public override object VisitParCommand([NotNull] OALParser.ParCommandContext context) { stackEXEScope.Push(new EXEScopeParallel()); for (int i = 1; i < context.ChildCount; i++) { Console.WriteLine(i + " -> " + context.GetChild(i).GetText() + " --- " + context.GetChild(i).GetType().Name); if (context.GetChild(i).GetText().Equals("thread")) { stackEXEScope.Push(new EXEScope()); } else if (context.GetChild(i).GetType().Name.Contains("LineContext")) { Visit(context.GetChild(i)); } else if (context.GetChild(i).GetText().Equals("end thread;")) { EXEScope temp = stackEXEScope.Pop(); ((EXEScopeParallel)stackEXEScope.Peek()).AddThread(temp); } else if (context.GetChild(i).GetText().Equals("end par;")) { EXEScope temp = stackEXEScope.Pop(); stackEXEScope.Peek().AddCommand(temp); } } return(null); //return base.VisitParCommand(context); }
public OALVisitor2() { this.globalExeScope = new EXEScope(); this.stackEXEASTNode = new Stack <EXEASTNode>(); this.stackEXEScope = new Stack <EXEScope>(); this.stackEXEScope.Push(this.globalExeScope); }
public override object VisitForeachCommand([NotNull] OALParser.ForeachCommandContext context) { String Iterator = context.GetChild(1).GetText(); String Iterable = context.GetChild(3).GetText(); stackEXEScope.Push(new EXEScopeForEach(Iterator, Iterable)); for (int i = 4; i < context.ChildCount; i++) { if (context.GetChild(i).GetType().Name.Contains("LineContext")) { Visit(context.GetChild(i)); } else if (context.GetChild(i).GetText().Contains("end for;")) { EXEScope temp = stackEXEScope.Pop(); stackEXEScope.Peek().AddCommand(temp); } } return(null); //return base.VisitForeachCommand(context); }
public override object VisitWhileCommand([NotNull] OALParser.WhileCommandContext context) { Visit(context.GetChild(2)); EXEScopeLoopWhile EXEScopeLoopWhile = new EXEScopeLoopWhile(stackEXEASTNode.Peek()); stackEXEASTNode.Clear(); stackEXEScope.Push(EXEScopeLoopWhile); for (int i = 4; i < context.ChildCount; i++) { if (context.GetChild(i).GetType().Name.Contains("LineContext")) { Visit(context.GetChild(i)); } else if (context.GetChild(i).GetText().Contains("end while;")) { EXEScope temp = stackEXEScope.Pop(); stackEXEScope.Peek().AddCommand(temp); } } return(null); //return base.VisitWhileCommand(context); }
public override bool Execute(OALProgram OALProgram, EXEScope Scope) { return(Scope.PropagateControlCommand(LoopControlStructure.Continue)); }
public override object VisitIfCommnad([NotNull] OALParser.IfCommnadContext context) { Visit(context.GetChild(2)); EXEScopeCondition EXEScopeCondition = new EXEScopeCondition(stackEXEASTNode.Peek()); stackEXEASTNode.Clear(); stackEXEScope.Push(EXEScopeCondition); Boolean els = false; Boolean elif = false; for (int i = 4; i < context.ChildCount; i++) { if (context.GetChild(i).GetType().Name.Contains("LineContext")) { Console.WriteLine(i + " -> " + context.GetChild(i).GetText()); Visit(context.GetChild(i)); } else if (context.GetChild(i).GetText().Equals("else")) { if (elif) { EXEScopeCondition temp3 = ((EXEScopeCondition)stackEXEScope.Pop()); ((EXEScopeCondition)stackEXEScope.Peek()).AddElifScope(temp3); } els = true; EXEScope temp2 = new EXEScope(); ((EXEScopeCondition)stackEXEScope.Peek()).ElseScope = temp2; EXEScope temp = stackEXEScope.Pop(); stackEXEScope.Peek().AddCommand(temp); stackEXEScope.Push(temp2); } else if (context.GetChild(i).GetText().Contains("elif")) { if (elif) { EXEScopeCondition temp = ((EXEScopeCondition)stackEXEScope.Pop()); ((EXEScopeCondition)stackEXEScope.Peek()).AddElifScope(temp); } elif = true; Console.WriteLine(i + " -> " + context.GetChild(i).GetText()); Console.WriteLine(i + "+ 2 -> " + context.GetChild(i + 2).GetText()); Visit(context.GetChild(i + 2)); EXEScopeCondition EXEScopeConditionELIF = new EXEScopeCondition(stackEXEASTNode.Peek()); stackEXEASTNode.Clear(); stackEXEScope.Push(EXEScopeConditionELIF); } else if (context.GetChild(i).GetText().Contains("end if;")) { Console.WriteLine(i + "-> " + context.GetChild(i).GetText()); EXEScope temp = stackEXEScope.Pop(); if (!els && !elif)//TODO ako toto funguje? - napisal tvorca { stackEXEScope.Peek().AddCommand(temp); } if (elif && !els) { ((EXEScopeCondition)stackEXEScope.Peek()).AddElifScope((EXEScopeCondition)temp); EXEScopeCondition temp2 = ((EXEScopeCondition)stackEXEScope.Pop()); stackEXEScope.Peek().AddCommand(temp2); } } } return(null); //return base.VisitIfCommnad(context); }