55 lines
1.5 KiB
Plaintext
55 lines
1.5 KiB
Plaintext
%{
|
|
#include <tpr/tpr-scanner.hpp>
|
|
#include <string>
|
|
#undef YY_DECL
|
|
#define YY_DECL int tpr::TempProfileScanner::yylex(tpr::TempProfileParser::semantic_type * const lval, tpr::TempProfileParser::location_type *loc )
|
|
|
|
#define YY_USER_ACTION loc->step(); loc->columns(yyleng);
|
|
|
|
using token = tpr::TempProfileParser::token;
|
|
|
|
%}
|
|
|
|
%option yyclass="tpr::TempProfileScanner"
|
|
%option noyywrap
|
|
%option never-interactive
|
|
%option c++
|
|
|
|
/* Predefined rules */
|
|
NEWLINE "\n"|"\r\n"
|
|
COMMENT_LINE "#".*\n
|
|
SPACE "\t"|" "
|
|
|
|
NUM_INT [-+]?([0-9]+)
|
|
NUM_FLOAT [-+]?([0-9]*\.[0-9]+)
|
|
|
|
%%
|
|
%{
|
|
yylval = lval;
|
|
%}
|
|
|
|
<*>{SPACE} { /*Ignore spaces */}
|
|
{COMMENT_LINE} {loc->lines(); return token::lineend;}
|
|
{NEWLINE} {loc->lines(); return token::lineend;}
|
|
{NUM_FLOAT} {yylval->build<float>(std::stof(std::string(yytext))); return token::number_float;}
|
|
{NUM_INT} {yylval->build<float>(std::stof(std::string(yytext))); return token::number_int;}
|
|
|
|
pid_conf { return token::kw_pid_conf; }
|
|
temp_set { return token::kw_temp_set; }
|
|
wait_temp { return token::kw_wait_temp; }
|
|
wait_time { return token::kw_wait_time; }
|
|
temp_ramp { return token::kw_temp_ramp; }
|
|
beep { return token::kw_beep; }
|
|
temp_off { return token::kw_temp_off; }
|
|
clear_flags { return token::kw_clear_flags; }
|
|
digio_conf { return token::kw_digio_conf; }
|
|
digio_set { return token::kw_digio_set; }
|
|
digio_wait { return token::kw_digio_wait; }
|
|
|
|
. {
|
|
std::cerr << "[ERR] Failed to parse: " << yytext << " @ " << *loc << std::endl;
|
|
return token::unexpected_input;
|
|
}
|
|
|
|
%%
|