GetOperatorType() public static method

public static GetOperatorType ( string text ) : OperatorType
text string
return OperatorType
Ejemplo n.º 1
0
        public override bool Parse(ParseContext context, IAstNode parent)
        {
            Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Operator);

            OperatorType  = TokenOperator.GetOperatorType(context.TextProvider.GetText(context.Tokens.CurrentToken));
            OperatorToken = RParser.ParseToken(context, this);
            Associativity = OperatorAssociativity.GetAssociativity(OperatorType);

            // If operator is preceded by an operator, it is then unary
            // Look back two tokens since operator parsing already consumed its token.
            if (IsUnary || IsUnaryOperator(context.Tokens, context.TextProvider, OperatorType, -2))
            {
                OperatorType  = Operator.GetUnaryForm(OperatorType);
                IsUnary       = true;
                Associativity = Associativity.Right;
            }
            return(base.Parse(context, parent));
        }
Ejemplo n.º 2
0
        public override bool Parse(ParseContext context, IAstNode parent)
        {
            Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Operator);

            _operatorType      = TokenOperator.GetOperatorType(context.TextProvider.GetText(context.Tokens.CurrentToken));
            this.OperatorToken = RParser.ParseToken(context, this);
            this.Association   = OperatorAssociation.GetAssociation(_operatorType);

            bool isUnary;

            _precedence = this.GetCurrentOperatorPrecedence(context, this.OperatorType, out isUnary);

            if (!_isUnary)
            {
                _isUnary = isUnary;
            }

            return(base.Parse(context, parent));
        }