From 1a5258254a3dfe745fb6ab88f930f85b8a589d4e Mon Sep 17 00:00:00 2001 From: Niklas Fors <niklas.fors@cs.lth.se> Date: Fri, 15 Nov 2019 16:31:59 +0100 Subject: [PATCH] Make --gammar optional when using --jjtree --- ChangeLog | 9 +++++++-- src/java/org/jastadd/Configuration.java | 13 ++++--------- src/template/ast/JJTree.tt | 2 ++ src/template/ast/NodeConstructor.tt | 2 ++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a46dac5b..d3f30aa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-11-15 Niklas Fors <niklas.fors@cs.lth.se> + + * Made --gammar optional when using --jjtree + 2019-11-15 Jesper Öqvist <jesper.oqvist@cs.lth.se> * Fixed faulty code generation for incremental attributes with NTA tokens. @@ -505,7 +509,7 @@ 2013-12-03 Niklas Fors <niklas.fors@cs.lth.se> - * Added the abstract methods fullCopy(), treeCopyNoTransform() and + * Added the abstract methods fullCopy(), treeCopyNoTransform() and treeCopy() to abstract classes (with correct return type). 2013-10-30 Jesper Öqvist <jesper.oqvist@cs.lth.se> @@ -1358,7 +1362,8 @@ Removed errornous rewrite initialization code generated with rewrites disabled ---------------------------- jastadd2.jar revision 1.13 date: 2004-10-19 11:31:41 +0200; author: mjolner; state: Exp; lines: +636 -627; -Handle primitive circular attributes. Handle inherited circular attributes. +Handle primitive circular attributes. +Handle inherited circular attributes. ---------------------------- jastadd2.jar revision 1.12 date: 2004-10-13 20:07:20 +0200; author: torbjorn; state: Exp; lines: +417 -424; diff --git a/src/java/org/jastadd/Configuration.java b/src/java/org/jastadd/Configuration.java index 5e304be4..a2831619 100644 --- a/src/java/org/jastadd/Configuration.java +++ b/src/java/org/jastadd/Configuration.java @@ -121,11 +121,11 @@ public class Configuration { .templateVariable("generateAnnotations"); Option<Boolean> jjtreeOption = new FlagOption("jjtree", - "use jjtree base node, this requires --grammar to be set") + "use jjtree base node") .templateVariable("JJTree"); Option<String> grammarOption = new ValueOption("grammar", - "the name of the grammar's parser, required when using --jjtree") + "parser name when using --jjtree, used for generating visitor methods") .templateVariable("ParserName"); Option<String> defaultMapOption = new ValueOption( @@ -191,7 +191,7 @@ public class Configuration { // TODO(jesper): make this deprecated. Option<Boolean> inhEqCheckOption = new BooleanOption("inhEqCheck", - "enalbe check for inherited equations") + "enable check for inherited equations") .defaultValue(true) .nonStandard(); @@ -634,11 +634,6 @@ public class Configuration { return true; } - if (jjtreeOption.value() && grammarOption.value().isEmpty()) { - out.println("Error: No grammar name given. A grammar name is required in JJTree-mode!"); - return true; - } - Collection<String> grammarFiles = new LinkedList<String>(); for (String filename: filenames) { if (filename.endsWith(".ast")) { @@ -1282,7 +1277,7 @@ public class Configuration { * @return {@code true} annotations shall be generated. */ public boolean generateAnnotations() { - return generateAnnotations.value(); + return generateAnnotations.value(); } /** diff --git a/src/template/ast/JJTree.tt b/src/template/ast/JJTree.tt index fb4bb9d0..c7bb2c99 100644 --- a/src/template/ast/JJTree.tt +++ b/src/template/ast/JJTree.tt @@ -49,9 +49,11 @@ JJTree.dumpTree = [[ ]] JJTree.jjtAccept = [[ +$if(ParserName) public Object #name.jjtAccept($(ParserName)Visitor visitor, Object data) { return visitor.visit(this, data); } +$endif ]] JJTree.checkChild = [[ diff --git a/src/template/ast/NodeConstructor.tt b/src/template/ast/NodeConstructor.tt index 33c73eb5..4b0db9e1 100644 --- a/src/template/ast/NodeConstructor.tt +++ b/src/template/ast/NodeConstructor.tt @@ -35,10 +35,12 @@ $endif $FinalInit } +$if(ParserName) public #name.#name($ParserName p, int i) { this(i); parser = p; } +$endif public #name.#name() { this(0); -- GitLab