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

Gokulakannan Somasundaram gokul007 at gmail.com
Mon Oct 15 17:13:41 PDT 2012

getCharPositionInLine() function is present inside Lexer. You can just call
it as similar to Java.
this->getCharPositionInLine() ?

I can't understand second part of your question.


On Tue, Oct 16, 2012 at 2:43 AM, Richard Gildea <rgildea at gmail.com> wrote:

> Hi,
> 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
> ({ GETCHARPOSITIONINLINE() > 0 }?=> ';')
> 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?
> Cheers,
> Richard
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address

More information about the antlr-interest mailing list