While.SymbolTable.DefineVariable C# (CSharp) Method

DefineVariable() public method

public DefineVariable ( string name ) : void
name string
return void
        public void DefineVariable(string name)
        {
            if (_stack.Count == 0) {
                throw new WhileException("Stack is empty, cannot define variable {0}", name);
            }
            if (_stack[_stack.Count - 1].ContainsKey(name)) {
                throw new WhileException("Variable {0} is already defined in this scope!", name);
            }
            _stack[_stack.Count - 1].Add(name, _nr);
            _nr++;
        }