Skip to content

Commit

Permalink
Add ANTLR4 grammar and C++ parser
Browse files Browse the repository at this point in the history
Signed-off-by: Dusty DeWeese <dustin.deweese@gmail.com>
  • Loading branch information
HackerFoo committed Dec 3, 2020
1 parent 4857dde commit 23f530e
Show file tree
Hide file tree
Showing 7 changed files with 727 additions and 107 deletions.
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,50 @@
#
# SPDX-License-Identifier: ISC

CXXFLAGS += -Wno-attributes -O3
LDFLAGS += -lantlr4-runtime

.PHONY: all
all: parse_fasm fasm/parse_fasm.so

PYTHON_FORMAT ?= yapf
format:
$(IN_ENV) find . -name \*.py $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) yapf -p -i

check-license:
@./.github/check_license.sh
@./.github/check_python_scripts.sh


parse_fasm: cpp/ParseFasm.o cpp/FasmParser.o cpp/FasmLexer.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@

fasm/parse_fasm.so: cpp/ParseFasm.o cpp/FasmParser.o cpp/FasmLexer.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -fPIC -shared -o $@

cpp/ParseFasm.o: cpp/FasmLexer.h cpp/FasmParser.h

cpp/FasmParser.cpp \
cpp/FasmParser.h \
cpp/FasmParser.interp \
cpp/FasmParser.tokens \
cpp/FasmParserBaseListener.cpp \
cpp/FasmParserBaseListener.h \
cpp/FasmParserBaseVisitor.cpp \
cpp/FasmParserBaseVisitor.h \
cpp/FasmParserListener.cpp \
cpp/FasmParserListener.h \
cpp/FasmParserVisitor.cpp \
cpp/FasmParserVisitor.h : fasm/FasmParser.g4 cpp/FasmLexer.tokens
antlr -Dlanguage=Cpp -visitor -Xexact-output-dir -o cpp $<

cpp/FasmLexer.cpp \
cpp/FasmLexer.h \
cpp/FasmLexer.interp \
cpp/FasmLexer.tokens : fasm/FasmLexer.g4
antlr -Dlanguage=Cpp -Xexact-output-dir -o cpp $<

.PHONY: clean
clean:
rm -f cpp/FasmLexer* cpp/FasmParser* cpp/*.o parse_fasm fasm/parse_fasm.so

0 comments on commit 23f530e

Please sign in to comment.