Dear parsing experts,

I have been working on a medium-size parser using the PetitParser
framework, which so far has been a very productive environment.  But now
I have a problem to which I could not find the solution in "Deep into
Pharo", nor by searching around in the code.

One of my production rules requires several parsed items to be equal.
It should accept expressions such as

    1 + 3 + 2 + 6
    2 * 9 * 3 * 6
    0 - 8 - 5 - 3

but not expressions that mix different operators (because my grammar has
no precedence rules and thus requires parentheses for disambiguation).

In various other parsing frameworks, I do this by parsing up to the
first operator, retrieving it, and permitting only that same string in
the following. But I haven't found a way to do this in PetitParser, nor
any other obvious solution.

The only solution I see right now is to have one production rule per
operator, but that makes for a huge grammar. Is there another way?

Thanks in advance,
  Konrad

Reply via email to