Skip to content

Commit 89c32e6

Browse files
Do not require a generator when building the C++ decoder only (#374)
Decoder in C++ only requires a reference to the serializer and the type of treeformat to be used. It doesn't need any information about the generator, model, listener, or transformer used for generating the tree to be decoded. The patch eliminates such artificial requirements from the build system and config.
1 parent 98232fe commit 89c32e6

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

grammarinator-cxx/config/grammarinator/config.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#define GRAMMARINATOR_VERSION "0.0 (unknown)"
1010
#endif
1111

12-
#ifndef GRAMMARINATOR_GENERATOR
13-
#error "GRAMMARINATOR_GENERATOR must be defined"
14-
#endif
15-
1612
#ifndef GRAMMARINATOR_MODEL
1713
#define GRAMMARINATOR_MODEL grammarinator::runtime::DefaultModel
1814
#endif
@@ -34,9 +30,14 @@
3430
#endif
3531

3632
#ifndef GRAMMARINATOR_INCLUDE
33+
#ifdef GRAMMARINATOR_GENERATOR
3734
#define GRAMMARINATOR_INCLUDE GRAMMARINATOR_GENERATOR.hpp
3835
#endif
36+
#endif
3937

4038
#define GRAMMARINATOR_STRFY_INTERNAL(MACRO) #MACRO
4139
#define GRAMMARINATOR_STRFY(MACRO) GRAMMARINATOR_STRFY_INTERNAL(MACRO)
40+
41+
#ifdef GRAMMARINATOR_INCLUDE
4242
#include GRAMMARINATOR_STRFY(GRAMMARINATOR_INCLUDE)
43+
#endif

grammarinator-cxx/dev/build.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ def build_options_append(cmakeopt, cliarg):
3131
build_options_append('GRAMMARINATOR_DECODE', 'ON' if args.decode else 'OFF')
3232
build_options_append('GRAMMARINATOR_FUZZNULL', 'ON' if args.fuzznull else 'OFF')
3333
build_options_append('GRAMMARINATOR_GRLF', 'ON' if args.grlf else 'OFF')
34-
if args.generate or args.decode or args.fuzznull or args.grlf:
34+
35+
if args.generate or args.fuzznull or args.grlf:
3536
build_options_append('GRAMMARINATOR_GENERATOR', args.generator)
3637
build_options_append('GRAMMARINATOR_MODEL', args.model)
3738
build_options_append('GRAMMARINATOR_LISTENER', args.listener)
3839
build_options_append('GRAMMARINATOR_TRANSFORMER', args.transformer)
40+
41+
if args.generate or args.decode or args.fuzznull or args.grlf:
3942
build_options_append('GRAMMARINATOR_SERIALIZER', args.serializer)
4043
build_options_append('GRAMMARINATOR_TREECODEC', args.treecodec)
4144
build_options_append('GRAMMARINATOR_INCLUDE', args.include)
4245
build_options_append('GRAMMARINATOR_INCLUDEDIRS', ';'.join(os.path.abspath(includedir) for includedir in args.includedir))
4346
build_options_append('GRAMMARINATOR_SUFFIX', args.suffix)
4447
build_options_append('GRAMMARINATOR_LOG_LEVEL', args.log_level)
48+
4549
return build_options
4650

4751

grammarinator-cxx/libgrlf/grlf.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
#include "grammarinator/config.hpp"
2222

23+
#ifndef GRAMMARINATOR_GENERATOR
24+
#error "GRAMMARINATOR_GENERATOR must be defined"
25+
#endif
26+
2327
namespace {
2428

2529
struct {

grammarinator-cxx/tools/generate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
#include "grammarinator/config.hpp"
2222

23+
#ifndef GRAMMARINATOR_GENERATOR
24+
#error "GRAMMARINATOR_GENERATOR must be defined"
25+
#endif
26+
2327
using namespace grammarinator::runtime;
2428
using namespace grammarinator::tool;
2529
using namespace grammarinator::util;

0 commit comments

Comments
 (0)