Commit 51fe0bc9 authored by Johannes Mey's avatar Johannes Mey
Browse files

add a parameter --grammarName=<name> to set the name of the generated files...

add a parameter --grammarName=<name> to set the name of the generated files (without extension). Otherwise it is 'Grammar'
parent 8cb3b104
......@@ -19,6 +19,7 @@ public class Compiler {
private FlagOption optionWriteToFile;
private FlagOption optionPrintAST;
private StringOption optionListClass;
private StringOption optionGrammarName;
private CommandLine commandLine;
public Compiler(String[] args) throws CommandLineException {
......@@ -51,12 +52,14 @@ public class Compiler {
ASTNode.listClass = optionListClass.getValue();
}
String grammarName = "Grammar";
if (optionGrammarName.isSet()) {
grammarName = optionGrammarName.getValue();
}
if (optionWriteToFile.isSet()) {
File file = new File(filenames.get(0));
String absPath = file.getAbsolutePath();
String absPathExclExt = absPath.substring(0, absPath.lastIndexOf('.'));
writeToFile(absPathExclExt + "Gen.ast", p.generateAbstractGrammar());
writeToFile(absPathExclExt + "Gen.jadd", p.generateAspect());
writeToFile(grammarName + ".ast", p.generateAbstractGrammar());
writeToFile(grammarName + ".jadd", p.generateAspect());
} else if (optionPrintAST.isSet()) {
System.out.println(p.dumpTree());
} else {
......@@ -90,6 +93,7 @@ public class Compiler {
optionWriteToFile = addOption(new FlagOption("file", "write output to files <filename>Gen.ast and <filename>Gen.jadd"));
optionPrintAST = addOption(new FlagOption("ast", "print AST"));
optionListClass = addOption(new StringOption("listClass", "determine the class name of the nonterminal reference list"));
optionGrammarName = addOption(new StringOption("grammarName", "name of the generated grammar and aspect (without file extension)"));
}
private <OptionType extends Option<?>> OptionType addOption(OptionType option) {
......
all: build-jar test
test: test1
test: clean test1
@echo "#"
@echo "# MULTIPLE FILES TESTS OK"
@echo "#"
......@@ -7,11 +7,14 @@ test: test1
build-jar:
(cd ../../ && ./gradlew jar)
test1:
java -jar ../../build/libs/relast.jar Rules1.relast Rules2.relast Rules3.relast --file
rm -rf AST
rm -rf *.class
java -jar ../../tools/jastadd2.jar --package=AST Rules1Gen.ast Rules1Gen.jadd Utils.jadd
java -jar ../../build/libs/relast.jar Rules1.relast Rules2.relast Rules3.relast --file --grammarName=All
java -jar ../../tools/jastadd2.jar --package=AST All.ast All.jadd Utils.jadd
javac AST/*.java All.java
java All
java -jar ../../build/libs/relast.jar Rules1Gen.ast --file
diff Rules1Gen.ast Rules1GenGen.ast
\ No newline at end of file
java -jar ../../build/libs/relast.jar All.ast --file --grammarName=AllGen
diff All.ast AllGen.ast
clean:
rm -rf AST
rm -f *.class
rm -f *.ast
\ No newline at end of file
......@@ -7,15 +7,15 @@ test: test1 test2
build-jar:
(cd ../../ && ./gradlew jar)
test1:
java -jar ../../build/libs/relast.jar All.relast --file
java -jar ../../build/libs/relast.jar All.relast --file --grammarName=AllGen
rm -rf AST
java -jar ../../tools/jastadd2.jar --package=AST AllGen.ast AllGen.jadd Utils.jadd
javac AST/*.java All.java
java All
java -jar ../../build/libs/relast.jar AllGen.ast --file
java -jar ../../build/libs/relast.jar AllGen.ast --file --grammarName=AllGenGen
diff AllGen.ast AllGenGen.ast
test2:
java -jar ../../build/libs/relast.jar LowerBounds.relast --file
java -jar ../../build/libs/relast.jar LowerBounds.relast --file --grammarName=LowerBoundsGen
rm -rf AST
java -jar ../../tools/jastadd2.jar --package=AST LowerBoundsGen.ast LowerBoundsGen.jadd Utils.jadd
javac AST/*.java LowerBounds.java
......
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