I am doing a project with a Pascal subset. My code looks like:
NLINE [\n]
BRACKET ['('|')']
%%
{BRACKET} {
std::cout << "Found BRACKET symbol " << yytext[0] << std::endl;
return yytext[0];
}
{NLINE} {
std::cout << "Found NEWLINE symbol " << yytext[0] << std::endl;
yylineno++;
}
...
. { // anything is exactly before EOF
std::cout << "Found ANYTHING " << yytext[0] << std::endl;
yylval = NONE;
return yytext[0];
}
I tried many ways to deal with that, also just \n instead of [\n] or [ \n] but without the expected results. Below is the output:
...
Found BRACKET symbol )
Found ANYTHING ;
Found ANYTHING << where in code should be \n
I know that this is \n issue, because when I push the code without that it works like a charm!
Will appreciate every constructive answer.
(or)is[()]. Your pattern will match a parenthesis, an apostrophe, or a vertical bar. - rici