Example #1
0
        public void AddVariable(IdentifierToken variableToken, IdentifierToken typeToken, SymVar.SymLocTypeEnum locType,
                                SymConst value = null)
        {
            var type = FindType(typeToken.Value);

            if (type == null)
            {
                throw new TypeNotFoundException(typeToken.Lexeme, typeToken.Line, typeToken.Column);
            }

            RequireSymbolRewritable(variableToken);
            //type check for initial value must be performed earlier. i.e. in parser.
            var symVar = new SymVar(variableToken.Value, type, value, locType);

            _stack.Peek().Add(symVar);
        }