How do you specify the "beginning-of-line" in the lexer? In lex, it is "^".
Created May 4, 2012
Terence Parr Here is a simple DEFINE rule that is only matched if the semantic predicate is true.
DEFINE : {getColumn()==1}? "#define" ID ;Semantic predicates on the left-edge of single-alternative lexical rules get hoisted into the nextToken prediction mechanism. Adding the predicate to a rule makes it so that it is not a candidate for recognition until the predicate evaluates to true. In this case, the method for DEFINE would never be entered, even if the lookahead predicted #define, if the column > 1.