I'm trying to create a Beginning-Of-Line token:
lexer grammar ScriptLexer;
BOL : {getCharPositionInLine() == 0;}; // Beginning Of Line token
But the above emits the error
The name 'getCharPositionInLine' does not exist in the current context
As it creates this code:
private void BOL_action(RuleContext _localctx, int actionIndex) {
switch (actionIndex) {
case 0: getCharPositionInLine() == 0; break;
}
}
Where the getCharPositionInLine()
method doesn't exist...
GetCharPositionInLine()
(PascalCase as recommended by various C# code guidelines) – LabriecharPositionInLine
in there, but I'm not really familiar with C# to post an answer (hence this comment). – AustralopithecusColumn
property, sofragment BOL : { Column == 0 } ;
(or== 1
, dunno) should probably work (I don't think it makes sense to have an empty lexer rule, hence thefragment
). – Constrictorthis.charPositionInLine === 0;
wherethis
refers to Lexer superclass. – Wilber