Example #1
0
        public void AddTernaryTokenMatcher(ITokenMatcher matcher1, ITokenMatcher matcher2, int precedence, OperatorAssociativity associativity, TokenEvaluator tokenEvaluator)
        {
            ExpressionTokenMatcher root = new ExpressionTokenMatcher(null, TokenType.TernaryOperator, tokenEvaluator);

            ExpressionTokenMatcher partial1 = new ExpressionTokenMatcher(matcher1, TokenType.TernaryOperator1, precedence, associativity, null);
            ExpressionTokenMatcher partial2 = new ExpressionTokenMatcher(matcher2, TokenType.TernaryOperator1, precedence, associativity, null);

            partial1.Root = root;
            partial2.Root = root;

            AddTokenMatcher(partial1);
            AddTokenMatcher(partial2);
        }
        public ExpressionToken(ExpressionTokenMatcher tokenMatcher, string text) : base(tokenMatcher, text)
        {
            switch (tokenMatcher.TokenType)
            {
                case TokenType.TernaryOperator: _numTerms = 3; break;
                case TokenType.UnaryOperator: _numTerms = 1; break;
                case TokenType.Operator: _numTerms = 2; break;
            }

            _precedence = tokenMatcher.Precedence;
            _associativity = tokenMatcher.Associativity;
            _tokenType = tokenMatcher.TokenType;
            _evaluator = tokenMatcher.Evaluator;
        }
Example #3
0
        public ExpressionToken(ExpressionTokenMatcher tokenMatcher, string text) : base(tokenMatcher, text)
        {
            switch (tokenMatcher.TokenType)
            {
            case TokenType.TernaryOperator: _numTerms = 3; break;

            case TokenType.UnaryOperator: _numTerms = 1; break;

            case TokenType.Operator: _numTerms = 2; break;
            }

            _precedence    = tokenMatcher.Precedence;
            _associativity = tokenMatcher.Associativity;
            _tokenType     = tokenMatcher.TokenType;
            _evaluator     = tokenMatcher.Evaluator;
        }