private LetCommand parseLet() { if (CurrentToken != null && accept(_let)) { LetCommand curRoot = new LetCommand(prevLine); if (root == null) { root = curRoot; } while (CurrentToken.getType() != _in) { // accept(_in); curRoot.addDeclaration(parseDeclaration()); } accept(_in); while (CurrentToken.getType() != _end) { curRoot.addCommand(parseCommand()); } accept(_end); return(curRoot); } logError(CurrentToken, "Syntax error: Let required."); return(null); }
private void DoAnalyse(Command node) { if (node is LetCommand) { LetCommand letCommand = (LetCommand)node; DeclarationCheck(letCommand.SequentialDeclaration); AnalyseCommands(letCommand.SequentialCommand); RemoveScope(letCommand.SequentialDeclaration); } if (node is AssignCommand) { AssignCommand assignCommand = (AssignCommand)node; string type = ""; AnalyseAssignment(assignCommand, type); } if (node is IfCommand) { IfCommand ifCommand = (IfCommand)node; AnalyzeCondition(ifCommand.Expression); DoAnalyse(ifCommand.ThenCommand); DoAnalyse(ifCommand.ElseCommand); } }
public Contextualiser(LetCommand root) { _compilerUtils = CompilerUtils.getInstance(); this.root = root; declaList = new LinkedList <LinkedList <DeclarationCommand> >(); table = new Dictionary <string, string>(); }
public Void VisitLetCommand(LetCommand ast, Void arg) { _idTable.OpenScope(); ast.Declaration.Visit(this); ast.Command.Visit(this); _idTable.CloseScope(); return(null); }
public object visitLetCommand(LetCommand command, object arg) { idTable.openScope(); command.declaration.visit(this, null); command.command.visit(this, null); idTable.closeScope(); return(null); }
public Void VisitLetCommand(LetCommand ast, Void arg) { System.Console.WriteLine("Visiting letCommand"); idTable.OpenScope(); ast.Declaration.Visit(this, null); ast.Command.Visit(this, null); idTable.CloseScope(); return(null); }
public Void VisitLetCommand(LetCommand ast, Frame frame) { var extraSize = ast.Declaration.Visit(this, frame); ast.Command.Visit(this, frame.Expand(extraSize)); if (extraSize > 0) { _emitter.Emit(OpCode.POP, (short)extraSize); } return(null); }
public void visit(LetCommand that) { Console.WriteLine("{"); // note: function declarations should be output before the first line foreach (Declaration declaration in that.Declarations) { declaration.visit(this); } that.Command.visit(this); Console.WriteLine("}"); }
public void visit(LetCommand that) { string name = CreateName(); _symbols.EnterScope(name); foreach (Declaration declaration in that.Declarations) { declaration.visit(this); } that.Command.visit(this); _symbols.LeaveScope(name); }