-
-
Notifications
You must be signed in to change notification settings - Fork 114
JDL Compiler front-end Architecture & Implementation. #144
Comments
The point wasn't to have a compiler, but only a parser.
That's one of the issues I have with PegJS.
The project doesn't handle this point.
What's the point in doing this? I don't understand your second issue. |
Parser vs compiler's front-end
This is a matter of semantics, some refer to the lexing + parsing + ast creation + semantic checks Content-Assist
Yes indeed it does not, which is why there is logic duplication in the JDL-studio project So if the grammar changes, for example in the context of enriching the grammar that was discussed recently, that duplicate logic may also have to be modified. Original Text reproduction.
Lets say you want to build a linter for JDL How would you implement this using the existing data structure output from the parser? Another example would be refactoring.
I will try to emphasize this second issue once I fill the "alternative approach" section. |
Pinging @MathieuAA @deepu105 😄
|
Since @MathieuAA knows much better about the current parser I'll leave the decision to him. My personal opinion is that this seems more readable and maintainable than PegJS but a little more work initially to migrate everything I guess |
@bd82 @MathieuAA just one question currently I use the output json from PegJS parser for JDL studio, with this will the json structure change? |
I think it should not change, otherwise the scope of changes would be too large to safely handle. The difficult part is to ensure this actually happens without unintended changes... |
I could probably help by migrating the the grammar (Phases 1 & 2). And thanks for the compliment @MathieuAA 😄 |
Just a small update. I am hoping to start working on the grammar conversion (Phase 2) this weekend. |
This is getting messy, here's what I'm going to do:
|
Hi @MathieuAA I've recently finished version 1.0.0 of Chevrotain, so more free time... However I can only minimize the amount of work needed not complete it all. Hopefully I can minimize it enough to fit in your own free time constraints |
I still have some cleaning up to do (both in the internal project and in the app generation with PegJS), and I don't think the migration to chevrotain will be a priority. In my opinion, my initial mistake was not to 100% finish the app generation (and release it) before beginning the work needed for the chevrotain system. |
The more incremental approach seems best 👍 I will try to push migration issue a little farther in the upcoming new "side" branch. |
Alright! |
I think we can close this issue as merged the initial implementation to master |
yes |
Introduction
This issue is meant for discussion of the existing compiler architecture and implementation,
It's short comings and alternative approaches to resolve these short comings.
Existing Issues.
Root Issue
The root issue is that the existing solution solves the wrong problem.
The solution solves the problem of a compiler for code generation
Not a compiler that can also providing editor services.
Examples of missing requirements:
I recommend viewing this 30mins video on Modern Compiler Construction by Anders Hejlsberg for more details.
Secondary Issue
The other issue is that there is not enough separation of concerns in the existing implementation
Specifically separating the syntactic analysis phase (parsing) and everything else (Ast Building).
A small code snippet from the existing code clearly demonstrates this:
Can you tell at a glance:
Alternative Approach
There would be two main differences:
Instead of:
We will do:
This CST/Parse Tree structure will represents the original input, thus enabling the basis for these more advanced editor flows.
supporting editor related flows such as error recovery and multiple start rules.
Poc Highlights.
Instead of writing too many words lets just point to references in a run-able POC.
This POC implements a small subset of the JDL grammar to demonstrates the proposed
architecture and tooling. There several things missing, for example:
But the existing content is more than enough to review and discuss.
Phases
naming entities/fields/types/... cannot be applied as the names have common prefixes and the lexer does not have any information on the current context.
Parsing Phase
To create an AST. Instead the parser automatically creates a CST/Parse Tree which can later
be consumed for different use cases (separation of concerns mentioned earlier).
Ast Building Phase
Bonus Phase
as different "end users" can implement different parser related logic without modifying the parser
itself.
The text was updated successfully, but these errors were encountered: