Skip to content

Why does regex affect outer rules? #1281

Answered by MegaIng
mannim72 asked this question in Q&A
Discussion options

You must be logged in to vote

You can make this work by using lexer="dynamic_complete". This is very, very slow. For large inputs.

Lark uses regex engines (either the stdlib re or the third party regex). Those will consume as much as they can, independent of the surrounding grammar. So the terminals lark sees are "[", "FOobarbaz]" and then $EOF. This is not fixable from the park side without massive performance hits.

You can use foo: /./+, but like the dynamic complete option, this will be very slow, and in addition the Tree will be annoying to use.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mannim72
Comment options

@mannim72
Comment options

Answer selected by mannim72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants