eatkins / tree-sitter-ebnf-generator

Convert an EBNF grammar to the tree-sitter dsl
GNU General Public License v3.0
23 stars 2 forks source link

Maybe a mistake in the README.md ? #4

Closed mingodad closed 3 years ago

mingodad commented 3 years ago

Looking at the README.md and the explanation/example shown bellow:

    matches either the expression to the left of the | or the expression
    to the right. Concatenation has higher precedence than alternation
    so (A B) | (C | D) is equivalent to A B | C D.

If I understood it correctly because we are using grouping () to override precedence the example above could not be equivalent.

'(A B) | (C | D)' <> 'A B | C D'
mingodad commented 3 years ago

And this is one of the reasons I'm advocating to have an option to output an EBNF compatible with https://www.bottlecaps.de/rr/ui to help visually understand the iterations of a rule.

Input on Edit Grammar tab:

equiv ::= (A B) | (C | D)

Simplified shown on View Diagram tab:

equiv    ::= A B
           | C
           | D

And here in https://arthursonzogni.com/Diagon/#Grammar (as their EBNF syntax):

equiv = (A , B) | (C | D);

Output:

equiv:
    │├──╮── A ── B ──╭──┤│
        │            │
        ╰──── C ─────╯
        │            │
        ╰──── D ─────╯
eatkins commented 3 years ago

You are correct. There was a typo in the README.

eatkins commented 3 years ago

Fixed by #6