summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.l21
-rw-r--r--src/config.y5
2 files changed, 15 insertions, 11 deletions
diff --git a/src/config.l b/src/config.l
index f18dca7..5e5e666 100644
--- a/src/config.l
+++ b/src/config.l
@@ -4,11 +4,7 @@
%option reentrant
%top {
- #define YY_DECL int fastd_config_lex(YYSTYPE *yylval_param, fastd_context *ctx, void *yyscanner)
-
- #include <fastd.h>
#include <config.yy.h>
- YY_DECL;
}
%x STRING
@@ -26,8 +22,10 @@ peer { yylval->str = yytext; return TOK_PEER; }
address { yylval->str = yytext; return TOK_ADDRESS; }
[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} {
- if (!inet_pton(AF_INET, yytext, &yylval->addr))
- exit_error(ctx, "config error: invalid address");
+ if (!inet_pton(AF_INET, yytext, &yylval->addr)) {
+ yylval->str = "invalid address";
+ return TOK_ERROR;
+ }
return TOK_ADDR;
}
@@ -48,12 +46,17 @@ tun { yylval->str = yytext; return TOK_TUN; }
\[ BEGIN(ADDR6);
<ADDR6>[^\]]+ {
- if (!inet_pton(AF_INET6, yytext, &yylval->addr6))
- exit_error(ctx, "config error: invalid address");
+ if (!inet_pton(AF_INET6, yytext, &yylval->addr6)) {
+ yylval->str = "invalid address";
+ return TOK_ERROR;
+ }
return TOK_ADDR6;
}
<ADDR6>\] BEGIN(INITIAL);
-<INITIAL,STRING,ADDR6>. exit_error(ctx, "config error: invalid character");
+<INITIAL,STRING,ADDR6>. {
+ yylval->str = "invalid character";
+ return TOK_ERROR;
+ }
%%
diff --git a/src/config.y b/src/config.y
index c81b370..9a0d333 100644
--- a/src/config.y
+++ b/src/config.y
@@ -1,6 +1,5 @@
%define api.pure
%name-prefix "fastd_config_"
-%lex-param {fastd_context *ctx}
%lex-param {yyscan_t scanner}
%parse-param {fastd_context *ctx}
%parse-param {fastd_config *conf}
@@ -17,6 +16,8 @@
struct in6_addr addr6;
}
+%token <str> TOK_ERROR;
+
%token <num> TOK_INTEGER
%token <str> TOK_STRING
%token <str> TOK_IDENTIFIER
@@ -52,7 +53,7 @@
}
%code provides {
- #include <fastd.h>
+ #include <fastd.h>
int fastd_config_parse (fastd_context *ctx, fastd_config *conf, void *scanner);
}