Replies: 3 comments 3 replies
-
Hello @dhowe I would use a Use the |
Beta Was this translation helpful? Give feedback.
-
Thanks. I did try that, though it was unclear to me how to specify the else part of the gate. If "alone", do subrule(X), else do subrule(Y) I think I tried something like below: $.RULE("ConditionalRule", () => {
$.OR([
{
GATE: () => $.LA(1).tokenType === X,
ALT: () => $.subrule('X')
},
{
GATE: () => $.LA(1).tokenType === Y,
ALT: () => $.subrule('Y')
}
])
}) I guess one could also just allow define a separate rule for each of the two cases (?) |
Beta Was this translation helpful? Give feedback.
-
Is there an example somewhere of a parser using lookahead/lookbehind to choose between rules ? thanks! |
Beta Was this translation helpful? Give feedback.
-
I have a grammar where new-lines are generally ignored, except in the case where there is a specific element alone on a line.
How to specify that two different rules should fire, one if the element is alone on a line (/^ELEMENT$/), and the other if it is not?
Beta Was this translation helpful? Give feedback.
All reactions