示例#1
0
        private Exp AnalyWhileExpRaw(ExpRaw rawExp)
        {
            //ExpRaw rawExp = (ExpRaw)ConditionExp;
            //ContextExp context = new ContextExp(this.ProcContext, this);
            //rawExp.SetContext(context);
            List <LexToken> tokens = rawExp.RawTokens; //rawExp.Seg();

            if (tokens.Count > 0)
            {
                var lastIndex = tokens.Count - 1;

                var RepeatToken = tokens[lastIndex];
                if (RepeatToken is LexTokenText && RepeatToken.Text == "重复")//|| TimesToken.IsKeyIdent("次"))
                {
                    tokens.RemoveAt(lastIndex);
                }
                else
                {
                    Errorf(RepeatToken.Position, "循环语句的条件末尾缺少‘重复’");
                }
                //if (RepeatToken.Kind == TokenKindKeyword.Repeat)// == "重复" )//|| RepeatToken.IsKeyIdent("重复"))
                //{
                //    tokens.RemoveAt(lastIndex);
                //}
            }
            Exp exp = ParseAnalyRawExp(rawExp);

            return(exp);
            //ExpParser parser = new ExpParser();
            //Exp exp = parser.Parse(tokens, this.FileContext);
            ////exp.SetContextExp(rawExp.ExpContext);
            //return exp;
        }
示例#2
0
        private Exp AnalyRepeateExpRaw(ExpRaw rawExp)
        {
            //ExpRaw rawExp = (ExpRaw)TimesExp;
            //ContextExp context = new ContextExp(this.ProcContext, this);
            //rawExp.SetContext(context);
            List <LexToken> tokens = rawExp.RawTokens;

            if (tokens.Count > 0)
            {
                var lastIndex  = tokens.Count - 1;
                var TimesToken = tokens[lastIndex];
                if (TimesToken is LexTokenText && TimesToken.Text == "次")//|| TimesToken.IsKeyIdent("次"))
                {
                    tokens.RemoveAt(lastIndex);
                }
                else
                {
                    Errorf(TimesToken.Position, "循环语句的条件末尾缺少‘次’");
                }
            }
            //var lastIndex = tokens.Count - 1;
            //tokens.RemoveAt(lastIndex);
            //ExpParser parser = new ExpParser();
            //Exp exp = parser.Parse(tokens, this.FileContext);
            //exp.SetContext(rawExp.ExpContext);
            Exp exp = ParseAnalyRawExp(rawExp);

            return(exp);
        }
示例#3
0
文件: Stmt.cs 项目: pyzh/ZLanguage3
        protected virtual Exp ParseAnalyRawExp(ExpRaw expRaw)
        {
            ExpRawParser rawparser = new ExpRawParser();
            ContextExp   context   = new ContextExp(this.ProcContext, this);
            Exp          exp2      = rawparser.Parse(expRaw, context);
            Exp          exp3      = exp2.Analy();

            return(exp3);
        }
示例#4
0
            private LexTokenText GetDimTypeToken(ExpRaw ValueExp)
            {
                if (ValueExp == null)
                {
                    return(null);
                }
                if (ValueExp.RawTokens.Count == 0)
                {
                    return(null);
                }
                LexToken token = ValueExp.RawTokens[0];

                if (!(token is LexTokenText))
                {
                    return(null);
                }
                LexTokenText result = (LexTokenText)token;

                return(result);
            }