public override void doAction(CSsemi.CSemiExp semi) { RelElem Relem = new RelElem(); Relem.type = semi[0]; // expects relationship Relem.name = semi[1]; //expects name Relem.withName = semi[2]; // expects withname Relem.beginRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; if (semi[0].Equals("Aggregation")) { Relem.endRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; } else if (semi[0].Equals("Composition")) { Relem.endRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; } else if (semi[0].Equals("Using")) { Relem.endRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; } else if (semi[0].Equals("UsingTemp")) { Relem.endRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; } else if (semi[0].Equals("UsingStr")) { Relem.endRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; } else if (semi[0].Equals("Inheritance")) { Relem.endRel = repo_.semi.lineCount - 1 - repo_.prevLineCount; } else { Relem.endRel = 0; repo_.stack2.push(Relem); } if (Relem.type == "control" || Relem.name == "anonymous" || Relem.withName == "anonymous2") { return; } repo_.inheritance.Add(Relem); if (AAction.displaySemi) { Console.Write("\n line# {0,-5}", repo_.semi.lineCount - 1); Console.Write("entering "); string indent = new string(' ', 2 * repo_.stack.count); Console.Write("{0}", indent); this.display(semi); // defined in abstract action } if (AAction.displayStack) { repo_.stack.display(); } }
public override void doAction(CSsemi.CSemiExp semi) { RelElem Relem; try { Relem = repo_.stack2.pop(); for (int i = 0; i < repo_.inheritance.Count; ++i) { RelElem temp = repo_.inheritance[i]; if (Relem.type == temp.type) { if (Relem.name == temp.name) { if (Relem.withName == temp.withName) { if ((repo_.inheritance[i]).endRel == 0) { (repo_.inheritance[i]).endRel = repo_.semi.lineCount - repo_.prevLineCount; break; } } } } } } catch { Console.Write("popped empty stack on semiExp: "); semi.display(); return; } CSsemi.CSemiExp local = new CSsemi.CSemiExp(); local.Add(Relem.type).Add(Relem.name); if (local[0] == "control") { return; } if (AAction.displaySemi) { Console.Write("\n line# {0,-5}", repo_.semi.lineCount); Console.Write("leaving "); string indent = new string(' ', 2 * (repo_.stack.count + 1)); Console.Write("{0}", indent); this.display(local); // defined in abstract action } }