Hendrik Maryns schreef:
> Hi all,
>
> I have a rule like the following:
>
> binary returns [Formula result]
> : IMPLICATION WHITESPACE first=formula WHITESPACE second=formula {
> $result = new Implication($first, $second); }
> | EQUIVALENCE WHITESPACE first=formula WHITESPACE second=formula {
> $result = new Equivalence($first, $second); }
> ;
>
> and I would like to do something similar for n-ary junctors, that is
> junctors that can take an arbitrary number of arguments.
>
> The bare rule would be:
> /**
> * Conjunction or disjunction.
> */
> n_ary returns [Formula result]
> : CONJUNCTION ( WHITESPACE formula )+
> | DISJUNCTION ( WHITESPACE formula )+
> ;
>
> And for CONJUNCTION I would like new Conjunction(Formula... args) to be
> invoked with the formulas found (ignoring whitespace). Similar for new
> Disjunction(Formula... args). As you might guess
>
> formula returns [Formula result] …
>
> is the starting rule.
>
> Can I simply do { $result = new Equivalence($formula); } or something?Surely this can’t be too difficult, I read something about adding stuff to a list, but I forgot where. Just a pointer would be fine really. I could define a constructor taking a list for both classes, NP. TIA, H. -- Hendrik Maryns http://tcl.sfs.uni-tuebingen.de/~hendrik/ ================== Ask smart questions, get good answers: http://www.catb.org/~esr/faqs/smart-questions.html
signature.asc
Description: OpenPGP digital signature
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
