-
Notifications
You must be signed in to change notification settings - Fork 48
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
Brace use in productions. #108
Comments
Good question :) It actually was considered to add a |
Aye, in the process of converting my grammar over from my homebrew parser, I found the absence of square-bracket a little more frustrating. It felt like something that ought to be feasible as syntactic sugar... I.e writing:
could be treated as
|
This is a great example of where the SDT rules would be awkward. |
[edit: after reading the gocc2.bnf I'm guesisng 'sdt' specifically refers to the <<...>> directives; I'll write a follow-up] Sure, something like this?
I'll try to swing back to this and look at the code so I can see if how I'm now thinking it might be implemented is feasible, but
would effectively be internally mapped to
Pardon my oafishness - self-taught and aside from toy parsers/compilers for small dsls I haven't worked on a real parser in anger since I wrote a mud language+engine where the compiler produced an abstract grammar that the engine subsequently used to drive a bottom-up parser to interpret player input ('plant the big plant in the little plant pot and pot the little plant with the big potted plant' [spot the catch :)]). |
After reading the gocc2, I think you're referring to trying to capture the "optional" field in a production:
vs
If "[...]" is replaced with a logical substitute, then "[ Parent ]" would remain $2 regardless, it would just have a nil value when none was provided, so it would still be treated exactly as
The precedent for this is "anonymous terminals", where gocc allows
instead of requiring
|
I can see cases where a naive approach would cause problems:
obvious but flawed workarounds:
or:
|
Yes exactly |
I think this might work for the optional case, not sure about all implications, but at least SDT rules look nice. |
Yes I think already |
Tripped myself on subtle difference between token and production definitions :)
->
which is the unquoted open brace:
Obviously, I need to use the alternate structure here, but I'm just curious if it wouldn't actually just make sense to have that effect achieved by introducing the use of '{' in productions anyway?
The text was updated successfully, but these errors were encountered: