2024-01-17 20:28:40 +01:00
|
|
|
%{
|
|
|
|
#include <tpr/tpr-scanner.hpp>
|
2024-01-17 22:43:30 +01:00
|
|
|
#include <string>
|
2024-01-17 20:28:40 +01:00
|
|
|
#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);
|
|
|
|
|
2024-01-17 22:43:30 +01:00
|
|
|
using token = tpr::TempProfileParser::token;
|
|
|
|
|
2024-01-17 20:28:40 +01:00
|
|
|
%}
|
|
|
|
|
2024-01-17 22:43:30 +01:00
|
|
|
%option yyclass="tpr::TempProfileScanner"
|
2024-01-17 20:28:40 +01:00
|
|
|
%option noyywrap
|
|
|
|
%option never-interactive
|
|
|
|
%option c++
|
|
|
|
|
|
|
|
/* Predefined rules */
|
|
|
|
NEWLINE "\n"|"\r\n"
|
2024-01-17 22:43:30 +01:00
|
|
|
COMMENT_LINE "#".*\n
|
|
|
|
SPACE "\t"|" "
|
|
|
|
NUM [-+]?([0-9]*\.[0-9]+|[0-9]+)
|
2024-01-17 20:28:40 +01:00
|
|
|
|
|
|
|
%%
|
2024-01-18 23:27:06 +01:00
|
|
|
%{
|
|
|
|
yylval = lval;
|
|
|
|
%}
|
2024-01-17 20:28:40 +01:00
|
|
|
|
2024-01-17 22:43:30 +01:00
|
|
|
<*>{SPACE} { /*Ignore spaces */}
|
|
|
|
{COMMENT_LINE} {loc->lines(); return token::lineend;}
|
|
|
|
{NEWLINE} {loc->lines(); return token::lineend;}
|
|
|
|
{NUM} {yylval->build<float>(std::stof(std::string(yytext))); return token::number;}
|
|
|
|
|
|
|
|
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; }
|
2024-01-17 20:28:40 +01:00
|
|
|
|
2024-01-18 23:27:06 +01:00
|
|
|
. {
|
|
|
|
std::cerr << "[ERR] Failed to parse: " << yytext << " @ " << *loc << std::endl;
|
|
|
|
return token::unexpected_input;
|
|
|
|
}
|
|
|
|
|
2024-01-17 20:28:40 +01:00
|
|
|
%%
|