-
Hello, I am using pest parsing markdown. I write the follwing grammar: What's wrong with my grammar? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
PEG is greedy. Your top-level grammar is To parse this, we first try
The simple solution which probably does what you want is to instead use |
Beta Was this translation helpful? Give feedback.
PEG is greedy. Your top-level grammar is
inline = { chars | em }
.To parse this, we first try
chars = { char* }
.chars
will always succeed -- it can match the empty string. Thus theem
side of the alternation will never be tried;chars
succeeded already.The simple solution which probably does what you want is to instead use
chars = { char+ }
, such thatchars
must match at least onechar
, and ifchar
fails to match, theninline
will continue on to try the next alternation,em
.