summaryrefslogtreecommitdiffstats
path: root/mmss/config.y
diff options
context:
space:
mode:
Diffstat (limited to 'mmss/config.y')
-rw-r--r--mmss/config.y50
1 files changed, 48 insertions, 2 deletions
diff --git a/mmss/config.y b/mmss/config.y
index 2b5fb72..6eade61 100644
--- a/mmss/config.y
+++ b/mmss/config.y
@@ -43,16 +43,24 @@
int num;
bool boolean;
char *str;
+ gmrf_addr_t addr;
const char *error;
}
%token <num> TOK_INTEGER
%token <str> TOK_STRING
+%token <addr> TOK_GMRF_ADDRESS
-%token TOK_NETWORK
%token TOK_YES
%token TOK_NO
+%token TOK_NETWORK
+%token TOK_PROTOCOL
+%token TOK_NODE
+%token TOK_LOAD
+%token TOK_DEFAULT
+%token TOK_INTERFACE
+%token TOK_ADDRESS
%code {
@@ -61,6 +69,8 @@
%type <boolean> boolean
+%type <boolean> maybe_default
+%type <str> maybe_protocol
%%
@@ -72,20 +82,56 @@ config: config statement
;
statement: TOK_NETWORK network '{' network_config '}'
+ | TOK_PROTOCOL protocol ';'
+ | TOK_NODE node '{' node_config '}'
;
network: TOK_STRING {
- conf->add_network($1);
+ if (!conf->add_network($1))
+ YYERROR;
}
;
network_config:
;
+protocol: TOK_STRING TOK_LOAD TOK_STRING maybe_default {
+ if (!conf->load_proto($1, $3, $4))
+ YYERROR;
+ }
+ ;
+
+node: TOK_STRING maybe_protocol {
+ if (!conf->add_node($1, $2))
+ YYERROR;
+ }
+ ;
+
+node_config: node_config node_statement
+ |
+ ;
+
+node_statement: TOK_INTERFACE node_interface ';'
+ ;
+
+node_interface: TOK_STRING TOK_NETWORK TOK_STRING TOK_ADDRESS TOK_GMRF_ADDRESS {
+ if (!conf->add_iface($1, $3, &$5))
+ YYERROR;
+ }
+ ;
+
boolean: TOK_YES { $$ = true; }
| TOK_NO { $$ = false; }
;
+maybe_default: TOK_DEFAULT { $$ = true; }
+ | { $$ = false; }
+ ;
+
+maybe_protocol: TOK_PROTOCOL TOK_STRING { $$ = $2; }
+ | { $$ = nullptr; }
+ ;
+
%%
void mmss_config_error(YYLTYPE *loc, const std::shared_ptr<config_t> &conf, const char *filename, const char *s) {