Skip to content

feat: Compiler architecture#21

Draft
Gashmob wants to merge 8 commits into
masterfrom
2-compiler-architecture
Draft

feat: Compiler architecture#21
Gashmob wants to merge 8 commits into
masterfrom
2-compiler-architecture

Conversation

@Gashmob
Copy link
Copy Markdown
Owner

@Gashmob Gashmob commented Mar 22, 2026

Closes #2

Full architecture of the compiler but with a stub language

Checklist

  • I've followed Contributions guidelines
  • I have performed a self-review of my code
  • If it's a new feature, I've added tests that covers it
  • If it's a bug fix, I've added test case to reproduce the bug

Part of #2

Some cleanup before continue to work on features

*No functional changes expected*
@Gashmob Gashmob self-assigned this Mar 22, 2026
@Gashmob Gashmob linked an issue Mar 22, 2026 that may be closed by this pull request
Gashmob added 6 commits March 23, 2026 21:01
Part of #2

End of cleanup: extracted project creation logic of new command in its
own module. It avoid having too large files

*No functional changes expected*
Part of #2

Instead of having multiple Error type, I choose to have a single one
named Fault which holds a message and an Error. This way, each time
something may return an error, it will return a fault with the
corresponding message.

I got the idea to handle errors this way because:
- it will be the way in fil
- I use it in php at my work

*No functional changes expected*
Part of #2

[lalrpop](https://github.com/lalrpop/lalrpop) is a rust LR parser generator. It seems able to handle fil syntax. For now, the syntax is the one their tutorial (we don't need more for this issue).

*Testing:*

Have a simple arithmetic operation (+-/*) in a `src/main.fil`, run `fil build` you should get a "Not yet implemented" message.

Replace the file content by anything but an operation, you should get a syntax error coming from lalrpop
Part of #2

This way error are more intelligible by a human
Part of #2

It is still very basic but the idea is present. In future ast (the real
one), we'll have more information (like the position) and thus we will
be able to have something more precise and useful

*Testing:*

Try build a valid operation -> you have the not yet implemented message

Try build a division by 0 -> you have an error message telling you it is
not valid
Part of #2

Validation is already in its own mod, so Parsing and grammar should be
too. It is easier to read having each part separated
@Gashmob Gashmob force-pushed the 2-compiler-architecture branch from 9d1b482 to a702129 Compare April 15, 2026 19:05
Part of #2

*Testing:*

run `fil build` in a valid project, it should output corresponding llvm
ir. If you interpret it with lli you should get the result of the
operation as exit code
@Gashmob Gashmob force-pushed the 2-compiler-architecture branch from a702129 to 2c346a7 Compare April 21, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler architecture

1 participant