Replies: 5 comments 1 reply
-
OK I have more insights if I gen C# and debug the parser. The issue is that when it sees the If I remove that token and just define the statement as |
Beta Was this translation helpful? Give feedback.
-
This is the problem. I need a way to tell the parser that if it sees Right now I just have this:
And it does not see 'call' as being an identifier so always parses a statement starting with 'call' as being a keyword statement... |
Beta Was this translation helpful? Give feedback.
-
you can achieve this using semantic predicates
… Le 15 déc. 2022 à 15:26, Hugh Gleaves ***@***.***> a écrit :
This is the problem. I need a way to tell the parser that if it sees IDENTIFIER and that identifier is the text "call" then parse a call_stmt.
—
Reply to this email directly, view it on GitHub <#4018 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAZNQJC6ISEUDS3AX5ECPSLWNMS7XANCNFSM6AAAAAAS65GUAY>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
-
@ericvergnaud - Thanks Eric, I've looked for that recently but struggling a little. I did get someway toward a resolution, this grammar recognizes things now:
This input parses correctly in
But you'll see stuff like this:
Where I must call out the keywords individually. |
Beta Was this translation helpful? Give feedback.
-
OK I solved this now, this seems to be the way to go:
Earlier I define
seems to give me what I need ! Thx |
Beta Was this translation helpful? Give feedback.
-
I've hit a roadblock experimenting with a simplified PL/I grammar. The parser is interpreting an assignment statement as if it were a keyword statement.
The PL/I language will treat a statement as an assignment if it satisfies the grammar of an assignment, only if it does not will it then attempt a keyword based parse.
So, is there a way in Antlr to force that? given this parser rule:
If the text satisfies the first rule, can we not simply leave it at that? can we forcibly prioritize the two rules?
Here's my draft grammar:
and here is the input used to test in
grun
They are both assignments according to the grammar, the second line satisfies the assignment grammar and does not satisfy the
call
keyword grammar so why does the parser complain? the text obeys the grammar!Beta Was this translation helpful? Give feedback.
All reactions