Improved error printing torquescript

Added a vector that can lookback across x number of lines in a file, if not a file just print out the error.
This commit is contained in:
marauder2k7 2024-04-27 21:19:56 +01:00
parent f82082f59f
commit 8cf5fac497
4 changed files with 130 additions and 110 deletions

View file

@ -55,7 +55,7 @@ static int Sc_ScanIdent();
#define FLEX_DEBUG 0
#endif
char linebuf[512];
Vector<String> lines;
// Install our own input code...
#undef CMDgetc
@ -116,7 +116,13 @@ HEXDIGIT [a-fA-F0-9]
("///"([^/\n\r][^\n\r]*)?[\n\r]+)+ { return(Sc_ScanDocBlock()); }
"//"[^\n\r]* ;
[\r] ;
\n.* { yycolumn = 1; dStrcpy(linebuf, yytext + 1, sizeof(linebuf)); yyless(1); }
\n.* { yycolumn = 1;
lines.push_back(String::ToString("%s", yytext+1));
if (lines.size() > Con::getIntVariable("$scriptErrorLineCount", 10))
lines.erase(lines.begin());
yyless(1);
}
\"(\\.|[^\\"\n\r])*\" { return(Sc_ScanString(STRATOM)); }
\'(\\.|[^\\'\n\r])*\' { return(Sc_ScanString(TAGATOM)); }
"==" { CMDlval.i = MakeToken< int >( opEQ, yylineno ); return opEQ; }