diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-05 11:04:47 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-05 11:04:47 +0200 |
commit | 6175ce90b59d742976aa5a8b2603902761e540ae (patch) | |
tree | 4a680c6f0cb3cc22007aac1907e9c74fd22deae3 /grammar | |
parent | 641e383b8ad13ad6ee7fd9241214e24e6a983500 (diff) | |
download | rsyslog-6175ce90b59d742976aa5a8b2603902761e540ae.tar.gz rsyslog-6175ce90b59d742976aa5a8b2603902761e540ae.tar.xz rsyslog-6175ce90b59d742976aa5a8b2603902761e540ae.zip |
milestone: improved build system
... still had quite some glitches, as usual. This time it hopefully
works under all circumstances (well, let's hope for "usual cir..." ;)).
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/Makefile.am | 13 | ||||
-rw-r--r-- | grammar/grammar.y (renamed from grammar/rscript.y) | 7 | ||||
-rw-r--r-- | grammar/lexer.l (renamed from grammar/rscript-lex.l) | 12 | ||||
-rw-r--r-- | grammar/testdriver.c | 50 | ||||
-rw-r--r-- | grammar/utils.c | 28 |
5 files changed, 79 insertions, 31 deletions
diff --git a/grammar/Makefile.am b/grammar/Makefile.am index b2bd3430..b482c99e 100644 --- a/grammar/Makefile.am +++ b/grammar/Makefile.am @@ -1,7 +1,16 @@ +BUILT_SOURCES = grammar.h +CLEANFILES = grammar.h grammar.c +AM_YFLAGS = -d noinst_LTLIBRARIES = libgrammar.la +bin_PROGRAMS = testdriver # TODO: make this conditional libgrammar_la_SOURCES = \ + grammar.y \ + lexer.l \ utils.c \ utils.h \ - rscript-lex.l \ - rscript.y + grammar.h + +testdriver_SOURCES = testdriver.c libgrammar.la +testdriver_LDADD = libgrammar.la +testdriver_LDFLAGS = -lestr diff --git a/grammar/rscript.y b/grammar/grammar.y index b24b7db7..76881fd1 100644 --- a/grammar/rscript.y +++ b/grammar/grammar.y @@ -19,6 +19,10 @@ #include "utils.h" #define YYDEBUG 1 extern int yylineno; + +/* keep compile rule cleam of errors */ +extern int yylex(void); +extern int yyerror(char*); %} %union { @@ -109,7 +113,7 @@ conf: /* empty (to end recursion) */ obj: BEGINOBJ nvlst ENDOBJ { $$ = cnfobjNew($1, $2); } | BEGIN_ACTION nvlst ENDOBJ { $$ = cnfobjNew(CNFOBJ_ACTION, $2); } -cfsysline: CFSYSLINE { $$ = $1 } +cfsysline: CFSYSLINE { $$ = $1; } nvlst: { $$ = NULL; } | nvlst nv { $2->next = $1; $$ = $2; } nv: NAME '=' VALUE { $$ = nvlstNew($1, $3); } @@ -161,4 +165,5 @@ fparams: expr { $$ = cnffparamlstNew($1, NULL); } int yyerror(char *s) { printf("parse failure on or before line %d: %s\n", yylineno, s); + return 0; } diff --git a/grammar/rscript-lex.l b/grammar/lexer.l index 1c7b963e..2411be6f 100644 --- a/grammar/rscript-lex.l +++ b/grammar/lexer.l @@ -42,9 +42,12 @@ */ %{ #include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <strings.h> #include <libestr.h> #include "utils.h" -#include "rscript.tab.h" +#include "grammar.h" static int preCommentState; /* save for lex state before a comment */ struct bufstack { @@ -58,6 +61,13 @@ char *currfn; /* name of currently processed file */ int popfile(void); int cnfSetLexFile(char *fname); + +/* somehow, I need these prototype even though the headers are + * included. I guess that's some autotools magic I don't understand... + */ +char *strdup(char*); +int fileno(FILE *stream); + %} %% diff --git a/grammar/testdriver.c b/grammar/testdriver.c new file mode 100644 index 00000000..e1623829 --- /dev/null +++ b/grammar/testdriver.c @@ -0,0 +1,50 @@ +/* This is a stand-alone test driver for grammar processing. We try to + * keep this separate as it simplyfies grammer development. + * + * Copyright 2011 by Rainer Gerhards and Adiscon GmbH. + * + * This file is part of the rsyslog runtime library. + * + * The rsyslog runtime library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The rsyslog runtime library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>. + * + * A copy of the GPL can be found in the file "COPYING" in this distribution. + * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution. + */ +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <libestr.h> +#include "parserif.h" + +void +cstrPrint(char *text, es_str_t *estr) +{ + char *str; + str = es_str2cstr(estr, NULL); + printf("%s%s", text, str); + free(str); +} + + +int +main(int argc, char *argv[]) +{ + int r; + + cnfSetLexFile(argc == 1 ? NULL : argv[1]); + yydebug = 0; + r = yyparse(); + printf("yyparse() returned %d\n", r); + return r; +} diff --git a/grammar/utils.c b/grammar/utils.c index e488ebda..d9bf67aa 100644 --- a/grammar/utils.c +++ b/grammar/utils.c @@ -5,7 +5,7 @@ #include <libestr.h> #include "utils.h" #include "parserif.h" -#include "rscript.tab.h" +#include "grammar.h" void readConfFile(FILE *fp, es_str_t **str) @@ -609,29 +609,3 @@ cnffuncNew(es_str_t *fname, struct cnffparamlst* paramlst) } return func; } - -/* debug helper */ -#ifdef STAND_ALONE -void -cstrPrint(char *text, es_str_t *estr) -{ - char *str; - str = es_str2cstr(estr, NULL); - printf("%s%s", text, str); - free(str); -} - - -int -main(int argc, char *argv[]) -{ - int r; - - cnfSetLexFile(argc == 1 ? NULL : argv[1]); - yydebug = 0; - r = yyparse(); - printf("yyparse() returned %d\n", r); - return r; -} -#endif /* #ifdef STAND_ALONE */ - |