Exemplo n.º 1
0
        private Exp ParseLiteral()
        {
            ExpLiteral expb = (ExpLiteral)Tape.Current;

            MoveNext();
            //expb.SetContextExp(this.expContext);
            return(expb.Analy());
        }
Exemplo n.º 2
0
        Exp parseLiteral()
        {
            ExpLiteral literalex = new ExpLiteral();

            literalex.LiteralToken = tape.Current;
            tape.MoveNext();
            return(literalex);
        }
Exemplo n.º 3
0
        private ExpLiteral parseLiteral()
        {
            var        literalToken = (LexTokenLiteral)(tape.Current);
            ExpLiteral literalex    = new ExpLiteral(expContext, literalToken);

            //literalex.SetContextExp(this.expContext);
            tape.MoveNext();
            return(literalex);
        }
Exemplo n.º 4
0
        private Exp ParseChain()
        {
            ExpChain expChain = new ExpChain(expContext);

            while (tape.HasCurrent)
            {
                if (tape.Current.IsKind(TokenKindSymbol.LBS))
                {
                    ExpBracket subExp = parseBracket();
                    expChain.Add(subExp);
                }
                else if (tape.Current.IsKind(TokenKindSymbol.RBS))
                {
                    break;
                    //tape.error("多余的右括号");
                    //tape.MoveNext();
                }
                else if (tape.Current is LexTokenLiteral)
                {
                    ExpLiteral subExp = parseLiteral();
                    expChain.Add(subExp);
                }
                else if (tape.Current.IsKind(
                             TokenKindKeyword.Ident,
                             TokenKindKeyword.Ident,
                             TokenKindKeyword.DE,
                             TokenKindKeyword.DI,
                             TokenKindKeyword.Each,
                             TokenKindKeyword.NewDefault
                             )
                         )
                {
                    LexToken tok = tape.Current;
                    expChain.Add(tok);
                    tape.MoveNext();
                }
                else
                {
                    break;
                }
            }
            if (expChain.SubCount == 0)
            {
                return(null);
            }
            return(expChain);
        }
Exemplo n.º 5
0
 private Exp ParseItemExp()
 {
     if (Tape.Current is ExpBracket)
     {
         ExpBracket expb = (ExpBracket)Tape.Current;
         MoveNext();
         //expb.SetContextExp(this.expContext);
         return(expb.Analy());
     }
     else if (Tape.Current is ExpLiteral)
     {
         ExpLiteral expb = (ExpLiteral)Tape.Current;
         MoveNext();
         //expb.SetContextExp(this.expContext);
         return(expb.Analy());
     }
     throw new CCException();
 }
Exemplo n.º 6
0
        private bool ParseItem()
        {
            if (!Tape.HasCurrent)
            {
                return(false);
            }

            var data = Tape.Current;

            if (featurer.IsDe(data))
            {
                var obj = ParseDe();
                chains.Push(obj);
                return(true);
            }
            else if (featurer.IsNewfault(data))// (cf.IsNewfault)
            {
                var obj = ParseNewfault();
                chains.Push(obj);
                return(true);
                //MoveNext();
                //return false;
            }
            else if (featurer.IsDi(data))//(cf.IsDi)
            {
                var obj = ParseDi();
                chains.Push(obj);
                return(true);
            }
            else if (featurer.IsExp(data))//if (cf.IsExp)
            {
                var obj = ParseItemExp();
                chains.Push(obj);
                return(true);
            }
            else if (featurer.IsLocalVar(data) ||//cf.IsLocalVar
                     featurer.IsLiteral(data) ||//cf.IsLiteral
                     featurer.IsThisProperty(data) ||
                     featurer.IsSuperProperty(data) ||//cf.IsSuperProperty
                     featurer.IsUsedEnumItem(data) ||//cf.IsUsedEnumItem
                     featurer.IsUsedProperty(data) ||// cf.IsUsedProperty
                     featurer.IsParameter(data) ||//cf.IsParameter
                     featurer.IsUsedField(data) ||
                     featurer.IsThisField(data)
                     )
            {
                Exp        exp1           = ParseExpect_Var();
                ExpBracket bracketBracket = WarpExp(exp1);
                chains.Push(bracketBracket);
                return(true);
            }

            else if (featurer.IsThisClassName(data) || featurer.IsImportTypeName(data))
            {
                Exp exp = ParseTypes();
                chains.Push(exp);

                if (exp is ExpTypeBase)
                {
                    if (Tape.HasCurrent)
                    {
                        var data2 = Tape.Current;
                        if (!(featurer.IsDi(data2) || featurer.IsDe(data2)))
                        {
                            var b2 = ParseItem();
                            if (b2)
                            {
                                var nextObj = PeekChains();
                                if ((nextObj is ExpBracket) ||
                                    (nextObj is ExpLiteral) ||
                                    (nextObj is ExpVarBase)
                                    )
                                {
                                    var argExp  = (Exp)PopChains();
                                    var typeExp = (ExpTypeBase)PopChains();
                                    Exp newexp  = ParseToExpNew(typeExp, argExp);
                                    //obj = newexp;
                                    chains.Push(newexp);
                                    return(true);
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
            else if (featurer.IsIdent(data))
            {
                LexTokenText lexToken = (LexTokenText)data;
                if (lexToken.Text == "是" || lexToken.Text == "否")
                {
                    LexTokenLiteral literalToken = new LexTokenLiteral(lexToken.Line, lexToken.Col,
                                                                       lexToken.Text == "是" ? TokenKindLiteral.True : TokenKindLiteral.False, lexToken.Text);
                    ExpLiteral literalExp = new ExpLiteral(this.ExpContext, literalToken);
                    Exp        exp2       = literalExp.Analy();
                    chains.Push(exp2);
                    MoveNext();
                }
                else if (featurer.IsProcNamePart(lexToken.Text))
                {
                    Exp exp = ParseProcNamePart();
                    chains.Push(exp);
                }
                else
                {
                    //ExpErrorToken errorExp = new ExpErrorToken(this.ExpContext, lexToken);
                    //Exp exp1 = errorExp.Analy();
                    ExpLocalVar varExp = new ExpLocalVar(this.ExpContext, lexToken);
                    varExp.IsAssignTo = this.IsAssignTo;
                    Exp        exp1           = varExp.Analy();
                    ExpBracket bracketBracket = WarpExp(exp1);
                    chains.Push(bracketBracket);
                    MoveNext();
                }
                return(true);
            }
            else
            {
                throw new CCException();
            }
            return(true);
        }