Ejemplo n.º 1
0
        public Expression ParseMemberExpression()
        {
            Expression factor = ParseCallExpression(ParseFactor());

            while (_currentToken.TokenType == AphidTokenType.MemberOperator)
            {
                NextToken();

                Expression exp;

                switch (_currentToken.TokenType)
                {
                case AphidTokenType.Identifier:
                    exp = new IdentifierExpression(_currentToken.Lexeme);
                    NextToken();

                    break;

                case AphidTokenType.String:
                    exp = ParseStringExpression();
                    break;

                case AphidTokenType.LeftBrace:
                    NextToken();
                    exp = new DynamicMemberExpression(ParseExpression());
                    Match(AphidTokenType.RightBrace);
                    break;

                default:
                    throw new AphidParserException(_currentToken);
                }

                factor = ParseCallExpression(new BinaryOperatorExpression(factor, AphidTokenType.MemberOperator, exp));

                if (_currentToken.TokenType == AphidTokenType.definedKeyword)
                {
                    NextToken();

                    return(new UnaryOperatorExpression(AphidTokenType.definedKeyword, factor)
                    {
                        IsPostfix = true
                    });
                }
            }

            return(factor);
        }
Ejemplo n.º 2
0
        public static DynamicMemberExpression Create(
            AphidExpressionContext context_aphidExpressionContext,
            AphidExpression memberExpression_aphidExpression,
            int value_i,
            int value_i1
            )
        {
            DynamicMemberExpression dynamicMemberExpression = new DynamicMemberExpression
                                                                  (context_aphidExpressionContext, memberExpression_aphidExpression);

            ((AphidExpression)dynamicMemberExpression).Index  = value_i;
            ((AphidExpression)dynamicMemberExpression).Length = value_i1;
            return(dynamicMemberExpression);

            // TODO: Edit factory method of DynamicMemberExpression
            // This method should be able to configure the object in all possible ways.
            // Add as many parameters as needed,
            // and assign their values to each field by using the API.
        }
Ejemplo n.º 3
0
        public Expression ParseMemberExpression()
        {
            Expression factor = ParseCallExpression(ParseFactor());

            while (_currentToken.TokenType == AphidTokenType.MemberOperator)
            {
                NextToken();

                Expression exp;

                switch (_currentToken.TokenType)
                {
                    case AphidTokenType.Identifier:
                        exp = new IdentifierExpression(_currentToken.Lexeme);
                        NextToken();
                        break;

                    case AphidTokenType.String:
                        exp = ParseStringExpression();
                        break;

                    case AphidTokenType.LeftBrace:
                        NextToken();
                        exp = new DynamicMemberExpression(ParseExpression());
                        Match(AphidTokenType.RightBrace);
                        break;

                    default:
                        throw new AphidParserException(_currentToken);
                }

                factor = ParseCallExpression(new BinaryOperatorExpression(factor, AphidTokenType.MemberOperator, exp));
            }

            return factor;
        }
Ejemplo n.º 4
0
 private AphidExpression ParseMemberExpression()
 {
     var factor = ParseFactorCallExpression();
     for (
     ; (this._currentToken.TokenType == AphidTokenType.MemberOperator);
     ) {
         NextToken();
         AphidExpression exp = default(AphidExpression);
         if ((this._currentToken.TokenType == AphidTokenType.Identifier)) {
             exp = new IdentifierExpression(this._currentToken.Lexeme);
             NextToken();
         }
         else {
             if ((this._currentToken.TokenType == AphidTokenType.String)) {
                 exp = ParseStringExpression();
             }
             else {
                 if ((this._currentToken.TokenType == AphidTokenType.LeftBrace)) {
                     NextToken();
                     exp = new DynamicMemberExpression(ParseExpression());
                     Match(AphidTokenType.RightBrace);
                 }
                 else {
                     throw new AphidParserException(_currentToken);
                 }
             }
         }
         factor = new BinaryOperatorExpression(factor, AphidTokenType.MemberOperator, exp);
         for (
         ; (this._currentToken.TokenType == AphidTokenType.LeftParenthesis);
         ) {
             NextToken();
             if ((this._currentToken.TokenType == AphidTokenType.RightParenthesis)) {
                 NextToken();
                 factor = new CallExpression(factor);
             }
             else {
                 var args = ParseTuple();
                 Match(AphidTokenType.RightParenthesis);
                 factor = new CallExpression(factor, args);
             }
         }
         if ((this._currentToken.TokenType == AphidTokenType.definedKeyword)) {
             NextToken();
             return new UnaryOperatorExpression(AphidTokenType.definedKeyword, factor, true);
         }
     }
     return factor;
 }