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

EBNF parse error #137

Open
TopIdiot opened this issue Dec 27, 2024 · 1 comment
Open

EBNF parse error #137

TopIdiot opened this issue Dec 27, 2024 · 1 comment

Comments

@TopIdiot
Copy link

TopIdiot commented Dec 27, 2024

I just use the grammar from https://github.com/ggerganov/llama.cpp/blob/master/grammars/README.md

using xgramar==0.1.7, reproduce code

import xgrammar as xgr

grammar_str =  """
char ::= [^"\\\x7F\x00-\x1F] | [\\] (["\\bfnrt] | "u" [0-9a-fA-F]{4})
item ::= "{" space item-name-kv "," space item-age-kv "}" space
item-age ::= ([0-9] | ([1-8] [0-9] | [9] [0-9]) | "1" ([0-4] [0-9] | [5] "0")) space
item-age-kv ::= "\"age\"" space ":" space item-age
item-name ::= "\"" char{1,100} "\"" space
item-name-kv ::= "\"name\"" space ":" space item-name
root ::= "[" space item ("," space item){9,99} "]" space
space ::= | " " | "\n" [ \t]{0,20}
"""

print(xgr.Grammar.from_ebnf(grammar_str))

got
RuntimeError: [07:57:35] /workspace/cpp/grammar_parser.cc:72: EBNF parse error at line 2, column 13: Invalid escape sequence

@Ubospica
Copy link
Collaborator

Thanks for the catch @TopIdiot. The issue here is the repetition {l, r} is not supported well by xgrammar. We are working to fix this issue.

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