%namespace NewLanguage %using System.Text; %% /*[0-9a-zA-Z_][-0-9a-zA-Z_]* return (int)Tokens.Symbol;*/ [A-Za-z0-9_][\-A-Za-z0-9_]* { yylval.symbol = new SymbolNode(yytext); currentLine.Append(yytext); return (int)Tokens.SYMBOL; } [\-+/*\[\]<>=] { yylval.str = yytext; currentLine.Append(yytext); return yytext[0]; } [ \t]+ { currentLine.Append(yytext); /* ignore whitespace -- don't return anything */ } . { currentLine.Append(yytext); handler.Report(new SourceLocation(tokLin, tokCol, tokELin, tokECol, currentLine.ToString()), "unexpected character '{0}' in input", yytext); } /* epilog code -- appears at the end of the Scan method */ yylloc = new SourceLocation(tokLin, tokCol, tokELin, tokECol, currentLine.ToString()); %% public ErrorHandler handler; StringBuilder currentLine = new StringBuilder(); public override void yyerror(string msg, params object[] args) { handler.Report(yylloc, msg, args); }