diff --git a/temp-profile-checker/include/tpr/tpr-scanner.hpp b/temp-profile-checker/include/tpr/tpr-scanner.hpp index 74a7446..88e7a0b 100644 --- a/temp-profile-checker/include/tpr/tpr-scanner.hpp +++ b/temp-profile-checker/include/tpr/tpr-scanner.hpp @@ -23,7 +23,7 @@ class TempProfileScanner : public yyFlexLexer{ virtual int yylex( tpr::TempProfileParser::semantic_type * const lval, - tpr::TempProfileParser::location_type *location ); + tpr::TempProfileParser::location_type *loc ); // YY_DECL defined in mc_lexer.l // Method body created by flex in mc_lexer.yy.cc diff --git a/temp-profile-checker/parser/tpr.l b/temp-profile-checker/parser/tpr.l index b4dd9dc..d3ccb6b 100644 --- a/temp-profile-checker/parser/tpr.l +++ b/temp-profile-checker/parser/tpr.l @@ -1,26 +1,43 @@ %{ #include +#include #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::TempProgileScanner" +%option yyclass="tpr::TempProfileScanner" %option noyywrap %option never-interactive %option c++ /* Predefined rules */ NEWLINE "\n"|"\r\n" -SPACE " "|"\t"|"\f" -COMMENT_BEGIN "/*" -COMMENT_END "*/" -COMMENT_LINE "//".*\n +COMMENT_LINE "#".*\n +SPACE "\t"|" " +NUM [-+]?([0-9]*\.[0-9]+|[0-9]+) %% -SPACE {return 0;} +<*>{SPACE} { /*Ignore spaces */} +{COMMENT_LINE} {loc->lines(); return token::lineend;} +{NEWLINE} {loc->lines(); return token::lineend;} +{NUM} {yylval->build(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; } %% diff --git a/temp-profile-checker/parser/tpr.ypp b/temp-profile-checker/parser/tpr.ypp index 7406de6..1cec5ee 100644 --- a/temp-profile-checker/parser/tpr.ypp +++ b/temp-profile-checker/parser/tpr.ypp @@ -30,15 +30,67 @@ %locations %start tpr_file -%token foo +%token number +%token lineend +%token kw_pid_conf +%token kw_temp_set +%token kw_wait_temp +%token kw_wait_time +%token kw_temp_ramp +%token kw_beep +%token kw_temp_off +%token kw_clear_flags +%token kw_digio_conf +%token kw_digio_set +%token kw_digio_wait %% -tpr_file: foo - | tpr_file foo +tpr_file: tpr_command + | tpr_file tpr_command ; +tpr_command: tpr_command_inner lineend + | lineend + ; + +tpr_command_inner: cmd_pid_conf; + | cmd_temp_set + | cmd_wait_temp + | cmd_wait_time + | cmd_temp_ramp + | cmd_beep + | cmd_temp_off + | cmd_clear_flags + | cmd_digio_conf + | cmd_digio_set + | cmd_digio_wait + ; + + +cmd_pid_conf: kw_pid_conf number number number number number number; + +cmd_temp_set: kw_temp_set number; + +cmd_wait_temp: kw_wait_temp number; + +cmd_wait_time: kw_wait_time number; + +cmd_temp_ramp: kw_temp_ramp number number; + +cmd_beep: kw_beep number; + +cmd_temp_off: kw_temp_off; + +cmd_clear_flags: kw_clear_flags; + +cmd_digio_conf: kw_digio_conf number number; + +cmd_digio_set: kw_digio_set number number; + +cmd_digio_wait: kw_digio_wait number number; + %% void tpr::TempProfileParser::error(const location_type &l, const std::string &err_message)