feat: Compiler architecture#21
Draft
Gashmob wants to merge 8 commits into
Draft
Conversation
Part of #2 Some cleanup before continue to work on features *No functional changes expected*
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
9d1b482 to
a702129
Compare
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
a702129 to
2c346a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2
Full architecture of the compiler but with a stub language
Checklist