public virtual void Visit(VariableDeclaration node) { }
public void AddVariableDeclaration(VariableDeclaration vd) { AddChild(vd); }
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); }