summaryrefslogtreecommitdiffstats
path: root/mmss/config.y
diff options
context:
space:
mode:
Diffstat (limited to 'mmss/config.y')
-rw-r--r--mmss/config.y51
1 files changed, 49 insertions, 2 deletions
diff --git a/mmss/config.y b/mmss/config.y
index 6eade61..09eff91 100644
--- a/mmss/config.y
+++ b/mmss/config.y
@@ -41,6 +41,7 @@
%union {
int num;
+ float fnum;
bool boolean;
char *str;
gmrf_addr_t addr;
@@ -49,6 +50,7 @@
}
%token <num> TOK_INTEGER
+%token <fnum> TOK_FLOAT
%token <str> TOK_STRING
%token <addr> TOK_GMRF_ADDRESS
@@ -61,6 +63,18 @@
%token TOK_DEFAULT
%token TOK_INTERFACE
%token TOK_ADDRESS
+%token TOK_ETX
+%token TOK_CONST
+%token TOK_MIN
+%token TOK_MAX
+%token TOK_SINE
+%token TOK_PERIOD
+%token TOK_PHASE
+
+%token TOK_S
+%token TOK_M
+%token TOK_H
+%token TOK_DAYS
%code {
@@ -71,6 +85,8 @@
%type <boolean> boolean
%type <boolean> maybe_default
%type <str> maybe_protocol
+%type <num> time
+%type <fnum> float
%%
@@ -92,7 +108,27 @@ network: TOK_STRING {
}
;
-network_config:
+network_config: network_config network_statement
+ |
+ ;
+
+network_statement:
+ TOK_ETX network_etx ';'
+ ;
+
+network_etx:
+ TOK_CONST float {
+ if (!conf->set_packet_loss($2))
+ YYERROR;
+ }
+ | TOK_MIN float TOK_MAX float TOK_SINE TOK_PERIOD time {
+ if (!conf->set_packet_loss($2, $4, $7, 0))
+ YYERROR;
+ }
+ | TOK_MIN float TOK_MAX float TOK_SINE TOK_PERIOD time TOK_PHASE time {
+ if (!conf->set_packet_loss($2, $4, $7, $9))
+ YYERROR;
+ }
;
protocol: TOK_STRING TOK_LOAD TOK_STRING maybe_default {
@@ -120,6 +156,10 @@ node_interface: TOK_STRING TOK_NETWORK TOK_STRING TOK_ADDRESS TOK_GMRF_ADDRESS {
}
;
+float: TOK_FLOAT { $$ = $1; }
+ | TOK_INTEGER { $$ = $1; }
+ ;
+
boolean: TOK_YES { $$ = true; }
| TOK_NO { $$ = false; }
;
@@ -128,10 +168,17 @@ maybe_default: TOK_DEFAULT { $$ = true; }
| { $$ = false; }
;
-maybe_protocol: TOK_PROTOCOL TOK_STRING { $$ = $2; }
+maybe_protocol: TOK_PROTOCOL TOK_STRING { $$ = $2; }
| { $$ = nullptr; }
;
+time: TOK_INTEGER TOK_DAYS { $$ = $1*86400; }
+ | TOK_INTEGER TOK_H { $$ = $1*3600; }
+ | TOK_INTEGER TOK_M { $$ = $1*60; }
+ | TOK_INTEGER TOK_S { $$ = $1; }
+ | TOK_INTEGER { $$ = $1; }
+ ;
+
%%
void mmss_config_error(YYLTYPE *loc, const std::shared_ptr<config_t> &conf, const char *filename, const char *s) {