-
Notifications
You must be signed in to change notification settings - Fork 169
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
Online playground ? #434
Comments
That's super cool! I'd love to see it work. I don't know much about Lua, but I hope that sources list can be auto generated somehow so that your script is easily updated when files are removed/added. |
Would be nice to have code generation for |
Here is my attempt to manually port (not yet runable)
|
And here is
|
I noticed that this piece of code is repeated a lot only changing the last line goto destination:
|
@mingodad I suggest starting with simpler examples if you want to experiment with a JS backend. But more importantly, I'm leaning towards a different approach for adding new backends in re2c. Not the way we did it with C/Rust/Go, but instead, there should be a way to write a backend "syntax file" with some configurations, and re2c should be able to generate code using those configurations. This is much more scalable than hardcoding every new backend, and much less demanding in terms of documentation (as only one config file per language will be needed). People would be able to use local syntax files for whatever language they need, or upstream them with some examples to prove that they are working. I actually plan to rework the early Dlang patch done by @abenedic (8df0ed6) this way. I think merging that early support straight into master was premature; it should have been on a branch until the full backend is ready. Dlang and JS support will only be added after implementing that "syntax file" logic (and other backends should be rewritten using this logic as well, without breaking backwards compatibility). I hope to start working on it approximately in a month time, and I'm not sure how long it will take: it's difficult to decide on an optimal set of configurations that would accommodate many languages, and it is generally a lot of work. I'm sorry that it blocks your work, but this is needed to keep re2c lean and maintainable. It may be tempting to add new backends, but if they have very few users and take a lot of effort to maintain, this is not a good solution. |
Thank you for reply ! |
Not quite, files like https://github.com/adrian-thurston/ragel/blob/master/src/host-js/rlparse.lm are language frontend parsers, and they are part of the Ragel source files (codegen definitions are in https://github.com/adrian-thurston/ragel/blob/master/src/host-js/main.cc which is also a source file). What I want is more dynamic: a syntax file should be read at runtime, so that one could add a new language just by writing a new file (no changes to source code needed, provided that the set of configurations in syntax file is sufficient for the new language). But thanks for the link, it is interesting. It may be a good place to look if we want to add language-specific lexers to fix #429. It also raises an interesting point that if we want languge-specific frontends, they may also need some configurations. |
I'm looking to create a kind of online playground like:
And to start with I created this
Lua
script to generate an amalgamation of this project.mk-re2c-amalagamation.lua:
The text was updated successfully, but these errors were encountered: