You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do not know if this is the right place to ask, but I tried to implement the following parser:
The text has lines that are separated by "\n". Like this a = { b ~ c ~ d ~ "\n" }
This means that no "\n" has to appear between the rules b, c and d.
But there is an expectation that you can have multiline support by using parentheses. So this means that if there are parentheses, the new line as a separation should be ignored. Like a = "(" ~ "\n"? ~ b ~ "\n"? ~ ")"~ c ~ d ~ "\n"
The parentheses can appear between (b and c) or (b and d) or (c and d).
Something like this:
a = { b ~ c ~ d ~ "\n" |
"(" ~ "\n"? ~ b ~ "\n"? ~ ")"~ c ~ d ~ "\n" |
"(" ~ "\n"? ~ b ~ "\n"? ~ c ~ "\n"? ~ ")" ~ c ~ d ~ "\n" | etc. }
b = { "b" }
c = { "c" }
d = { "d" }
I tried to use the stack, but I did not figure it out. Maybe you guys have a nice solution, where I do not have to write any combination of the rules in parentheses.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi guys,
First, thanks for this awesome library.
I do not know if this is the right place to ask, but I tried to implement the following parser:
a = { b ~ c ~ d ~ "\n" }
a = "(" ~ "\n"? ~ b ~ "\n"? ~ ")"~ c ~ d ~ "\n"
b
andc
) or (b
andd
) or (c
andd
).Something like this:
I tried to use the stack, but I did not figure it out. Maybe you guys have a nice solution, where I do not have to write any combination of the rules in parentheses.
Beta Was this translation helpful? Give feedback.
All reactions