Пример #1
0
        protected void onInput(Statement s)
        {
            List <Expression> varList = s.m_expressList;
            string            input   = null;

            foreach (Expression exp in varList)
            {
                input = m_apiCall.Input();
                BaseData dat = BaseData.Parser(input);

                // 转换为字符串
                if (exp.m_symbolName.EndsWith("$"))
                {
                    dat.Convert(BaseData.TYPE_STRING);
                }

                if (exp.m_type == Expression.EXP_SYMBOL)
                {
                    VarSymbol symbol = m_symbolTable.ResolveVar(exp.m_symbolName);
                    symbol.VALUE = dat;
                }
                else if (exp.m_type == Expression.EXP_ARRAY_SYMBOL)
                {
                    List <int>  indexs    = expressListToIndexs(exp.m_funcParams);
                    ArraySymbol arrSymbol = m_symbolTable.ResolveArray(exp.m_symbolName, indexs);
                    arrSymbol.SetValue(indexs, dat);
                }
                else
                {
                    throw new ErrorCode(ErrorCode.ERROR_CODE_02);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// assignment
        /// </summary>
        /// <param name="s"></param>
        protected void doAssign(Statement s)
        {
            // calculate the expression value
            BaseData dat = calculateExp(s.m_exp).m_value;

            if (s.m_expressList == null)
            {
                VarSymbol symbol = m_symbolTable.ResolveVar(s.m_symbol);
                symbol.VALUE = dat;
            }
            else
            {
                List <int>  indexs    = expressListToIndexs(s.m_expressList);
                ArraySymbol arrSymbol = m_symbolTable.ResolveArray(s.m_symbol, indexs);
                arrSymbol.SetValue(indexs, dat);
            }
        }