diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-25 14:21:47 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-25 14:21:47 +0200 |
commit | 59a5b833216b62f28c816df7c9129bf0954993e0 (patch) | |
tree | 64c35f8ddcc8eafa9e12663b8eb12ba836ea1886 /src/config.c | |
parent | 6ce20e2bb6660694e995d890f2846fc26c96c8f7 (diff) | |
download | fastd-59a5b833216b62f28c816df7c9129bf0954993e0.tar fastd-59a5b833216b62f28c816df7c9129bf0954993e0.zip |
Change parse to push API, fix some parser bugs
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c index 12b92b3..d584264 100644 --- a/src/config.c +++ b/src/config.c @@ -90,6 +90,10 @@ static bool config_match(const char *opt, ...) { static void fastd_read_config(fastd_context *ctx, fastd_config *conf, const char *filename) { yyscan_t scanner; + fastd_config_pstate *ps; + int token; + YYSTYPE token_val; + FILE *file; bool use_stdin = !strcmp(filename, "-"); @@ -98,12 +102,20 @@ static void fastd_read_config(fastd_context *ctx, fastd_config *conf, const char else file = fopen(filename, "r"); - fastd_config_lex_init(&scanner); - fastd_config_set_in(file, scanner); + fastd_config_yylex_init(&scanner); + fastd_config_yyset_in(file, scanner); + + ps = fastd_config_pstate_new(); + + do { + token = fastd_config_yylex(&token_val, scanner); - fastd_config_parse(ctx, conf, scanner); + if (token < 0) + exit_error(ctx, "config error: %s", token_val.str); + } while(fastd_config_push_parse(ps, token, &token_val, ctx, conf) == YYPUSH_MORE); - fastd_config_lex_destroy(scanner); + fastd_config_pstate_delete(ps); + fastd_config_yylex_destroy(scanner); if (!use_stdin) fclose(file); |