Example #1
0
 public MemberAccessExpression(ExpressionNode left, ExpressionNode right, TokenId qualifierKind, bool isMember)
     : base(left.RelatedToken)
 {
     _left = left;
     _right = right;
     _isMember = isMember;
 }
Example #2
0
 public ConditionalExpression(ExpressionNode test, ExpressionNode left, ExpressionNode right)
     : base(test.RelatedToken)
 {
     this._test = test;
     this._left = left;
     this._right = right;
 }
Example #3
0
 public BinaryExpression(TokenId op, ExpressionNode left, ExpressionNode right)
     : base(left.RelatedToken)
 {
     _op = op;
     _left = left;
     _right = right;
 }
Example #4
0
 public ElementAccessExpression(ExpressionNode leftSide, ExpressionList expressions)
     : base(leftSide.RelatedToken)
 {
     _leftSide = leftSide;
     _expressions = expressions;
 }
Example #5
0
 public ElementAccessExpression(ExpressionNode leftSide)
     : base(leftSide.RelatedToken)
 {
     _leftSide = leftSide;
 }
Example #6
0
 public ExpressionStatement(ExpressionNode expression)
     : base(expression.RelatedToken)
 {
     _expression = expression;
 }
Example #7
0
 public PostDecrementExpression(ExpressionNode expression)
     : base(expression.RelatedToken)
 {
     _expression = expression;
 }
Example #8
0
 public ParenthesizedExpression(ExpressionNode expression)
     : base(expression.RelatedToken)
 {
     _expression = expression;
 }
Example #9
0
 public UnaryExpression(TokenId op, ExpressionNode child, Token relatedToken)
     : base(relatedToken)
 {
     _op = op;
     _child = child;
 }
Example #10
0
        private ExpressionNode ParseSubexpression(int precBound, ExpressionNode left)
        {
            while (true)
            {
                int curPrec = _precedence[(int)_curtok.TokenId];
                if (curPrec < precBound) break;

                int associativity = ASSOC_LEFT;
                TokenId curOp = _curtok.TokenId;
                switch (curOp)
                {
                    case TokenId.Equal:
                    case TokenId.PlusEqual:
                    case TokenId.MinusEqual:
                    case TokenId.StarEqual:
                    case TokenId.SlashEqual:
                    case TokenId.PercentEqual:
                    case TokenId.QuestionQuestion:
                        {
                            associativity = ASSOC_RIGHT;
                            goto case TokenId.Percent;		// "FALL THROUGH"
                        }
                    case TokenId.Greater:
                    case TokenId.Or:
                    case TokenId.And:
                    case TokenId.EqualEqual:
                    case TokenId.NotEqual:
                    case TokenId.Less:
                    case TokenId.LessEqual:
                    case TokenId.GreaterEqual:
                    case TokenId.Plus:
                    case TokenId.Minus:
                    case TokenId.Star:
                    case TokenId.Slash:
                    case TokenId.Percent:
                        {
                            Advance();
                            left = new BinaryExpression(curOp, left, ParseSubexpression(curPrec + associativity));
                            break;
                        }
                    case TokenId.PlusPlus:								// postfix
                        {
                            Advance();
                            left = new PostIncrementExpression(left);
                            break;
                        }
                    case TokenId.MinusMinus:							// postfix
                        {
                            Advance();
                            left = new PostDecrementExpression(left);
                            break;
                        }
                    case TokenId.Question:
                        {
                            Advance();
                            ExpressionNode node = ParseExpression();
                            AssertAndAdvance(TokenId.Colon);
                            left = new ConditionalExpression(left, node, ParseExpression());
                            break;
                        }

                    case TokenId.LParen:								// invocation
                        Advance();
                        left = new InvocationExpression(left, ParseArgumentList());
                        AssertAndAdvance(TokenId.RParen);
                        break;

                    case TokenId.LBracket:								// element access
                        Advance();
                        left = new ElementAccessExpression(left, ParseExpressionList());
                        AssertAndAdvance(TokenId.RBracket);
                        break;

                    case TokenId.Dot:
                        left = ParseMemberAccess(left);
                        break;

                    default:
                        throw new ParseException("Unexpected token");
                }
            }

            return left;
        }
Example #11
0
        private ExpressionNode ParseMemberAccess(ExpressionNode left)
        {
            TokenId qualifierKind = _curtok.TokenId;

            AssertAndAdvance(TokenId.Dot);

            if (_curtok.TokenId != TokenId.Ident)
            {
                throw new ParseException("Right side of member access must be identifier");
            }

            return new MemberAccessExpression(left, ParseMember(), qualifierKind, _curtok.TokenId == TokenId.LParen);
        }
Example #12
0
 public ExpressionStatement(ExpressionNode expression)
     : base(expression.RelatedToken)
 {
     _expression = expression;
 }
Example #13
0
 public ParenthesizedExpression(ExpressionNode expression)
     : base(expression.RelatedToken)
 {
     _expression = expression;
 }
Example #14
0
 public NameExpressionNode(ExpressionNode expression, Token relatedToken)
     : base(relatedToken)
 {
     _name = relatedToken.Data;
     _expression = expression;
 }