pascalabcnet/Parsers/PascalABCParserNewSaushkin/Preprocessor3.lex

49 lines
984 B
Plaintext
Raw Permalink Normal View History

2015-05-14 22:35:07 +03:00
%{
%}
%scannertype PreprocessorScanner
%namespace GPPGPreprocessor3
%using PascalABCCompiler.SyntaxTree;
%using QUT.Gppg;
DIRECTIVE [^\}]+
NODIRECTIVE [.|\n]+
%x INSIDEDIRECTIVE
%%
"{$" {
BEGIN(INSIDEDIRECTIVE);
}
<INSIDEDIRECTIVE> "}" {
BEGIN(INITIAL);
}
<INSIDEDIRECTIVE> {DIRECTIVE} {
2017-05-09 20:37:50 +03:00
//if (yytext.Contains("\n"))
// Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,"error: LF into directive");
2015-05-14 22:35:07 +03:00
//else Console.WriteLine("({0},{1}) {2}",tokLin,tokCol,yytext);
yylval = new Directive(yytext, new LexLocation(tokLin, tokCol, tokELin, tokECol));
var t1 = yylloc;
return (int)Tokens.DIRECTIVE;
}
{NODIRECTIVE} {
return (int)Tokens.NODIRECTIVE;
}
%{
yylloc = new LexLocation(tokLin, tokCol, tokELin, tokECol);
%}
%%
/*public override void yyerror(string format, params object[] args)
{
string errorMsg = parsertools.CreateErrorString(yytext,args);
parsertools.AddError(errorMsg,new LexLocation(tokLin, tokCol, tokELin, tokECol));
}*/