I want the information from a syntactic predicate but don't want to select an alternative.

Monty Zukowski

You can't do it, but you can probably work around it. I wanted to know if a case block had any labels, if so the translation was slightly different, so I just wanted to set a flag.

    hasLabel = false;
        (#("begin" (~(LABEL))* LABEL))=> {hasLabel = true;}
           rest of rule here...

ANTLR complains because you aren't using the syntactic predicate to choose an alternative. What I did was made a seperate rule that does the work of transforming the case block and then passed in a parameter based on the syntactic predicate.

        (#("begin" (~(LABEL))* LABEL))=> caseBlockTransform[true]
        | caseBlockTransform[false]
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.