示例#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);
        }
示例#2
0
 public SymVar(string name, SymType type, SymConst initialValue, SymLocTypeEnum locType)
     : base(name, type, locType, false)
 {
     InitialValue       = initialValue;
     InitialStringValue = initialValue?.InitialStringValue;
 }
示例#3
0
 public void AddConst(IdentifierToken constToken, SymConst symConst)
 {
     RequireSymbolRewritable(constToken);
     _stack.Peek().Add(symConst);
 }
示例#4
0
        public SymVar AddVariable(IdentifierToken variableToken, SymType type, SymVar.SymLocTypeEnum varMod, SymConst value = null)
        {
            RequireSymbolRewritable(variableToken);
            //type check for initial value must be performed earlier. i.e. in parser.
            var symVar = new SymVar(variableToken.Value, type, value, varMod);

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