Parse variable declarations

This commit is contained in:
2024-12-21 14:05:27 +01:00
parent 72681e349a
commit f080b75c52
15 changed files with 1151 additions and 62 deletions

View File

@@ -6,12 +6,12 @@
#include "parser.hpp"
#undef YY_DECL
#define YY_DECL yy::parser::symbol_type elna::syntax::FooLexer::lex()
#define YY_DECL yy::parser::symbol_type elna::source::lexer::lex()
#define yyterminate() return yy::parser::make_YYEOF(this->location)
%}
%option c++ noyywrap never-interactive
%option yyclass="elna::syntax::FooLexer"
%option yyclass="elna::source::lexer"
%%
%{
@@ -53,10 +53,10 @@ const {
var {
return yy::parser::make_VAR(this->location);
}
True {
true {
return yy::parser::make_BOOLEAN(true, this->location);
}
False {
false {
return yy::parser::make_BOOLEAN(false, this->location);
}
[A-Za-z_][A-Za-z0-9_]* {
@@ -125,7 +125,7 @@ False {
. {
std::stringstream ss;
ss << "Illegal character 0x" << std::hex << static_cast<unsigned char>(yytext[0]);
ss << "Illegal character 0x" << std::hex << static_cast<unsigned int>(yytext[0]);
throw yy::parser::syntax_error(this->location, ss.str());
}
%%