Skip to content

Commit

Permalink
Fixes incorrect column numbers.
Browse files Browse the repository at this point in the history
This was due to using JLex and not JFlex, which BNFC needed for
correct column numbers. Also removed cup jar from the project, now
both JFlex and cup are pulled from Maven.
  • Loading branch information
zafer-esen committed Nov 20, 2023
1 parent 92b8fa4 commit bd8cbb7
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 37 deletions.
61 changes: 42 additions & 19 deletions acsl-parser/Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,62 @@

PARSER_BASEDIR=$(shell pwd)
PARSER_BINDIR=$(PARSER_BASEDIR)/bin
PARSER_LIBDIR = $(PARSER_BASEDIR)/../cc-parser/lib

CUP = java_cup.Main
CUPFLAGS = -expect 7 -locations
CUP_JAR = $(PARSER_LIBDIR)/java-cup-11b.jar

JLEX = JLex.Main
JFLEX = jflex.Main
JFLEX_PLUGIN_JAR = $(PARSER_LIBDIR)/jflex-1.9.1.jar

LATEX = latex
DVIPS = dvips
DVIPDF = dvipdfm


PARSER_BASEDIR=$(shell pwd)
PARSER_BINDIR=$(PARSER_BASEDIR)/bin


JLEX_PATH:=/usr/share/java/JLex.jar
CLASSPATH:=$(CLASSPATH):$(PARSER_BASEDIR)/../cc-parser/lib/java-cup-11b.jar:$(PARSER_BASEDIR):$(JLEX_PATH)
CLASSPATH:=$(CLASSPATH):$(CUP_JAR):$(JFLEX_PLUGIN_JAR)
export CLASSPATH

JAVAC:=javac
JAVAC_FLAGS:=-target 1.8 -source 1.8

JAVA:=java
JAVA_FLAGS:=


export CLASSPATH


all: acsl-parser.jar tricera/acsl/Test.class

.PHONY: all
all: $(CUP_JAR) $(JFLEX_PLUGIN_JAR) acsl-parser.jar tricera/acsl/Test.class

$(PARSER_LIBDIR):
@mkdir -p $@

$(CUP_JAR): | $(PARSER_LIBDIR)
@echo "Looking for cup jar at $(CUP_JAR)"
@if [ ! -f $(CUP_JAR) ]; then \
echo "not found, downloading..."; \
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \
-DremoteRepositories=https://repo.maven.apache.org/maven2/ \
-Dartifact=com.github.vbmacher:java-cup:11b-20160615-2 \
-Dtransitive=false \
-Ddest=$(CUP_JAR); \
else \
echo "found, skipping download."; \
fi

$(JFLEX_PLUGIN_JAR): | $(PARSER_LIBDIR)
@echo "Looking for JFlex plugin jar at $(JFLEX_PLUGIN_JAR)"
@if [ ! -f $(JFLEX_PLUGIN_JAR) ]; then \
echo "not found, downloading..."; \
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \
-DremoteRepositories=https://repo.maven.apache.org/maven2/ \
-Dartifact=de.jflex:jflex:1.9.1 \
-Dtransitive=false \
-Ddest=$(JFLEX_PLUGIN_JAR); \
else \
echo "found, skipping download."; \
fi

acsl-parser.jar: $(PARSER_BINDIR) $(PARSER_BINDIR)/tricera/acsl/Absyn/acsl.class $(PARSER_BINDIR)/tricera/acsl/sym.class $(PARSER_BINDIR)/tricera/acsl/Yylex.class $(PARSER_BINDIR)/tricera/acsl/PrettyPrinterNonStatic.class $(PARSER_BINDIR)/tricera/acsl/parser.class
cd $(PARSER_BINDIR) && jar cf $(PARSER_BASEDIR)/acsl-parser.jar tricera


$(PARSER_BINDIR):
mkdir $(PARSER_BINDIR)

Expand All @@ -46,10 +69,10 @@ clean:

# just any of the files that is created by bnfc
acsl.tex: acsl.cf
bnfc -p tricera --java -l acsl.cf
bnfc -p tricera --java --jflex -l acsl.cf

$(PARSER_BINDIR)/tricera/acsl/Absyn/acsl.java: acsl.cf
bnfc -p tricera --java -l acsl.cf
bnfc -p tricera --java --jflex -l acsl.cf

$(PARSER_BINDIR)/tricera/acsl/Absyn/acsl.class: $(PARSER_BINDIR)/tricera/acsl/Absyn/acsl.java
${JAVAC} ${JAVAC_FLAGS} -d $(PARSER_BINDIR) tricera/acsl/Absyn/*.java
Expand All @@ -61,7 +84,7 @@ tricera/acsl/Yylex.java: tricera/acsl/Yylex
# quote dashes "-"
# sed 's/\\\+-/\\+\\-/g' <tricera/acsl/Yylex >tricera/acsl/Yylex.temp
# mv tricera/acsl/Yylex.temp tricera/acsl/Yylex
${JAVA} ${JAVA_FLAGS} ${JLEX} tricera/acsl/Yylex
${JAVA} ${JAVA_FLAGS} ${JFLEX} tricera/acsl/Yylex

tricera/acsl/sym.java tricera/acsl/parser.java: tricera/acsl/_cup.cup
${JAVA} ${JAVA_FLAGS} ${CUP} ${CUPFLAGS} tricera/acsl/_cup.cup
Expand Down
Binary file modified acsl-parser/acsl-parser.jar
Binary file not shown.
60 changes: 42 additions & 18 deletions cc-parser/Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,58 @@

PARSER_BASEDIR=$(shell pwd)
PARSER_BINDIR=$(PARSER_BASEDIR)/bin
PARSER_LIBDIR = $(PARSER_BASEDIR)/lib

CUP = java_cup.Main
CUPFLAGS = -expect 100 -locations
CUP_JAR = $(PARSER_LIBDIR)/java-cup-11b.jar

JLEX = JLex.Main
JFLEX = jflex.Main
JFLEX_PLUGIN_JAR = $(PARSER_LIBDIR)/jflex-1.9.1.jar

LATEX = latex
DVIPS = dvips
DVIPDF = dvipdfm


PARSER_BASEDIR=$(shell pwd)
PARSER_BINDIR=$(PARSER_BASEDIR)/bin


JLEX_PATH:=/usr/share/java/JLex.jar
CLASSPATH:=$(CLASSPATH):$(PARSER_BASEDIR)/lib/java-cup-11b.jar:$(PARSER_BASEDIR):$(JLEX_PATH)
CLASSPATH:=$(CLASSPATH):$(CUP_JAR):$(JFLEX_PLUGIN_JAR)
export CLASSPATH

JAVAC:=javac
JAVAC_FLAGS:=-target 1.8 -source 1.8

JAVA:=java
JAVA_FLAGS:=


export CLASSPATH


all: cc-parser.jar tricera/concurrency/concurrent_c/Test.class

.PHONY: all
all: $(CUP_JAR) $(JFLEX_PLUGIN_JAR) cc-parser.jar tricera/concurrency/concurrent_c/Test.class

$(PARSER_LIBDIR):
@mkdir -p $@

$(CUP_JAR): | $(PARSER_LIBDIR)
@echo "Looking for cup jar at $(CUP_JAR)"
@if [ ! -f $(CUP_JAR) ]; then \
echo "not found, downloading..."; \
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \
-DremoteRepositories=https://repo.maven.apache.org/maven2/ \
-Dartifact=com.github.vbmacher:java-cup:11b-20160615-2 \
-Dtransitive=false \
-Ddest=$(CUP_JAR); \
else \
echo "found, skipping download."; \
fi

$(JFLEX_PLUGIN_JAR): | $(PARSER_LIBDIR)
@echo "Looking for JFlex plugin jar at $(JFLEX_PLUGIN_JAR)"
@if [ ! -f $(JFLEX_PLUGIN_JAR) ]; then \
echo "not found, downloading..."; \
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \
-DremoteRepositories=https://repo.maven.apache.org/maven2/ \
-Dartifact=de.jflex:jflex:1.9.1 \
-Dtransitive=false \
-Ddest=$(JFLEX_PLUGIN_JAR); \
else \
echo "found, skipping download."; \
fi

cc-parser.jar: $(PARSER_BINDIR) $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Absyn/concurrent_c.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/sym.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Yylex.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/PrettyPrinterNonStatic.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/parser.class
cd $(PARSER_BINDIR) && jar cf $(PARSER_BASEDIR)/cc-parser.jar tricera
Expand All @@ -46,10 +70,10 @@ clean:

# just any of the files that is created by bnfc
concurrent_c.tex: concurrentC.cf
bnfc -p tricera.concurrency --java -l concurrentC.cf
bnfc -p tricera.concurrency --java --jflex -l concurrentC.cf

$(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Absyn/concurrent_c.java: concurrentC.cf
bnfc -p tricera.concurrency --java -l concurrentC.cf
bnfc -p tricera.concurrency --java --jflex -l concurrentC.cf

$(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Absyn/concurrent_c.class: $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Absyn/concurrent_c.java
${JAVAC} ${JAVAC_FLAGS} -d $(PARSER_BINDIR) tricera/concurrency/concurrent_c/Absyn/*.java
Expand All @@ -61,7 +85,7 @@ tricera/concurrency/concurrent_c/Yylex.java: tricera/concurrency/concurrent_c/Yy
# quote dashes "-"
# sed 's/\\\+-/\\+\\-/g' <tricera/concurrency/concurrent_c/Yylex >tricera/concurrency/concurrent_c/Yylex.temp
# mv tricera/concurrency/concurrent_c/Yylex.temp tricera/concurrency/concurrent_c/Yylex
${JAVA} ${JAVA_FLAGS} ${JLEX} tricera/concurrency/concurrent_c/Yylex
${JAVA} ${JAVA_FLAGS} ${JFLEX} tricera/concurrency/concurrent_c/Yylex

tricera/concurrency/concurrent_c/sym.java tricera/concurrency/concurrent_c/parser.java: tricera/concurrency/concurrent_c/_cup.cup
${JAVA} ${JAVA_FLAGS} ${CUP} ${CUPFLAGS} tricera/concurrency/concurrent_c/_cup.cup
Expand Down
Binary file modified cc-parser/cc-parser.jar
Binary file not shown.
Binary file removed cc-parser/lib/java-cup-11b.jar
Binary file not shown.

0 comments on commit bd8cbb7

Please sign in to comment.