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

Grammar sends Earley implementation to an infinite loop #3

Closed
erezsh opened this issue Feb 17, 2017 · 5 comments
Closed

Grammar sends Earley implementation to an infinite loop #3

erezsh opened this issue Feb 17, 2017 · 5 comments
Assignees
Labels

Comments

@erezsh
Copy link
Member

erezsh commented Feb 17, 2017

Earley implementation never terminates when running with the input "a", and the following grammar:

start: a
a: a | "a"

Of course the grammar is badly formed, but since we aspire to parse "any grammar", an error is a more appropriate behavior.

@lucaswiman
Copy link

@erezsh If I understand correctly, this grammar is not malformed, but also enters into an infinite loop:

from lark import Lark

l = Lark('''
  start: bar+
  bar: /a|b|c*/ "foo"
''')

l.parse('afoobfooccfoo')

@lucaswiman
Copy link

It seems the issue is that the regex can match zero characters. This one works fine:

Lark('''
  start: bar+
  bar: /a|b|c+/ "foo"
''')

and this one fails in the same way as the example above:

Lark('''
  start: bar+
  bar: /a|b|/ "foo"
''')

@erezsh
Copy link
Member Author

erezsh commented Feb 24, 2017

Thanks, good catch!

I think the correct response is to forbid empty regexps.

@erezsh erezsh added the bug label Feb 24, 2017
@erezsh erezsh self-assigned this Feb 24, 2017
@erezsh
Copy link
Member Author

erezsh commented Mar 2, 2017

Both issues resolved.

@erezsh
Copy link
Member Author

erezsh commented Mar 9, 2017

Fixed!

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

No branches or pull requests

2 participants