chore: noisy lexer

This commit is contained in:
Eatswap 2022-12-10 13:54:48 +08:00
parent a9f8ef6eef
commit ae30e35334
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
1 changed files with 70 additions and 14 deletions

View File

@ -30,21 +30,76 @@ blank [ \t\v\r]
yylval = lval; yylval = lval;
%} %}
{blank}+ { loc->step(); } {blank}+ {
\n+ { loc->lines(yyleng); loc->step(); } loc->step();
std::printf("Skipping blank\n");
};
"<=" { return token::TOKEN_LE; } \n+ {
">=" { return token::TOKEN_GE; } loc->lines(yyleng);
"<" { return token::TOKEN_LT; } loc->step();
">" { return token::TOKEN_GT; } std::printf("Skipping newline\n");
"=" { return token::TOKEN_EQUAL; } }
"/=" { return token::TOKEN_NE; }
"(" { return token::TOKEN_LPAREN; } "<=" {
")" { return token::TOKEN_RPAREN; } std::printf("Scanned <=\n");
"+" { return token::TOKEN_PLUS; } return token::TOKEN_LE;
"-" { return token::TOKEN_MINUS; } };
"*" { return token::TOKEN_STAR; }
"/" { return token::TOKEN_SLASH; } ">=" {
std::printf("Scanned >=\n");
return token::TOKEN_GE;
};
"<" {
std::printf("Scanned <\n");
return token::TOKEN_LT;
};
">" {
std::printf("Scanned >\n");
return token::TOKEN_GT;
};
"=" {
std::printf("Scanned =\n");
return token::TOKEN_EQUAL;
};
"/=" {
std::printf("Scanned !=\n");
return token::TOKEN_NE;
};
"(" {
std::printf("Scanned (\n");
return token::TOKEN_LPAREN;
};
")" {
std::printf("Scanned )\n");
return token::TOKEN_RPAREN;
};
"+" {
std::printf("Scanned +\n");
return token::TOKEN_PLUS;
};
"-" {
std::printf("Scanned -\n");
return token::TOKEN_MINUS;
};
"*" {
std::printf("Scanned *\n");
return token::TOKEN_STAR;
};
"/" {
std::printf("Scanned /\n");
return token::TOKEN_SLASH;
};
{int} { {int} {
errno = 0; errno = 0;
@ -52,6 +107,7 @@ blank [ \t\v\r]
if (errno) if (errno)
throw DragonLisp::DLParser::syntax_error(*loc, "Invalid integer provided: " + std::string(yytext)); throw DragonLisp::DLParser::syntax_error(*loc, "Invalid integer provided: " + std::string(yytext));
yylval->emplace<int64_t>(n); yylval->emplace<int64_t>(n);
std::printf("Scanned integer: %lld\n", n);
return token::TOKEN_NUMBER; return token::TOKEN_NUMBER;
}; };