public virtual void Visit(VariableDeclarationSequence node) { }
public Block(VariableDeclarationSequence vars, StatementSequence stmts) { AddChild(vars); AddChild(stmts); }
void VarDec(VariableDeclarationSequence vars) { Expect(16); int sl = t.line; int sc = t.col; int el = la.line; int ec = la.col+la.val.Length; Expect(1); if (SymbolTable.IsDeclaredInCurrentScope(t.val)) { errors.SemErr(t.line, t.col, string.Format("Variable '{0}' is already declared in this scope", t.val)); } else if (SymbolTable.IsInScope(t.val)) { errors.Warning(t.line, t.col, string.Format("Variable '{0}' hides variable with same name in outer block",t.val)); SymbolTable.DefineVariable(t.val); } else { SymbolTable.DefineVariable(t.val); } VariableDeclaration vd = new VariableDeclaration(new Variable(t.val)); vd.AddSequencePoint(sl,sc,el,ec); vars.AddVariableDeclaration(vd); Expect(11); }
void VarDecStmt(out VariableDeclarationSequence vars) { vars = new VariableDeclarationSequence(); VarDec(vars); while (la.kind == 16) { VarDec(vars); } }
void BlockStmt(out Statement block) { Expect(3); if (Options.BookVersion) { errors.SemErr(t.line, t.col, "Variable declarations are only allowed when using the /coursesyntax switch. Type 'wc.exe /help' for more information"); While.Environment.Exit(1); } VariableDeclarationSequence vars = new VariableDeclarationSequence(); SymbolTable.PushScope(); int sl = t.line; int sc = t.col; int el = t.line; int ec = t.col+t.val.Length; if (la.kind == 16) { VarDecStmt(out vars); } StatementSequence statements; StmtSeq(out statements); Expect(4); block = new Block(vars, statements); block.AddSequencePoint(sl,sc,el,ec); block.AddSequencePoint(t); SymbolTable.PopScope(); }