From d6ad14da10022913bf7b82c91d21d5b0defffb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20=C3=96qvist?= <jesper.oqvist@cs.lth.se> Date: Mon, 18 May 2020 17:16:26 +0200 Subject: [PATCH] Remove list rewrites --- ChangeLog | 4 ++ src/jastadd/ast/Ast.ast | 2 - src/jastadd/ast/AttributeProblems.jrag | 12 ------ src/jastadd/ast/Attributes.jrag | 59 -------------------------- src/jastadd/ast/Rewrites.jrag | 29 ------------- src/javacc/jrag/Jrag.jjt | 9 +--- 6 files changed, 5 insertions(+), 110 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65bc1be5..79f29356 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-05-18 Jesper Öqvist <jesper.oqvist@cs.lth.se> + + * Removed the deprecated list rewrite feature. + 2020-05-15 Jesper Öqvist <jesper.oqvist@cs.lth.se> * Fixed order dependency between interface declarations and collection diff --git a/src/jastadd/ast/Ast.ast b/src/jastadd/ast/Ast.ast index 76168e0e..7ffba661 100644 --- a/src/jastadd/ast/Ast.ast +++ b/src/jastadd/ast/Ast.ast @@ -58,8 +58,6 @@ ClassBodyDecl ::= <Name> <FileName> <StartLine:int> <EndLine:int> <AspectName:St Rewrite ::= <FileName> <StartLine:int> <EndLine:int> <AspectName>; -RewriteList : Rewrite; - /** A component of an AST node type declaration. */ abstract Component; diff --git a/src/jastadd/ast/AttributeProblems.jrag b/src/jastadd/ast/AttributeProblems.jrag index 6683df94..3d29e4d7 100644 --- a/src/jastadd/ast/AttributeProblems.jrag +++ b/src/jastadd/ast/AttributeProblems.jrag @@ -506,16 +506,4 @@ aspect AttributeProblems { when root != null && root() == null to TypeDecl.attributeProblems() for hostClass(); - - RewriteList contributes - error("list rewrites are not supported when using cnta rewrites") - when config().rewriteCircularNTA() - to TypeDecl.attributeProblems() - for hostClass(); - - RewriteList contributes - warning("list rewrites are deprecated and will be removed in a future version of JastAdd") - when config().legacyRewrite() - to TypeDecl.attributeProblems() - for hostClass(); } diff --git a/src/jastadd/ast/Attributes.jrag b/src/jastadd/ast/Attributes.jrag index 95bb3b55..86ed10fb 100644 --- a/src/jastadd/ast/Attributes.jrag +++ b/src/jastadd/ast/Attributes.jrag @@ -87,45 +87,6 @@ public aspect Attributes { aspectMap.put(name, comment); } - // Add attributes to AST. - public void Grammar.addRewriteList( - String className, - org.jastadd.jrag.AST.SimpleNode condition, - org.jastadd.jrag.AST.SimpleNode result, - String type, - String fileName, - int startLine, - int endLine, - String parentName, - String childName, - String aspectName) { - - if (!config().rewriteEnabled()) { - error("can not use rewrites while rewrites are disabled (enable with --rewrite=cnta)", - fileName, startLine); - return; - } - - TypeDecl c = lookup(className); - if (c != null && c instanceof ASTDecl) { - RewriteList r = new RewriteList(); - r.setFileName(fileName); - r.setStartLine(startLine); - r.setEndLine(endLine); - r.setCondition(condition); - r.setResult(result); - r.setReturnType(type); - r.setParentName(parentName); - r.setChildName(childName); - r.setAspectName(aspectName); - ((ASTDecl)c).addRewrite(r); - } else if (c != null) { - error("can not rewrite to non AST class '" + className + "'", fileName, startLine); - } else { - error("can not rewrite to unknown class '" + className + "'", fileName, startLine); - } - } - public void Grammar.addRewrite( String className, org.jastadd.jrag.AST.SimpleNode condition, @@ -1125,24 +1086,4 @@ public aspect Attributes { public void Rewrite.setReturnType(String type) { returnType = type; } - - public String RewriteList.parentName; - - public String RewriteList.getParentName() { - return parentName; - } - - public void RewriteList.setParentName(String name) { - parentName = name; - } - - public String RewriteList.childName; - - public String RewriteList.getChildName() { - return childName; - } - - public void RewriteList.setChildName(String name) { - childName = name; - } } diff --git a/src/jastadd/ast/Rewrites.jrag b/src/jastadd/ast/Rewrites.jrag index 8216bd73..49330634 100644 --- a/src/jastadd/ast/Rewrites.jrag +++ b/src/jastadd/ast/Rewrites.jrag @@ -90,18 +90,6 @@ aspect Rewrites { } } - public boolean RewriteList.genRewrite(PrintStream out, int index) { - TemplateContext tt = templateContext(); - tt.expand("Rewrite.declaredat", out); - if (getCondition() != null) { - tt.bind("Condition", " && " + Unparser.unparse(getCondition())); - } else { - tt.bind("Condition", ""); - } - tt.expand("RewriteList.genRewrite", out); - return false; - } - public void Rewrite.genRewriteCondition(PrintStream out, int index) { TemplateContext tt = templateContext(); tt.bind("RewriteIndex", "" + index); @@ -129,23 +117,6 @@ aspect Rewrites { } } - public void RewriteList.genRewritesExtra(PrintStream out, int index) { - String ind = config().indent; - String ind2 = config().ind(2); - if (getResult() instanceof org.jastadd.jrag.AST.ASTBlock) { - templateContext().expand("Rewrite.javaDoc:internal", out); - out.println(ind + "private " + getReturnType() + " rewrite" - + getParentName() + "_" + getChildName() + "() {"); - out.print(Unparser.unparse(getResult())); - out.println(ind + "}"); - } else { - templateContext().expand("Rewrite.javaDoc:internal", out); - out.println(ind + "private " + getReturnType() + " rewrite" + getParentName() + "_" + getChildName() + "() {"); - out.println(ind2 + "return " + Unparser.unparse(getResult()) + ";"); - out.println(ind + "}"); - } - } - syn lazy boolean ASTDecl.hasRewrites() = getNumRewrite() > 0 || (superClass() != null && superClass().hasRewrites()); diff --git a/src/javacc/jrag/Jrag.jjt b/src/javacc/jrag/Jrag.jjt index c349e8a1..1c949828 100644 --- a/src/javacc/jrag/Jrag.jjt +++ b/src/javacc/jrag/Jrag.jjt @@ -1139,22 +1139,15 @@ void AspectRewrite() : SimpleNode eq; Token first, last; - Token parent = null; - Token child = null; String type; } { "rewrite" {cond = null; first = token;} t = <IDENTIFIER> { className = t.image; } - [<IDENTIFIER> parent = <IDENTIFIER> "." child = <IDENTIFIER> <LPAREN> <RPAREN>] <LBRACE> ( ["when" { first = token; } <LPAREN> cond = Expression() <RPAREN>] "to" type = AspectType() ( (eq = Expression() ";" { last = token; }) | eq = Block() { last = token; } ) { - if (parent != null && child != null) { - root.addRewriteList(className, cond, eq, type, fileName, first.beginLine, last.endLine, parent.image, child.image, enclosingAspect); - } else { - root.addRewrite(className, cond, eq, type, fileName, first.beginLine, last.endLine, enclosingAspect); - } + root.addRewrite(className, cond, eq, type, fileName, first.beginLine, last.endLine, enclosingAspect); cond = null; } )+ -- GitLab