small fixes

This commit is contained in:
bronku 2025-11-25 16:24:09 +01:00
parent 0bc67209b9
commit 38438904dc
2 changed files with 37 additions and 31 deletions

View file

@ -10,10 +10,10 @@
%}
%%
^[ \t]*\r?\n { /* Ignore lines containing whitespace only */ }
^[ \t]*#.*\n { /* Ignore comment-only lines */ }
^[ \t]*\r?\n { /* Ignore lines containing whitespace only */ }
^[ \t]*#.*\n { /* Ignore comment-only lines */ }
^[ \t]* {
^[ \t]+ {
int col = indent_stack.calculateColumn(yytext, yyleng);
auto action = indent_stack.updateIndentation(col);
@ -22,28 +22,27 @@
}
\n { return yy::parser::token::TOK_NEWLINE; }
\n { return yy::parser::token::TOK_NEWLINE; }
def { return yy::parser::token::TOK_KW_DEF; }
if { return yy::parser::token::TOK_KW_IF; }
return { return yy::parser::token::TOK_KW_RETURN; }
for { return yy::parser::token::TOK_KW_FOR; }
in { return yy::parser::token::TOK_KW_IN; }
def { return yy::parser::token::TOK_KW_DEF; }
if { return yy::parser::token::TOK_KW_IF; }
return { return yy::parser::token::TOK_KW_RETURN; }
for { return yy::parser::token::TOK_KW_FOR; }
in { return yy::parser::token::TOK_KW_IN; }
\( { return yy::parser::token::TOK_L_PAREN; }
\) { return yy::parser::token::TOK_R_PAREN; }
\: { return yy::parser::token::TOK_COLON; }
\= { return yy::parser::token::TOK_ASSIGN; }
\+ { return yy::parser::token::TOK_PLUS; }
\- { return yy::parser::token::TOK_MINUS; }
\( { return yy::parser::token::TOK_L_PAREN; }
\) { return yy::parser::token::TOK_R_PAREN; }
\: { return yy::parser::token::TOK_COLON; }
\= { return yy::parser::token::TOK_ASSIGN; }
\+ { return yy::parser::token::TOK_PLUS; }
\- { return yy::parser::token::TOK_MINUS; }
\" { yymore(); BEGIN(STRING); }
<STRING>\"\" { yymore(); }
<STRING>\" { BEGIN(INITIAL); yylval->as<std::string>() = yytext; return yy::parser::token::TOK_STRING; }
<STRING>. { yymore(); }
\" { yymore(); BEGIN(STRING); }
<STRING>\" { BEGIN(INITIAL); yylval->as<std::string>() = yytext; return yy::parser::token::TOK_STRING; }
<STRING>. { yymore(); }
[0-9]+ { yylval->as<std::string>() = yytext; return yy::parser::token::TOK_NUMBER; }
[0-9]+ { yylval->as<std::string>() = yytext; return yy::parser::token::TOK_NUMBER; }
[A-Za-z_][A-Za-z0-9_]* { yylval->as<std::string>() = yytext; return yy::parser::token::TOK_IDENTIFIER; }
<<EOF>> { return yy::parser::token::TOK_EOF; }
. { /* ignore other characters */ }
<<EOF>> { return yy::parser::token::TOK_EOF; }
. { }