[antlr-interest] Tricky vector constructor syntax
richard at exaflop.org
Sun Jul 17 14:10:29 PDT 2005
I'm trying to write a parser for a scripting language used in an online game.
The language is predictably very C-like with a few twists, most of which are
quite benign, but one is really twisting my melon.
The language supports vectors and quaternions as data types and they have
provided syntax for constructing instances of these types that make it just a
little bit tricky to parse. For example:-
vector v = <4.0 , 1.2, 0>;
Of course that's just an initializer, the same angle bracket syntax can be
used in expressions and each of the three elements of the vector can of
course be expressions also. A quaternion is for the sake of parsing just the
same except it has four components.
The grammar (which I've attached) has an expression section shamelessly
lifted from the java.g sample grammar but altered slightly to match the
original yacc grammar supplied by the makers of the game. For the moment I've
placed a rule for just the vector at the same level as the other constants
(the last alt of the postfixExpression rule) and even with a syntactic
predicate it still causes the same ambiguity warning. Does this look right or
should I try and shoehorn it in at the same level as the < operator?
I commented out some other stuff so at least without the production in
question the grammar compiles without warnings to give a fighting chance! And
the lexer isn't complete yet so it won't produce the right tokens. Oh and
please don't ridicule my choice of token names too much :)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 8498 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050717/1c02f97d/LSLCompilerFrontEnd.obj
More information about the antlr-interest