コード例 #1
0
        //обработка инструкции set
        private void Set()
        {
            mCurrentLex = mLexer.GetLex();
            CheckLexType(mCurrentLex, LexTypes.INDENT);
            string varName = mCurrentLex.Value;

            mCurrentLex = mLexer.GetLex();
            CheckLexType(mCurrentLex, LexTypes.DIGIT);
            int val = Int32.Parse(mCurrentLex.Value);

            if (!mInnerView.Variables.ContainsKey(varName))
            {
                mInnerView.Variables.Add(varName, new Variable {
                    Init = false
                });
                if (ExpectToDefVars.Contains(varName))
                {
                    ExpectToDefVars.Remove(varName);
                }
            }

            Instructions.Add(new SetInst(varName, val, mCurrentLex.LineNo));

            EndLine();
        }
コード例 #2
0
        //обработка инструкции print
        private void Print()
        {
            mCurrentLex = mLexer.GetLex();
            CheckLexType(mCurrentLex, LexTypes.INDENT);
            if (!mInnerView.Variables.ContainsKey(mCurrentLex.Value))
            {
                if (!ExpectToDefVars.Contains(mCurrentLex.Value))
                {
                    ExpectToDefVars.Add(mCurrentLex.Value);
                }
            }

            Instructions.Add(new PrintInst(mCurrentLex.Value, mCurrentLex.LineNo));

            EndLine();
        }