diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-03 11:22:26 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-03 11:22:26 +0200 |
commit | ead2f1961fc653861a151a033c3cd0657c50af16 (patch) | |
tree | cc28f63f2fd690bd9287c7793cda1b604560e912 /cmake/elfinfo/Makefile.grammar | |
parent | 4b0939539fb99ee8a399d8a59d295ff94c1eeebc (diff) | |
download | intel-quark-d2000-playground-ead2f1961fc653861a151a033c3cd0657c50af16.tar.gz intel-quark-d2000-playground-ead2f1961fc653861a151a033c3cd0657c50af16.tar.bz2 intel-quark-d2000-playground-ead2f1961fc653861a151a033c3cd0657c50af16.tar.xz intel-quark-d2000-playground-ead2f1961fc653861a151a033c3cd0657c50af16.zip |
LD file Antlr4 grammar. Generates a lexer and parser for Java.
Diffstat (limited to 'cmake/elfinfo/Makefile.grammar')
-rw-r--r-- | cmake/elfinfo/Makefile.grammar | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/cmake/elfinfo/Makefile.grammar b/cmake/elfinfo/Makefile.grammar new file mode 100644 index 0000000..13eb13d --- /dev/null +++ b/cmake/elfinfo/Makefile.grammar @@ -0,0 +1,53 @@ +GRAMMAR=GnuLd.g4 +G4_PACKAGE ?= io.trygvis.ld.antlr +PACKAGE_PATH = $(subst .,/,$(G4_PACKAGE)) + +G4_JAVA=\ + $(patsubst %.g4,antlr/$(PACKAGE_PATH)/%Lexer.java,$(GRAMMAR)) + +# $(patsubst %.g4,antlr/$(PACKAGE_PATH)/%Parser.java,$(GRAMMAR)) \ +# $(patsubst %.g4,antlr/$(PACKAGE_PATH)/%Listener.java,$(GRAMMAR)) \ +# $(patsubst %.g4,antlr/$(PACKAGE_PATH)/%BaseListener.java,$(GRAMMAR)) + +G4_CLASSES=$(patsubst antlr/%.java,target/classes/%.class,$(G4_JAVA)) + +ANTLR_URL=http://repo1.maven.org/maven2/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar +ANTLR_RUNTIME_URL=http://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.jar +ANTLR_JAR=$(notdir $(ANTLR_URL)) +ANTLR_RUNTIME_JAR=$(notdir $(ANTLR_RUNTIME_URL)) + +all: meta-java + +meta-java: $(G4_JAVA) + +meta-classes: $(G4_CLASSES) + +info: + @echo "ANTLR_JAR $(ANTLR_JAR)" + @echo "GRAMMAR $(GRAMMAR)" + @echo "G4_JAVA $(G4_JAVA)" + @echo "G4_CLASSES $(G4_CLASSES)" + +target/classes antlr: + mkdir -p $@ + +download: $(ANTLR_JAR) $(ANTLR_RUNTIME_JAR) + +$(ANTLR_JAR): + wget $(ANTLR_URL) + +$(ANTLR_RUNTIME_JAR): + wget $(ANTLR_RUNTIME_URL) + +$(G4_JAVA): $(GRAMMAR) | antlr $(ANTLR_JAR) + java -cp $(ANTLR_JAR) org.antlr.v4.Tool \ + -visitor \ + -o antlr/$(PACKAGE_PATH) \ + $(patsubst %,-package %,$(G4_PACKAGE)) \ + $< + +$(G4_CLASSES): $(G4_JAVA) | target/classes + javac -d target/classes -cp $(ANTLR_JAR) $(wildcard antlr/$(PACKAGE_PATH)/*.java) + +clean: + rm -rf target/classes antlr |