Skip to content
Snippets Groups Projects
Commit abce5ee8 authored by René Schöne's avatar René Schöne
Browse files

Add option for JastAddList name.

parent dcfe383c
No related branches found
No related tags found
1 merge request!1Mquat2
aspect BackendAbstractGrammar { aspect BackendAbstractGrammar {
public static String ASTNode.listClass = "ArrayList"; public static String ASTNode.listClass = "ArrayList";
public static String ASTNode.jastAddListType = "List";
public String Program.generateAbstractGrammar() { public String Program.generateAbstractGrammar() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -120,7 +121,7 @@ aspect BackendAspect { ...@@ -120,7 +121,7 @@ aspect BackendAspect {
return getTypeUse() + " " + getID(); return getTypeUse() + " " + getID();
} }
public String ListComponent.constructorParameter() { public String ListComponent.constructorParameter() {
return "List<" + getTypeUse() + "> " + getID(); return ASTNode.jastAddListType + "<" + getTypeUse() + "> " + getID();
} }
public String OptComponent.constructorParameter() { public String OptComponent.constructorParameter() {
return "Opt<" + getTypeUse() + "> " + getID(); return "Opt<" + getTypeUse() + "> " + getID();
......
...@@ -18,11 +18,12 @@ import org.jastadd.relast.compiler.options.CommandLine.CommandLineException; ...@@ -18,11 +18,12 @@ import org.jastadd.relast.compiler.options.CommandLine.CommandLineException;
import beaver.Parser; import beaver.Parser;
public class Compiler { public class Compiler {
protected ArrayList<Option<?>> options; private ArrayList<Option<?>> options;
protected FlagOption optionWriteToFile; private FlagOption optionWriteToFile;
protected FlagOption optionPrintAST; private FlagOption optionPrintAST;
protected StringOption optionListClass; private StringOption optionListClass;
protected CommandLine commandLine; private StringOption optionJastAddList;
private CommandLine commandLine;
public Compiler(String args[]) throws CommandLineException { public Compiler(String args[]) throws CommandLineException {
options = new ArrayList<>(); options = new ArrayList<>();
...@@ -51,9 +52,14 @@ public class Compiler { ...@@ -51,9 +52,14 @@ public class Compiler {
if (optionListClass.isSet()) { if (optionListClass.isSet()) {
System.out.println("ListClass is set to " + optionListClass.getValue()); System.out.println("ListClass is set to " + optionListClass.getValue());
p.listClass = optionListClass.getValue(); ASTNode.listClass = optionListClass.getValue();
} }
if (optionJastAddList.isSet()) {
System.out.println("JastAdd List type is set to " + optionJastAddList.getValue());
ASTNode.jastAddListType = optionJastAddList.getValue();
}
if (optionWriteToFile.isSet()) { if (optionWriteToFile.isSet()) {
File file = new File(filename); File file = new File(filename);
String absPath = file.getAbsolutePath(); String absPath = file.getAbsolutePath();
...@@ -81,9 +87,14 @@ public class Compiler { ...@@ -81,9 +87,14 @@ public class Compiler {
} }
protected void addOptions() { protected void addOptions() {
optionWriteToFile = addOption(new FlagOption("file", "write output to files <filename>Gen.ast and <filename>Gen.jadd")); optionWriteToFile = addOption(new FlagOption("file",
optionPrintAST = addOption(new FlagOption("ast", "print AST")); "write output to files <filename>Gen.ast and <filename>Gen.jadd"));
optionListClass = addOption(new StringOption("listClass", "determine the class name of the nonterminal reference list")); optionPrintAST = addOption(new FlagOption("ast",
"print AST"));
optionListClass = addOption(new StringOption("listClass",
"determine the class name of the nonterminal reference list"));
optionJastAddList = addOption(new StringOption("jastAddList",
"set the name of the List type in JastAdd (has to match the option '--List' or its default List)"));
} }
protected <OptionType extends Option<?>> OptionType addOption(OptionType option) { protected <OptionType extends Option<?>> OptionType addOption(OptionType option) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment