pascalabcnet/Parsers/PascalABCParserNewSaushkin/Preprocessor3.lex

89 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2015-05-14 22:35:07 +03:00
%{
%}
%scannertype PreprocessorScanner
%namespace GPPGPreprocessor3
%using PascalABCCompiler.SyntaxTree;
%using QUT.Gppg;
2019-03-27 21:56:13 +03:00
DotChr [^\r\n]
OneLineCmnt \/\/{DotChr}*
STRINGNUM \'([^\'\n]|\'\')*\'
2015-05-14 22:35:07 +03:00
DIRECTIVE [^\}]+
NODIRECTIVE [.|\n]+
%x INSIDEDIRECTIVE
2019-03-27 21:56:13 +03:00
%x COMMENT
%x COMMENT1
%x COMMENTONELINE
2015-05-14 22:35:07 +03:00
%%
2019-03-27 21:56:13 +03:00
{STRINGNUM} {
}
{OneLineCmnt} {
}
2015-05-14 22:35:07 +03:00
"{$" {
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;
}
2019-03-27 21:56:13 +03:00
"{" {
BEGIN(COMMENT);
}
<COMMENT> "}" {
BEGIN(INITIAL);
}
<COMMENT>.|\n {
}
"(*" {
BEGIN(COMMENT1);
}
<COMMENT1> "*)" {
BEGIN(INITIAL);
}
<COMMENT1>.|\n {
}
2015-05-14 22:35:07 +03:00
%{
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));
}*/