grammar.py and friends: Implement config file support

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-11-02 08:54:39 +01:00
commit 1a7a34f73c
6 changed files with 100 additions and 27 deletions

View file

@ -4,6 +4,7 @@ EXE_ARGS ?= grammartest.code
PREREQ_BUILD += ytools
FB_NAME = grammartest
NAMESPACE_IN_GENERATED = gt
GENERATE_CONFIG_FILE = generate.conf
include $(TOPDIR)/make/proj.mk
include $(TOPDIR)/make/generate-flex-bison.mk

View file

@ -0,0 +1,9 @@
[symbols]
[white_space[
regex = "[ \n\t\r]+"
]
[test[
dings = bums
regex = "bumsdings"
]

View file

@ -7,6 +7,7 @@
struct context {
int line;
int column;
};
union YYSTYPE;

View file

@ -12,6 +12,8 @@
#include "include/defs.h"
#include "include/grammartest.tab.h"
extern int FB_SYM(debug);
using namespace std;
int main(int argc, const char *argv[])
@ -28,10 +30,14 @@ int main(int argc, const char *argv[])
return 1;
}
// TODO: Initialize this in a generated function
struct context context = {
line: 0
line: 1,
column: 0
};
FB_SYM(debug) = 1;
struct vp_scanner *scanner = FB_SYM(init_scanner)(content.c_str());
int status = FB_SYM(parse)(&context, FB_SYM(scanner_get_data)(scanner));
FB_SYM(cleanup_scanner)(scanner);