I am new with antlr4 ... I search a lot to get number of line and column for each token in antlr4 ... I have a well knewoleadge on flex and bison and I make a complete compiler for php with flex and bison ... in flex and bison I was get the number of line and column by a simple code : in bison.y I define struct :
struct R{ int i; float f; char c; char* str; int myLineNo; int myColno; }r; namespace_name_parts: // rule T_STRING { $
int lineNo = 1; int colNo = 1; "while" { yylval.r.myLineNo= lineNo; yylval.r.myColno = colNo; colNo += strlen(yytext); return T_WHILE ; }
this way I can get the line of number and column with flex and bison ... NOTE : I need the line of number and column for print my own type checking error so can help me to get the number of line and column for each token in antlr4
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)