chore: noisy lexer
This commit is contained in:
parent
a9f8ef6eef
commit
ae30e35334
84
DragonLisp.l
84
DragonLisp.l
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue