Skip to content

This grammar causes parsing to hang indefinitely #797

Answered by jdidion
jdidion asked this question in Q&A
Discussion options

You must be logged in to vote

I'm finding that rules like the following are very slow:

equality = _{ not_equal | equal | comparison }
equal = { comparison ~ ( eq ~ comparison )+ }
not_equal = { comparison ~ ( ne ~ comparison )+ }

If I re-write this as

equality = { comparison ~ ( (eq | ne ) ~ comparison )* }

parsing time decreases by an order-of-magnitude. I am not sure if this is the root cause yet. I'm going to re-write the expression grammar and see if that resolves the issue.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tomtau
Comment options

You must be logged in to vote
1 reply
@tomtau
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #792 on February 11, 2023 02:20.