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

Priorities not working within recursive rules #1441

Open
ThatOtherAndrew opened this issue Aug 6, 2024 · 0 comments
Open

Priorities not working within recursive rules #1441

ThatOtherAndrew opened this issue Aug 6, 2024 · 0 comments

Comments

@ThatOtherAndrew
Copy link

Describe the bug

Using a priority after a terminal works fine for non-recursive rules, however in a recursive rule it fails to apply how I expected - see below reproduction example. This is very likely just me misunderstanding how Lark works, but better safe than sorry! I had a grueling few hours chewing through the documentation trying to piece together what's going on, to no avail.

To Reproduce

Here's a minimal reproduction of the issue:

parser = Lark('''
%import common.SIGNED_INT
%import common.SIGNED_FLOAT
%import common.WS
%ignore WS
FLOAT.1: SIGNED_FLOAT
INT: SIGNED_INT
start: FLOAT | INT | "[" (start)* "]"
''')
print(parser.parse('[1 2.0 3]').pretty())

Which results in:

start
  start	1
  start	2
  start	.0
  start	3
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