[antlr-interest] Checking for missing optional token in rule

Burton Samograd burton.samograd at markit.com
Mon Jul 23 14:55:26 PDT 2012


See the comment below for an explanation:

paren_delimited_numeric_unit_list
    : LPAREN number unit1=unit (COMMA number unit2=unit? {
            // I would like to check if unit2 was present in the input tokens
            // and do something if it was not.
        })* RPAREN
        -> (number unit)+
        ;

In the tree walker we can say ($unit2 == NULL) to check for presence, but that technique does not work in the parser.  Is there a way to do what I would like to do?

Thanks.

--
Burton Samograd

________________________________
This e-mail, including accompanying communications and attachments, is strictly confidential and only for the intended recipient. Any retention, use or disclosure not expressly authorised by Markit is prohibited. This email is subject to all waivers and other terms at the following link: http://www.markit.com/en/about/legal/email-disclaimer.page

Please visit http://www.markit.com/en/about/contact/contact-us.page? for contact information on our offices worldwide.


More information about the antlr-interest mailing list