-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-generating lexer.rs and parser.rs #17
Comments
To get started on the short term solution:
|
birkenfeld
added a commit
that referenced
this issue
Jul 9, 2017
Fork can be found here: github.com:birkenfeld/alex-rust ref #17
Work started with Alex in the "lexer" branch. Now I'll try my luck with Happy. |
birkenfeld
added a commit
that referenced
this issue
Jul 9, 2017
Fork can be found here: github.com:birkenfeld/alex-rust ref #17
Ok, parser is done in the "parser" branch. Sneaky proc-macro making clones behind my back! |
birkenfeld
added a commit
that referenced
this issue
Jul 9, 2017
Fork can be found here: github.com:birkenfeld/happy-rust Fixes #17
tcr
pushed a commit
that referenced
this issue
Jul 10, 2017
Fork can be found here: github.com:birkenfeld/alex-rust ref #17
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's important that parser-c be able to port fixes from upstream (language-c) even though they weren't written in Rust. For the most part, source code changes can be ported over manually, assuming that most patches will are small.
But, there are exceptions. lexer.rs and parser.rs are converted from Lexer.y and Parser.x, which are inputs to a Haskell-specific lexer and parser generator (Happy and Alex, respectively). Because these generate a large amount of Haskell code, the corresponding changes to Rust code must also be massive, so porting it over manually is prohibitive.
Corollary is not capable of doing this complex a conversion any time soon. (The current lexer.rs and parser.rs were heavily edited by hand.) These are the solutions I came up with instead:
Short term solution: We use Haskell's Happy and Alex libraries to do the code generation, but modify their codemod files to output Rust instead: ProduceCode.lhs and Output.hs. Inline Haskell code in the source .y and .x files must also changed to be Rust.
The benefit of this setup is that it's simple, and we can keep using it indefinitely. Requiring Haskell for the build step will not mean Haskell is required for consumers of the library—they'll only get the generated Rust code.
Long term solution: After this, I see three obvious choices:
There may be better solutions than either of the above!
The text was updated successfully, but these errors were encountered: