Commit 8e4b63d8 authored by Johannes Roith's avatar Johannes Roith

Various fixes in the backend.

parent 4a8fdee5
......@@ -7,9 +7,6 @@ public class LabeledProductionSymbolRef extends ProductionSymbolRef
{
public String label; // TODO: Name class?
// TODO: this should point to the declaration, after being resolved by a visitor.
public Production declaration;
public LabeledProductionSymbolRef(Name name, String label, Range range) {
super(name, range);
this.label = label;
......
......@@ -9,7 +9,7 @@ public class Production extends AbstractNode
implements IWithName, IHasDeclarationReference
{
private NonTerminal declarationRef;
private Name lhs;
private Name lhs; // TODO: This should really be a NonTerminal class
private List<ProductionRight> rhs;
@Override
......
......@@ -10,6 +10,7 @@ import de.in.tum.www2.cup.Range;
public class ProductionRight extends AbstractNode {
private List<IProductionRightPart> lst;
private Terminal precedenceLike;
private int index;
private List<Integer> extractedActionProductions;
......@@ -25,6 +26,10 @@ public class ProductionRight extends AbstractNode {
return index;
}
public boolean hasSpecifiedPrecedence() {
return precedenceLike != null;
}
public List<Integer> getExtractedActionProductions() {
return extractedActionProductions;
}
......@@ -39,17 +44,23 @@ public class ProductionRight extends AbstractNode {
public ProductionRight(int index,
List<Integer> extractedActionProductions,
List<IProductionRightPart> lst, Range range) {
List<IProductionRightPart> lst,
Terminal precedenceLike,
Range range) {
super(range);
this.precedenceLike = precedenceLike;
this.index = index;
this.extractedActionProductions = extractedActionProductions;
this.lst = lst;
if (lst != null) {
for (IProductionRightPart prp : lst)
for (IProductionRightPart prp : lst) {
if (prp != null) {
if (prp instanceof AbstractNode)
((AbstractNode) prp).setParent(this);
}
if (precedenceLike != null)
precedenceLike.setParent(this);
}
}
}
......@@ -83,6 +94,8 @@ public class ProductionRight extends AbstractNode {
for (IProductionRightPart ip : lst)
ip.accept(visitor, childArg);
}
if (precedenceLike != null)
precedenceLike.accept(visitor, childArg);
}
visitor.postVisit(this, data);
}
......@@ -109,6 +122,11 @@ public class ProductionRight extends AbstractNode {
builder.append(",");
builder.append("\n");
}
if (precedenceLike != null) {
builder.append("%prec ");
builder.append(precedenceLike);
builder.append("\n");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment