Example #1
0
        //------------------------------------------------------------
        /// <summary>
        /// IdentityExpression:
        ///   EqualityExpression (IdentityOperator EqualityExpression )*
        /// </summary>
        /// <returns></returns>
        IExpression parseIdentityExpression()
        {
            // 第1式
            IExpression firstExpr = parseEqualityExpression();

            if (firstExpr == null)
            {// エラー
                return(null);
            }
            for (BinaryOpExpression.OpKind opKind = parseIdentityOperator();
                 opKind != BinaryOpExpression.OpKind.Unknnown;
                 opKind = parseEqualityOperator()
                 )
            {
                nextToken();

                // 第2式
                IExpression secondExpr = parseEqualityExpression();
                if (secondExpr == null)
                {// エラー
                    return(null);
                }

                // 第1式を更新
                firstExpr = new BinaryOpExpression(opKind, firstExpr, secondExpr);
            }
            return(firstExpr);
        }
Example #2
0
        //------------------------------------------------------------
        /// <summary>
        /// LogicalAndExpression:
        ///   BitwiseOrExpression (LogicalAndOperator BitwiseOrExpression)*
        /// </summary>
        /// <returns></returns>
        IExpression parseLogicalAndExpression()
        {
            // 第1式
            IExpression firstExpr = parseBitwiseOrExpression();

            if (firstExpr == null)
            {// エラー
                return(null);
            }
            while (currentToken().Value == Token.Kind.OpAndAnd)
            {
                nextToken();

                // 第2式
                IExpression secondExpr = parseBitwiseOrExpression();
                if (secondExpr == null)
                {// エラー
                    return(null);
                }

                // 第1式を更新
                firstExpr = new BinaryOpExpression(BinaryOpExpression.OpKind.LogicalAnd, firstExpr, secondExpr);
            }
            return(firstExpr);
        }
Example #3
0
        //------------------------------------------------------------
        /// <summary>
        /// AdditiveExpression:
        ///   MultiplicativeExpression (AdditiveOperator MultiplicativeExpression)*
        /// </summary>
        /// <returns></returns>
        IExpression parseAdditiveExpression()
        {
            // 第1式
            IExpression firstExpr = parseMultiplicativeExpression();

            if (firstExpr == null)
            {// エラー
                return(null);
            }
            for (BinaryOpExpression.OpKind opKind = parseAdditiveOperator();
                 opKind != BinaryOpExpression.OpKind.Unknnown;
                 opKind = parseAdditiveOperator()
                 )
            {
                nextToken();

                // 第2式
                IExpression secondExpr = parseMultiplicativeExpression();
                if (secondExpr == null)
                {// エラー
                    return(null);
                }

                // 第1式を更新
                firstExpr = new BinaryOpExpression(opKind, firstExpr, secondExpr);
            }
            return(firstExpr);
        }