コード例 #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);
        }
コード例 #2
0
ファイル: ExpressionToken.cs プロジェクト: lulzzz/BraneCloud
        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;
        }