115 lines
2.2 KiB
Plaintext
115 lines
2.2 KiB
Plaintext
|
|
%language "c++"
|
|
%require "3.2"
|
|
%defines
|
|
%define api.namespace {tpr}
|
|
%define api.parser.class {TempProfileParser}
|
|
|
|
|
|
%define parse.error verbose
|
|
|
|
%code requires{
|
|
namespace tpr {
|
|
class TempProfileScanner;
|
|
}
|
|
}
|
|
|
|
%parse-param { TempProfileScanner &scanner }
|
|
|
|
%code {
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
#include <fstream>
|
|
#include <utility>
|
|
#include <tuple>
|
|
#include <tpr/tpr-scanner.hpp>
|
|
#include <tpr/tpr-types.hpp>
|
|
#undef yylex
|
|
#define yylex scanner.yylex
|
|
}
|
|
|
|
%define api.value.type variant
|
|
%locations
|
|
%start tpr_file
|
|
|
|
%token<float> number_float
|
|
%token<float> number_int
|
|
%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
|
|
%token unexpected_input
|
|
|
|
%type<float>number number_truncated
|
|
|
|
%%
|
|
|
|
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 {std::cout << "Set Temperature" << $2 << std::endl;}
|
|
;
|
|
|
|
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_truncated;
|
|
|
|
cmd_temp_off: kw_temp_off;
|
|
|
|
cmd_clear_flags: kw_clear_flags;
|
|
|
|
cmd_digio_conf: kw_digio_conf number_truncated number_truncated;
|
|
|
|
cmd_digio_set: kw_digio_set number_truncated number_truncated;
|
|
|
|
cmd_digio_wait: kw_digio_wait number_truncated number_truncated;
|
|
|
|
number_truncated: number_float {$$ = $1; std::cerr << "[WARN] Floating point number " << $1 << " will be truncated to an integer (" << (int)$1 << ") at location (" << @1 << ")" << std::endl;}
|
|
| number_int {$$ = $1;}
|
|
;
|
|
|
|
number: number_float {$$ = $1;}
|
|
| number_int {$$ = $1;}
|
|
;
|
|
|
|
%%
|
|
|
|
void tpr::TempProfileParser::error(const location_type &l, const std::string &err_message)
|
|
{
|
|
std::cerr << "[ERR] Parser Error: '" << err_message << "' at " << l << std::endl;
|
|
std::abort();
|
|
} |