Skip to content

Grammar stops whenever there is a valid parse even if you could generate more #7

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

Open
marcotcr opened this issue Oct 6, 2023 · 0 comments

Comments

@marcotcr
Copy link

marcotcr commented Oct 6, 2023

Minimum example:

grammar = '''start: expression

expression: expression " " expression | terminal
terminal:  "token1" 
         | "token2"
'''.strip()
parser = Lark(grammar, parser='lalr')
p = ParserState(parser)

Now, this works for incomplete parses, e.g.

p.next_lex('')

{'TOKEN1', 'TOKEN2'}

p.next_lex('token1 ')

{'TOKEN1', 'TOKEN2'}

Now, let's say you have a state that is itself a valid parse, but which also allows for more tokens to be generated (notice I removed the trailing whitespace):

p.next_lex('token1')

[]

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

1 participant