Commit 634daf2a authored by Vladimír Štill's avatar Vladimír Štill
Browse files

make: Improve grammar generation

parent d330782a
PWD != pwd
PY = $(wildcard *.py)
GRMS=DFA NFA CFG RegG RegEx
GRMS=DFA NFA CFG SET RegG
ANTLR_VERSION != antlr4 | grep Version | sed -E 's/.*Version ([0-9]+[.][0-9]+.[0-9]+).*/\1/'
-include local.make
......@@ -24,9 +26,22 @@ $(GRMS:%=lib/parser/%Parser.py) : lib/parser/%Parser.py : lib/parser/%.g4
@# let's be a bit more permissive for versions
sed -i '/self.checkVersion(".*")/d' $(@:%Parser.py=%*.py)
$(GRMS:%=build/js/%Parser.js) : build/js/%Parser.js : lib/parser/%.g4
mkdir -p $(dir $@)
@# note: the path must be absolute, otherwise antlr4 put files into lib/parser subdir
antlr4 -Dlanguage=JavaScript -o $(dir $@) $(PWD)/$<
runtime-js : build/js/runtime/antlr4/Parser.js
build/js/runtime/antlr4/Parser.js : build/js/antlr-javascript-runtime-$(ANTLR_VERSION).zip
(cd $(dir $@).. && unzip -o ../antlr-javascript-runtime-$(ANTLR_VERSION).zip)
touch $@
FA_PARSER=DFA NFA
$(FA_PARSER:%=lib/parser/%Parser.py) : lib/parser/FA.g4
$(FA_PARSER:%=build/js/%Parser.js) : lib/parser/FA.g4
lib/parser/RegG.g4 : lib/parser/CFG.g4
lib/parser/RegGParser.py : lib/parser/CFG.g4
build/js/RegGParser.js : lib/parser/CFG.g4
.PHONY: %.mypy typecheck test unit all grammars
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment