[antlr-interest] How to use lexer getCharPositionInLine() function in Cpp target

Richard Gildea rgildea at gmail.com
Mon Oct 15 11:43:04 PDT 2012


I am attempting to convert my parser to use the Cpp target after previously
using the C target for some time, and have come across a problem trying to
call the function TLexer::getCharPositionInLine() inside a gated semantic
predicate in one of my lexer rules. With the C target I was using a
construct such as


to identify a semicolon character in the first column of a line. When
trying to use a similar construct with the Cpp target, in the generated
code this predicate is used both inside the lexer rule, where the correct
usage would be this->getCharPositionInLine(), and inside a cyclicDFA, where
the usage would be ctx->getCharPositionInLine(). Is there a way to use such
a predicate with the Cpp target?



More information about the antlr-interest mailing list