Skip to content

Does choice guarantee order? #133

Answered by zesterer
baanan asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, this also holds for choice. Chumsky is a PEG parser, so ambiguity is resolved by simply using the order of patterns as the tie-breaking mechanism.

As mentioned in the docs, choice has a few tradeoff compared to or chains:

  • It's significantly faster to compile (I'm hoping that a future version of Rust will be able to memoise trait solving to fix this)
  • Its error selection is very slightly weaker (but still sufficient for 90% of use-cases)

Replies: 1 comment 1 reply

Comment options

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

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