Skip to content

Branch rule for parsing chr once but not twice #50

Answered by foonathan
lmichaelis asked this question in Q&A
Discussion options

You must be logged in to vote

Instead of using dsl::peek_not(), there is also an alternative approach: using identifiers and keywords. They are designed to prevent partial matches. In your example, you want to match an operator consisting of e.g. ASCII punctuation, so that's your "identifier", and the operators in question are keywords: https://lexy.foonathan.net/playground/?id=a7berP9Ks&mode=tree Essentially, the keyword rule does something like this: https://lexy.foonathan.net/playground/?id=r4Ye6bxrM&mode=tree

Also note that if you can use the newly added dsl::literal_set() (or previously operator/) to achieve similar maximal munch: https://lexy.foonathan.net/playground/?id=7WG9vnb3e&mode=tree It matches the longes…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
7 replies
@lmichaelis
Comment options

@foonathan
Comment options

@benjaminwinger
Comment options

@lmichaelis
Comment options

@benjaminwinger
Comment options

Comment options

You must be logged in to vote
3 replies
@lmichaelis
Comment options

@foonathan
Comment options

@lmichaelis
Comment options

Answer selected by lmichaelis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants