Skip to content

Priorities not working within recursive rules #1441

Description

@m31-galaxy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions