Skip to content

Commit 7f8dfd9

Browse files
committed
Merge branch 'feature/20-attributes' into develop
2 parents 44c7126 + aa43959 commit 7f8dfd9

13 files changed

+314
-277
lines changed

src/wyrl/ConsoleRewriter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ private void print(AbstractActivation activation, Rewrite.Step step) {
164164
if(activation.rule() instanceof InferenceRule) {
165165
System.out.print("* ");
166166
}
167-
if(activation.rule().name() != null) {
168-
System.out.print(activation.rule().name());
167+
if(activation.rule().annotation("name") != null) {
168+
System.out.print(activation.rule().annotation("name"));
169169
}
170170
System.out.print(" #" + activation.target());
171171
if(step != null) {
@@ -182,7 +182,7 @@ public void printLog() {
182182
AbstractActivation activation = rewrite.states().get(before).activation(step.activation());
183183
int after = step.after();
184184
System.out.print(before + " => " + after);
185-
System.out.println(" (" + activation.target() + ", " + activation.rule().name() + ")");
185+
System.out.println(" (" + activation.target() + ", " + activation.rule().annotation("name") + ")");
186186
}
187187
}
188188

@@ -233,9 +233,9 @@ public void startRewrite(Reader input, RwMode mode) throws Exception {
233233
private Rewrite constructRewrite(final Schema schema, final ReductionRule[] reductions,
234234
InferenceRule[] inferences, RwMode mode) {
235235
if (mode == RwMode.INFER) {
236-
return new Inference(schema, AbstractActivation.RANK_COMPARATOR, inferences, reductions);
236+
return new Inference(schema, null, inferences, reductions);
237237
} else {
238-
return new Reduction(schema, AbstractActivation.RANK_COMPARATOR, reductions);
238+
return new Reduction(schema, null, reductions);
239239
}
240240
}
241241

src/wyrl/core/SpecFile.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,56 +56,60 @@ public IncludeDecl(SpecFile file, Attribute... attributes) {
5656
}
5757
}
5858

59-
public static class TermDecl extends SyntacticElement.Impl implements Decl {
59+
public static class AnnotableDecl extends SyntacticElement.Impl implements Decl {
60+
public final Map<String,Object> annotations;
61+
62+
public AnnotableDecl(Map<String,Object> annotations, Attribute... attributes) {
63+
super(attributes);
64+
this.annotations = new HashMap<String,Object>(annotations);
65+
}
66+
}
67+
68+
public static class TermDecl extends AnnotableDecl {
6069
public Type.Term type;
6170

62-
public TermDecl(Type.Term data, Attribute... attributes) {
63-
super(attributes);
71+
public TermDecl(Type.Term data, Map<String,Object> annotations, Attribute... attributes) {
72+
super(annotations,attributes);
6473
this.type = data;
6574
}
6675
}
6776

68-
public static class TypeDecl extends SyntacticElement.Impl implements Decl {
77+
public static class TypeDecl extends AnnotableDecl {
6978
public final String name;
7079
public final Type type;
7180
public final boolean isOpen;
7281

73-
public TypeDecl(String n, Type type, boolean isOpen, Attribute... attributes) {
74-
super(attributes);
82+
public TypeDecl(String n, Type type, boolean isOpen, Map<String,Object> annotations, Attribute... attributes) {
83+
super(annotations,attributes);
7584
this.name = n;
7685
this.type = type;
7786
this.isOpen = isOpen;
7887
}
7988
}
8089

81-
public static abstract class RewriteDecl extends SyntacticElement.Impl implements
82-
Decl {
90+
public static abstract class RewriteDecl extends AnnotableDecl {
8391
public Pattern.Term pattern;
8492
public final ArrayList<RuleDecl> rules;
85-
public final String name;
86-
public final int rank;
8793

8894
public RewriteDecl(Pattern.Term pattern, Collection<RuleDecl> rules,
89-
String name, int rank, Attribute... attributes) {
90-
super(attributes);
95+
Map<String,Object> annotations, Attribute... attributes) {
96+
super(annotations, attributes);
9197
this.pattern = pattern;
92-
this.rules = new ArrayList<RuleDecl>(rules);
93-
this.name = name;
94-
this.rank = rank;
98+
this.rules = new ArrayList<RuleDecl>(rules);
9599
}
96100
}
97101

98102
public static class ReduceDecl extends RewriteDecl {
99103
public ReduceDecl(Pattern.Term pattern, Collection<RuleDecl> rules,
100-
String name, int rank, Attribute... attributes) {
101-
super(pattern,rules,name,rank,attributes);
104+
Map<String,Object> annotations, Attribute... attributes) {
105+
super(pattern,rules,annotations,attributes);
102106
}
103107
}
104108

105109
public static class InferDecl extends RewriteDecl {
106-
public InferDecl(Pattern.Term pattern, Collection<RuleDecl> rules,
107-
String name, int rank, Attribute... attributes) {
108-
super(pattern,rules,name,rank, attributes);
110+
public InferDecl(Pattern.Term pattern, Collection<RuleDecl> rules, Map<String, Object> annotations,
111+
Attribute... attributes) {
112+
super(pattern,rules,annotations,attributes);
109113
}
110114
}
111115

0 commit comments

Comments
 (0)