inline alts need newline
to duplicate: paste the below grammar into ohm-editor, case 0: no error, case 1: uncomment "Thing1a rule" -> parse error in grammar
severity: low workaround: always include newline after inline "-- ..." alternate declaration
testGrammar { Main = Thing0a Thing0a Thing0 = | A | B
Thing1 = | A -- a | B -- b
Thing0a = | A | B // Thing1a = | A -- a | B -- b
A = "a" B = "b" }
Hi @guitarvydas,
This is how we intended the syntax of "case labels" to work, and our motivation was to keep grammars readable. I would argue that
Thing1
= A -- a
| B -- b
is much more readable than
Thing1a = A -- a | B -- b
Now, I understand this may be more heavy-handed than you might like. And it would be great if we could produce a nicer error message for your example. But I don't think it's a good reason to relax the syntax.
Do you disagree?
I don’t disagree, but it wasn’t obvious from the documentation.
I found a (single) edge-case where it made sense to collapse the grammar and have something like Thing1a on one line, but, I usually I don’t do this.
thanks pt
On Apr 19, 2022, at 1:20 PM, Alessandro Warth @.***> wrote:
Hi @guitarvydas https://github.com/guitarvydas,
This is how we intended the syntax of "case labels" to work, and our motivation was to keep grammars readable. I would argue that
Thing1 = A -- a | B -- b is much more readable than
Thing1a = A -- a | B -- b Now, I understand this may be more heavy-handed than you might like. And it would be great if we could produce a nicer error message for your example. But I don't think it's a good reason to relax the syntax.
Do you disagree?
— Reply to this email directly, view it on GitHub https://github.com/harc/ohm/issues/373#issuecomment-1102899276, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAM4YGA5666UTNN2QAB4UA3VF3TM5ANCNFSM5TYHQRHQ. You are receiving this because you were mentioned.