Exemplo n.º 1
0
 //------------------------------------------------------------
 // コンストラクタ。
 public EvaluateNode(IExpression aFirstExpr, FunctionCallExpression aFuncExpr)
 {
     mFirstExpr = aFirstExpr;
     mFirstNode = mFirstExpr.CreateEvaluateNode();
     mFuncExpr  = aFuncExpr;
     if (mFuncExpr.mSequenceExpr != null)
     {
         mSeqNode = mFuncExpr.mSequenceExpr.CreateEvaluateNode();
     }
 }
Exemplo n.º 2
0
        //------------------------------------------------------------
        /// <summary>
        /// NewExpression:
        ///   "new" TypePath FunctionCallExpression
        /// </summary>
        /// <returns></returns>
        IExpression parseNewExpression()
        {
            // "new"
            Assert.Check(currentToken().Value == Token.Kind.KeyNew);
            nextToken();

            // TypePath
            TypePath typePath = parseTypePath();

            if (typePath == null)
            {
                return(null);
            }

            // FunctionCallExpression
            FunctionCallExpression funcCallExpr = parseFunctionCallExpression();

            if (funcCallExpr == null)
            {
                return(null);
            }

            return(new NewExpression(typePath, funcCallExpr));
        }
Exemplo n.º 3
0
 //------------------------------------------------------------
 // コンストラクタ。
 public NewExpression(TypePath aTypePath, FunctionCallExpression aFuncCallExpr)
 {
     mTypePath     = aTypePath;
     mFuncCallExpr = aFuncCallExpr;
 }
Exemplo n.º 4
0
        //------------------------------------------------------------
        /// <summary>
        /// PostfixExpression:
        ///   PrimaryExpression (PostfixOperator)*
        ///
        /// PostfixOperator:
        ///   "++"
        ///   | "--"
        ///   | IndexExpression
        ///   | FunctionCallExpression
        ///   | "." Identifier # ChildIdentExpression
        /// </summary>
        /// <returns></returns>
        IExpression parsePostfixExpression()
        {
            IExpression firstExpr = parsePrimaryExpression();

            while (firstExpr != null)
            {
                PostfixExpression.OpKind opKind = PostfixExpression.OpKind.Unknown;

                // OpTokenがある式
                Token opToken = currentToken();
                if (currentToken().Value == Token.Kind.OpPlusPlus)
                {// "++"
                    opKind = PostfixExpression.OpKind.Inc;
                    nextToken();
                }
                else if (currentToken().Value == Token.Kind.OpMinusMinus)
                {// "--"
                    opKind = PostfixExpression.OpKind.Dec;
                    nextToken();
                }
                if (opKind != PostfixExpression.OpKind.Unknown)
                {
                    firstExpr = new PostfixExpression(opToken, opKind, firstExpr);
                }

                // OpTokenがない式
                if (currentToken().Value == Token.Kind.OpLBracket)
                {// IndexExpression
                    IndexExpression expr = parseIndexExpression();
                    if (expr == null)
                    {
                        return(null);
                    }
                    return(new PostfixExpression(firstExpr, expr));
                }
                else if (currentToken().Value == Token.Kind.OpLParen)
                {// FunctionCallExpression
                    FunctionCallExpression expr = parseFunctionCallExpression();
                    if (expr == null)
                    {
                        return(null);
                    }
                    return(new PostfixExpression(firstExpr, expr));
                }
                else if (currentToken().Value == Token.Kind.OpDot)
                {// ChildIdentExpression
                    nextToken();
                    if (currentToken().Value != Token.Kind.Identifier)
                    {
                        setErrorKind(ErrorKind.POSTFIX_EXPRESSION_IDENTIFIER_EXPECTED);
                        return(null);
                    }
                    ChildIdentExpression expr = new ChildIdentExpression(new Identifier(currentToken()));
                    nextToken();
                    return(new PostfixExpression(firstExpr, expr));
                }
                else
                {
                    return(firstExpr);
                }
            }

            return(firstExpr);
        }
Exemplo n.º 5
0
 //------------------------------------------------------------
 // FunctionCallのコンストラクタ。
 public PostfixExpression(IExpression aFirstExpr, FunctionCallExpression aFuncCallExpr)
 {
     mExprKind         = ExprKind.FunctionCallExpr;
     mFirstExpr        = aFirstExpr;
     mFunctionCallExpr = aFuncCallExpr;
 }