-
Notifications
You must be signed in to change notification settings - Fork 228
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
facing an error while parsing in case of newline token #646
Comments
One recommendation I would make is to not end (or begin) your definitions with "whitespace" pattern matches. This way you avoid parser ambiguities. Change:
Into:
To handle "whitespace" surrounding single statements, define it in the parent definition. For example:
Here is a working example from my own grammar:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i am creating a small programming language and i have set the grammar to handle statements like this:
statements
-> statement %NL
{%
(data) => {
return [data[0]];
}
%}
| statements %NL statement %NL
{%
(data) => {
return [...data[0], data[2]];
}
%}
but everytime is reaches the newline token it throws this error:
Error while parsing Error: invalid syntax at line 1 col 19:
1 @name = "mohammad"
^
2 call print(name)
Unexpected input (lexer error). I did not expect any more input. Here is the state of my parse table:
this is only in case of newline token everything else works fine
The text was updated successfully, but these errors were encountered: