-
Notifications
You must be signed in to change notification settings - Fork 11
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 ? #11
Comments
Shown bellow is a start point of translating https://github.com/facebookincubator/CG-SQL/blob/main/sources/cql.y and https://github.com/facebookincubator/CG-SQL/blob/main/sources/cql.l to the format understood by this project. I've noticed that this project do not seem to accept a dummy token name to be used only for precedence purposes.
Output:
|
That would be awesome. Thanks for taking the time!
You should be able to use a regular expression, e.g. |
Can you give me an example to show me what you mean? I don't quite understand how that would be used. Doesn't have to be related to the SQL grammar if you have a simpler example. Thanks. |
That's easily the biggest grammar that's been thrown at it. I'm not sure how much time I have over the next few weeks to look at this, but I'll see what I can do. I'd also be happy to accept a PR -- at a guess Profiling it first would be a better move though, that's just my intuition as to what's taking up time. |
Here https://www.gnu.org/software/bison/manual/html_node/Contextual-Precedence.html you can see the description of it.
|
The lalr equivalent is
Is that what you're after? |
Thank you again for reply ! It seems that's my fault because I was declaring But now I'm attaching the
|
There are some terminals that are undefined in that grammar, e.g. There was also an error with the Fixed grammar cql.zip |
Thanks !
How can those can be achieved in |
I'm trying multi word keyword like shown bellow and at least the grammar is accepted:
Trying to test a grammar with input with the code shown bellow I think that it could be added to the main
How to declare
Can you help make the attached example parse the Attached zip file contains:
|
When executing the example attached above I'm getting this:
|
I just added this test:
And if I use |
I also noticed that in several tests there is an unnecessary repetition of string literals, see the same test shown above without the repetitions:
|
I was mistakenly using
|
When I try this with grep I get an informative error message:
|
The easiest way is to use lexer actions within the whitespace token. See the tests
Then you need to register handlers for the #include <lalr/line_comment.hpp>
#include <lalr/block_comment.hpp>
//...
lalr::Parser<const char*, int> parser( parser_state_machine, &error_policy );
parser.lexer_action_handlers()
("line_comment", &lalr::line_comment<const char*>)
("block_comment", &lalr::block_comment<const char*>)
//... I've not tested that in your SQL grammar yet so YMMV. I'm just trying that now but I'm almost out of time for the evening. |
Good point. I've created #15 to track this. |
This is another problem that would be solved with better error reporting for regular expressions. The That syntax error seems like a bug in lalr rather than a true error, at the very least it's not clear what the actual problem is. See the cql branch for an example that works up to the syntax error. |
Would be nice to have a way to describe the comments (line/block) directly with regular expressions otherwise the online playground will not work for cases not hardcoded. Also on you |
When using
In several place where |
Looking at the code generated by this small grammar:
Partial output:
And comparing with this grammar:
Partial output:
I've noticed this appears repeated:
And also this strange LexerTransition:
|
Ah, of course. There's nothing stopping you using regular expression for these too. It was just easier for me to use the lexer actions.
Thanks. Fixed in main now. |
...
It's not unexpected for transitions to be repeated, they are transitions from different states which I don't feel are worth the trouble of combining. In this particular case I can't see why the state matching
This, and the transition before it, are matching |
I've made a few fixes to handling whitespace and to matching tokens where some tokens are prefixes of longer tokens. These fixes are all in main now. I've also updated the CQL grammar and example so that they parse. I've updated I don't quite have time to describe the changes I've made and the parts of the example script that I can't match to the grammar right now but hopefully the branch and commits are enough of an example to get you going a bit further. |
Thank you ! |
Looking at your fixes to accomplish case insensitive is not good enough |
Testing with this grammar https://github.com/AthrunArthur/cxxparser.git I'm getting 3 unresolved shift/reduce conflicts but bison/byacc reports none (see attached grammars):
|
Changing
|
Ah. You also need to add |
Closing now. I believe all of the problems raised here are addressed. |
I've just got an initial version of the playground working at https://meimporta.eu/lalr-playground/ see attached the source. |
It would be nice to have the
Also would be nice to be able to output an AST of the parsed source. |
Notice that when there is errors we can click on then to jump to the error on the corresponding editor. |
Also notice that if we check the |
Just added an option to load examples to play with ( |
I've got |
I just added a |
At the end only |
Testing the playground I noticed that when checking
Using this rule:
But when using this rule:
I'm seeing this:
I was expecting something like:
|
Also when trying the
It seems that the |
Also when trying the |
JUst added |
Just added a |
I also added a not yet working grammar for https://github.com/jplevyak/dparser that shows lots of shift/reduce conflicts, would be nice if the error messages could also include some kind of |
Looking through But the there is no example of usage of Can you give some help here ?
|
Would be nice to output a parser tree like here https://mingodad.github.io/lua-wasm-playground/ or something similar. |
Using this function while parsing with
Output:
|
After add column info to error messages and reviewing the with the You can see it here https://meimporta.eu/lalr-playground/ , select the
|
The problem for not showing an
|
I did a possible fix by adding another flag
|
Moving the Put the |
From looking at your playground online it looks like you've solved this already. But, if not, then set a default action handler function to handle all reductions. Inside that handler you'd copy out, at least, the symbols and lexemes in the array of |
Probably it's better to check if precedence is assigned to non-terminal and show an error message and maybe have an explicit grammar section for the lexer that allow more flexible regex constructions. |
Now the playground is also available at https://mingodad.github.io/lalr/ |
I'm looking at an online playground like:
And testing it before trying implementing it with a
SQL
grammar and didn't found any way to definecase insensitive
tokens/literals.The text was updated successfully, but these errors were encountered: