Beispiel #1
0
 internal OperatorToken(
     string text,
     TokenId id,
     int precedence,
     PowerShellBinaryOperator operationDelegate)
     : base(text, id)
 {
     this._precedence        = precedence;
     this._operationDelegate = operationDelegate;
 }
 public AssignmentStatementNode(
     Token operatorToken,
     IAssignableParseTreeNode left,
     ParseTreeNode right)
 {
     this.NodeToken          = operatorToken;
     this._left              = left;
     this._rightHandSide     = right;
     this._operationDelegate = ((OperatorToken)operatorToken).OperationDelegate;
     this.IsVoidable         = true;
 }
Beispiel #3
0
 internal ComparisonToken(
     string text,
     TokenId id,
     int precedence,
     string comparisonName,
     bool ignoreCase,
     PowerShellBinaryOperator operationDelegate)
     : base(text, id, precedence, operationDelegate)
 {
     this._comparisonName = comparisonName;
     this._ignoreCase     = ignoreCase;
     this.BindDelegates(comparisonName, id);
 }
Beispiel #4
0
        protected void BindDelegates(string text, TokenId id)
        {
            switch (id)
            {
            case TokenId.AssignmentOperatorToken:
                switch (text)
                {
                case "+=":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyAdd);
                    return;

                case "-=":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyMinus);
                    return;

                case "*=":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyMultiply);
                    return;

                case "/=":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyDiv);
                    return;

                case "%=":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyMod);
                    return;

                case null:
                    return;

                default:
                    return;
                }

            case TokenId.MultiplyOperatorToken:
                switch (text)
                {
                case "*":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyMultiply);
                    return;

                case "/":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyDiv);
                    return;

                case "%":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyMod);
                    return;

                case null:
                    return;

                default:
                    return;
                }

            case TokenId.ComparisonOperatorToken:
            case TokenId.CaseSensitiveComparisonOperatorToken:
            case TokenId.CaseInsensitiveComparisonOperatorToken:
                ComparisonToken comparisonToken = (ComparisonToken)this;
                if (comparisonToken != null)
                {
                    text = comparisonToken.ComparisonName;
                    if (text == null)
                    {
                        break;
                    }
                }
                switch (text)
                {
                case "-replace":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.ReplaceOperator);
                    return;

                case "-split":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.SplitOperator);
                    return;

                case "-join":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.JoinOperator);
                    return;

                case "-as":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.AsOperator);
                    return;

                case "-isnot":
                case "-is":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.IsOperator);
                    return;

                case "-like":
                case "-notlike":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.LikeOperator);
                    return;

                case "-match":
                case "-notmatch":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.MatchOperator);
                    return;

                default:
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.ComparisonOperators);
                    return;
                }

            case TokenId.LogicalOperatorToken:
                switch (text)
                {
                case "-and":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.andOperator);
                    return;

                case "-or":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.orOperator);
                    return;

                case "-xor":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.xorOperator);
                    return;

                case null:
                    return;

                default:
                    return;
                }

            case TokenId.BitwiseOperatorToken:
                switch (text)
                {
                case "-band":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.bandOperator);
                    return;

                case "-bor":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.borOperator);
                    return;

                case "-bxor":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.bxorOperator);
                    return;

                case null:
                    return;

                default:
                    return;
                }

            case TokenId.AdditionOperatorToken:
                switch (text)
                {
                case "+":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyAdd);
                    return;

                case "-":
                    this._operationDelegate = new PowerShellBinaryOperator(ParserOps.PolyMinus);
                    return;

                case null:
                    return;

                default:
                    return;
                }

            case TokenId.FormatOperatorToken:
                this._operationDelegate = new PowerShellBinaryOperator(ParserOps.formatOperator);
                break;

            case TokenId.RangeOperatorToken:
                this._operationDelegate = new PowerShellBinaryOperator(ParserOps.rangeOperator);
                break;
            }
        }