[antlr-interest] Semantic predicates during AST construction
Oliver B. Fischer
o.b.fischer at gmx.de
Mon Oct 6 15:02:10 PDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
It is possible, if you call the ctor directly, but this is a language
dependend solution.
Here is an example:
- -> ^(PLUS $ruleA $ruleB
{(true != false) ? new SymbolTree(INT2FLOAT) : null })
I would like to have a more generic solution...
Gavin Lambert schrieb:
> At 20:30 6/10/2008, Oliver B. Fischer wrote:
>>I would like to express things like:
>>
>>-> ^(ROOT A ({condition}? B | C)
>>
>>Evaluates condition to true, I would like to get ^(ROOT A B).
>>Otherwise the result should be ^(ROOT A C).
>
> If B and C are tokens that exist on the matching side (left of the
> arrow) then I think you can do this (haven't tried it, though, so I
> could be wrong):
>
> A b=B c=C -> ^(ROOT A { (condition) ? $b : $c })
>
> It's probably possible to do this sort of thing with imaginary tokens as
> well, although I'm not sure exactly what the syntax would be.
>
- --
Oliver B. Fischer, Schönhauser Allee 64, 10437 Berlin
Tel. +49 30 44793251, Mobil: +49 178 7903538
Mail: o.b.fischer at gmx.de Blog: http://www.sw-blog.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkjqiuIACgkQbyc4N0PdoAxnrgCfdp3I0sEESrVQgGIcHSxzh1hq
i2EAoLDSUYNpABOJDe02pGY1vcysPtCo
=VF4H
-----END PGP SIGNATURE-----
More information about the antlr-interest
mailing list