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

Wrong positions with GLRParser and EMPTY #110

Closed
Hyldrean opened this issue May 26, 2020 · 5 comments
Closed

Wrong positions with GLRParser and EMPTY #110

Hyldrean opened this issue May 26, 2020 · 5 comments
Labels

Comments

@Hyldrean
Copy link
Contributor

  • parglare version: 0.12.1.dev13+gc0df483
  • Python version: 3.5.3
  • Operating System: Debian GNU/Linux 9 (stretch) 64 bits

Description

The start/end positions are sometimes wrong when we use the GLRParser and grammar with EMPTY. NB: I couldn't reproduce the bug with the LR Parser.

What I Did

Here is a minimal working example

from parglare import GLRParser, Grammar

rules = """
S: A A B;
A: letter;
B: letter | EMPTY;

terminals
letter: /\w/;
"""
g = Grammar.from_string(rules)
parser = GLRParser(g, build_tree=True, debug=False, debug_colors=True)
result = parser.parse("ab")
print(result[0].tree_str())

It gives the tree


S[0->1]
A[0->1]
  letter[0->1, "a"]
A[1->2]
  letter[1->2, "b"]
B[1->1]

One can easily see that it's rather

S[0->2]
A[0->1]
  letter[0->1, "a"]
A[1->2]
  letter[1->2, "b"]
B[2->2]
@igordejanovic
Copy link
Owner

Thanks for the report. Could you make a PR with failing regression test?

@Hyldrean
Copy link
Contributor Author

It is the very first time I use py.test and I do a pull request. I hope all is fine.

@igordejanovic
Copy link
Owner

@Hyldrean It's perfect. Thanks!

@igordejanovic
Copy link
Owner

Fixed on master

@Hyldrean
Copy link
Contributor Author

Thanks ! It works for me ;)

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