Skip to content
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

Recursion in EBNF #39

Open
hiiroo opened this issue Jan 30, 2023 · 1 comment
Open

Recursion in EBNF #39

hiiroo opened this issue Jan 30, 2023 · 1 comment

Comments

@hiiroo
Copy link

hiiroo commented Jan 30, 2023

Hi, thanks for great library. However, I was trying EBNF grammar (I could not achieve recursion using the existing API).

p = ebnf"""
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
       | "H" | "I" | "J" | "K" | "L" | "M" | "N"
       | "O" | "P" | "Q" | "R" | "S" | "T" | "U"
       | "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
       | "c" | "d" | "e" | "f" | "g" | "h" | "i"
       | "j" | "k" | "l" | "m" | "n" | "o" | "p"
       | "q" | "r" | "s" | "t" | "u" | "v" | "w"
       | "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
word = letter, {letter};
term = "(", word, " ", (word | term), ")";
"""

where I was attempting to parse the following;

match(p, "(NP (NNP Test))")

However, grammar does not compile and give StackOverflowError. Is this supposedly happen or am I missing something. Because, following EBNF grammar is working at https://mdkrajnak.github.io/ebnftest/;

Term = "(", Word, " ", (Word | Term), ")";
Word ::= Letter, {Letter}
Letter  ::= #'[A-Za-z]'
Number ::= Digits ( ( '.' | ',' ) Digits? )?
Digits ::= #'[0-9]+'

Any help or redirection would be helpful. Thanks in advance.

@melonedo
Copy link

melonedo commented Feb 4, 2023

Seems like the parser for EBNF grammar itself is broken😥.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants