mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
grammar.py and friends: Implement config file support
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
214c222002
commit
1a7a34f73c
6 changed files with 100 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
9
test/grammar/generate.conf
Normal file
9
test/grammar/generate.conf
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[symbols]
|
||||
[white_space[
|
||||
regex = "[ \n\t\r]+"
|
||||
]
|
||||
[test[
|
||||
dings = bums
|
||||
regex = "bumsdings"
|
||||
]
|
||||
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
struct context {
|
||||
int line;
|
||||
int column;
|
||||
};
|
||||
|
||||
union YYSTYPE;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue