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
syntax for multiline comments #78
Comments
Something along the lines of:
Does that answer your question? |
it helped, thanks ;-) but it's still not ok ... on my fork https://github.com/goulu/lark you will see a pascal/delphi grammar here : https://github.com/goulu/lark/blob/master/lark/grammars/delphi.g , with:
which works in simple cases, BUT doesn't with my test file https://github.com/goulu/lark/blob/master/tests/test_delphi/cclasses.pas line 3135 :
causes a parse error:
but if I convert it as a single line comment like this : Any idea ? |
Maybe, try to remove the terminal definition of LCURLY. |
did it, but no change ... is there a way to get a clearer error message, like a context, or which rules/terminals are expected in the "unexpected input" ? |
Okay, you're right! I added some more information. It now says:
I'm not sure why this happens. It might be a bug in the parser? See if you can get it to happen for a smaller input and grammar. It will help you debug, and if it looks like a bug, it will help me debug too. |
Ok I just modified the "Hello World ! " example like this:
but it crashes :
if I remove the \n from COMMENT : "{" /(.|\n)+/ "}" // then it works. So I suspected the \n should be in some way escaped and tried \\n instead : IT WORKS ! :-)
|
I'm having the same kind of problems with a basic Token definition: |
@mcondarelli If you're defining the grammar in a Python file, you should define it as a raw string:
|
@goulu I'm glad you figure it out. You can also use raw strings ( Btw, how is the performance? Using Earley with such a big grammar and big input files can lead to some serious runtime! Generally I recommend using LALR for such tasks. |
Hi, just want to feedback back that defining grammar in a python file should be done as a raw string was a gotcha to me. Perhaps it might be helpful to add it in the examples or something. Anyhow, lark is a joy to use, thanks for maintaining it :) |
what would be the grammar to parse expressions like (Delphi):
thanks !
(I'll share the Delphi grammar as soon as it works)
The text was updated successfully, but these errors were encountered: