[antlr-interest] Semantic predicates during AST construction

Johannes Luber jaluber at gmx.de
Mon Oct 6 15:47:58 PDT 2008


Oliver B. Fischer schrieb:
> -----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...

Actions are in ANTLR always language dependent. Once Loring finishes
ANTLR/Yggdrasil (hey, are you still working on this, Loring?), this
won't be true if you decide to switch the system. Yggdrasil has some
differences compared to pure ANTLR, but is then language independent.

Johannes
> 
> 
> 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-----
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 



More information about the antlr-interest mailing list