2013-03-18 01:03:43 +01:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%define api.pure
|
|
|
|
%define api.push-pull push
|
|
|
|
%name-prefix "mmss_config_"
|
|
|
|
%locations
|
2013-07-26 17:45:15 +02:00
|
|
|
%parse-param {MMSS::context_t *mmss}
|
|
|
|
%parse-param {MMSS::config_t *conf}
|
2013-07-26 14:22:18 +02:00
|
|
|
%parse-param {const char *filename}
|
2013-03-18 01:03:43 +01:00
|
|
|
|
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%code requires {
|
|
|
|
#include <mmss.hpp>
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
#include <cstdio>
|
2013-07-26 17:45:15 +02:00
|
|
|
#include <string>
|
2013-07-26 14:22:18 +02:00
|
|
|
}
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%union {
|
|
|
|
int num;
|
|
|
|
bool boolean;
|
2013-07-26 17:45:15 +02:00
|
|
|
char *str;
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
const char *error;
|
|
|
|
}
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%token <num> TOK_INTEGER
|
|
|
|
%token <str> TOK_STRING
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%token TOK_NETWORK
|
|
|
|
%token TOK_YES
|
|
|
|
%token TOK_NO
|
2013-03-18 01:03:43 +01:00
|
|
|
|
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%code {
|
2013-07-26 17:45:15 +02:00
|
|
|
void mmss_config_error(YYLTYPE *loc, MMSS::context_t *mmss, MMSS::config_t *conf, const char *filename, const char *s);
|
2013-03-18 01:03:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%type <boolean> boolean
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%%
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
start: config
|
|
|
|
;
|
|
|
|
|
|
|
|
config: config statement
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
statement: TOK_NETWORK network '{' network_config '}'
|
|
|
|
;
|
|
|
|
|
|
|
|
network: TOK_STRING {
|
2013-07-26 17:45:15 +02:00
|
|
|
MMSS::Config::add_network(mmss, conf, $1);
|
2013-07-26 14:22:18 +02:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
network_config:
|
|
|
|
;
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
boolean: TOK_YES { $$ = true; }
|
|
|
|
| TOK_NO { $$ = false; }
|
|
|
|
;
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 14:22:18 +02:00
|
|
|
%%
|
2013-03-18 01:03:43 +01:00
|
|
|
|
2013-07-26 17:45:15 +02:00
|
|
|
void mmss_config_error(YYLTYPE *loc, MMSS::context_t *mmss, MMSS::config_t *conf, const char *filename, const char *s) {
|
|
|
|
MMSS::logf(mmss, LOG_ERR, "config error: %s at %s:%i:%i", s, filename, loc->first_line, loc->first_column);
|
2013-03-18 01:03:43 +01:00
|
|
|
}
|