Skip to content
Snippets Groups Projects
Commit d6ad14da authored by Jesper's avatar Jesper
Browse files

Remove list rewrites

parent d492f921
Branches
No related tags found
No related merge requests found
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> 2020-05-15 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Fixed order dependency between interface declarations and collection * Fixed order dependency between interface declarations and collection
......
...@@ -58,8 +58,6 @@ ClassBodyDecl ::= <Name> <FileName> <StartLine:int> <EndLine:int> <AspectName:St ...@@ -58,8 +58,6 @@ ClassBodyDecl ::= <Name> <FileName> <StartLine:int> <EndLine:int> <AspectName:St
Rewrite ::= <FileName> <StartLine:int> <EndLine:int> <AspectName>; Rewrite ::= <FileName> <StartLine:int> <EndLine:int> <AspectName>;
RewriteList : Rewrite;
/** A component of an AST node type declaration. */ /** A component of an AST node type declaration. */
abstract Component; abstract Component;
......
...@@ -506,16 +506,4 @@ aspect AttributeProblems { ...@@ -506,16 +506,4 @@ aspect AttributeProblems {
when root != null && root() == null when root != null && root() == null
to TypeDecl.attributeProblems() to TypeDecl.attributeProblems()
for hostClass(); 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();
} }
...@@ -87,45 +87,6 @@ public aspect Attributes { ...@@ -87,45 +87,6 @@ public aspect Attributes {
aspectMap.put(name, comment); 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( public void Grammar.addRewrite(
String className, String className,
org.jastadd.jrag.AST.SimpleNode condition, org.jastadd.jrag.AST.SimpleNode condition,
...@@ -1125,24 +1086,4 @@ public aspect Attributes { ...@@ -1125,24 +1086,4 @@ public aspect Attributes {
public void Rewrite.setReturnType(String type) { public void Rewrite.setReturnType(String type) {
returnType = 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;
}
} }
...@@ -90,18 +90,6 @@ aspect Rewrites { ...@@ -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) { public void Rewrite.genRewriteCondition(PrintStream out, int index) {
TemplateContext tt = templateContext(); TemplateContext tt = templateContext();
tt.bind("RewriteIndex", "" + index); tt.bind("RewriteIndex", "" + index);
...@@ -129,23 +117,6 @@ aspect Rewrites { ...@@ -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() = syn lazy boolean ASTDecl.hasRewrites() =
getNumRewrite() > 0 || (superClass() != null && superClass().hasRewrites()); getNumRewrite() > 0 || (superClass() != null && superClass().hasRewrites());
......
...@@ -1139,22 +1139,15 @@ void AspectRewrite() : ...@@ -1139,22 +1139,15 @@ void AspectRewrite() :
SimpleNode eq; SimpleNode eq;
Token first, last; Token first, last;
Token parent = null;
Token child = null;
String type; String type;
} }
{ {
"rewrite" {cond = null; first = token;} t = <IDENTIFIER> { className = t.image; } "rewrite" {cond = null; first = token;} t = <IDENTIFIER> { className = t.image; }
[<IDENTIFIER> parent = <IDENTIFIER> "." child = <IDENTIFIER> <LPAREN> <RPAREN>]
<LBRACE> <LBRACE>
( ["when" { first = token; } <LPAREN> cond = Expression() <RPAREN>] ( ["when" { first = token; } <LPAREN> cond = Expression() <RPAREN>]
"to" type = AspectType() ( (eq = Expression() ";" { last = token; }) | eq = Block() { last = token; } ) "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; cond = null;
} }
)+ )+
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment