[antlr-interest] Expression parsing ideas for ANTLR v4
JALuber at gmx.de
Wed Jan 20 04:08:14 PST 2010
> Several expression parsers are limited to handling the binary operator
> portion of the expression. In addition to the obvious limitations, it
> poses an additional problem for languages like C++ where the assignment
> operators are split (in precedence) from the rest of the binary
> operators by the ternary operator (?:). My most complicated production
> ANTLR grammar (parses the UnrealScript language) currently uses a
> completely new expression parser that offers a great deal more
> flexibility than the previous approaches I tried. I don't think it's the
> end-all solution for integrating expression parsing into ANTLR for v4,
> but I believe it's a worthwhile example to show what's possible. Here
> are some pros and cons of the implementation:
> I'm very interested in any feedback y'all may have on this.
As a layman in expression parsing I don't feel qualified to comment on if your solution lacks certain features, but the way you define the operators looks clean to me. One knows immediately how operators work in a given language. The only not obvious thing is if the precedence is ascending or descending. I guess ascending from my knowledge of C#.
BTW, which tokens are encoded as CATEQ and CAT2EQ?
Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
More information about the antlr-interest