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

Bug in handling of maybe_placeholders #1078

Closed
erezsh opened this issue Jan 15, 2022 · 0 comments
Closed

Bug in handling of maybe_placeholders #1078

erezsh opened this issue Jan 15, 2022 · 0 comments
Labels

Comments

@erezsh
Copy link
Member

erezsh commented Jan 15, 2022

Describe the bug

When missing alternatives within [], Lark will produce None for all the alternatives, while only generating one match if any of them match.

This breaks the principle behind it, the argument count must remain the same whether or not there is a match.

To Reproduce

from lark import Lark

p = Lark(r"""
start: b [c | d]

b: "b"
c: "c"
d: "d"

""")

print(p.parse('b').pretty())
print(p.parse('bc').pretty())

# Output
# ------

# start
#   b
#   None
#   None

# start
#   b
#   c

@MegaIng @ornariece Not sure how we missed it, but we need to fix it.

Related PRs: #922

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

1 participant