/// <summary>
        ///     Determine if contains keyword and if it's possible to convert non-keyword types to keyword type
        ///     ie. monday = 4 or month in (may,...,december)
        /// </summary>
        /// <param name="left">Node do check.</param>
        /// <param name="right">Node do check.</param>
        /// <returns>true if can be generalized, else false.</returns>
        private static bool CanBeGeneralized(RdlSyntaxNode left, RdlSyntaxNode right)
        {
            if (right.Token.Value == null)
            {
                return(false);
            }

            if (right.Token.Value.IsKeyword() &&
                RdlMetadata.IsTypePossibleToConvert(left.ReturnType, typeof(int)))
            {
                return(true);
            }

            if (left.Token.Value == null)
            {
                return(false);
            }

            if (left.Token.Value.IsKeyword() &&
                RdlMetadata.IsTypePossibleToConvert(typeof(int), right.ReturnType))
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
 public DebuggerTrap(RdlSyntaxNode node, ExpressionState state, OnExpressionBegin expBeginCallback,
                     OnExpressionEnd expEndCallback)
 {
     _node             = node;
     _state            = state;
     _expBeginCallback = expBeginCallback;
     _expEndCallback   = expEndCallback;
 }
Exemple #3
0
 public ModuloNode(RdlSyntaxNode left, RdlSyntaxNode right)
     : base(left, right)
 {
 }
Exemple #4
0
 /// <inheritdoc />
 /// <summary>
 ///     Create instance of tree enumerator
 /// </summary>
 /// <param name="node">Abstract Syntax Tree</param>
 public ArythmeticEnumerator(RdlSyntaxNode node)
     : base(node)
 {
     Stack.Push(new VisitationState(Root));
 }
Exemple #5
0
 /// <summary>
 ///     Initialize object.
 /// </summary>
 /// <param name="root">Root element where enumeration will start from.</param>
 public KeywordEnumerator(RdlSyntaxNode root)
     : base(root)
 {
     Stack.Push(new VisitationState(root));
 }
Exemple #6
0
 /// <summary>
 ///     Initialize object
 /// </summary>
 /// <param name="node">Node that has to be tracked</param>
 public VisitationState(RdlSyntaxNode node)
 {
     Node = node;
     ToVisitDescendantIndex = 0;
     WasVisitedOnce         = false;
 }
Exemple #7
0
 public FSlashNode(RdlSyntaxNode left, RdlSyntaxNode right)
     : base(left, right)
 {
 }
Exemple #8
0
 /// <summary>
 ///     Initialize object.
 /// </summary>
 /// <param name="root">Root node where enumeration will start from.</param>
 protected EnumeratorBase(RdlSyntaxNode root)
 {
     Root = root;
 }
Exemple #9
0
 public StarNode(RdlSyntaxNode left, RdlSyntaxNode right)
     : base(left, right)
 {
 }
Exemple #10
0
 public CommaNode(RdlSyntaxNode left, RdlSyntaxNode right)
     : base(left, right)
 {
 }
Exemple #11
0
 public AddNode(RdlSyntaxNode left, RdlSyntaxNode right)
     : base(left, right)
 {
 }
Exemple #12
0
        private RdlSyntaxNode ComposeArithmeticOperators(Precendence precendence)
        {
            RdlSyntaxNode node = null;

            switch (precendence)
            {
            case Precendence.Level1:
            {
                node = ComposeArithmeticOperators(Precendence.Level2);
                while (IsArithmeticOperator(Current, Precendence.Level1))
                {
                    switch (Current.TokenType)
                    {
                    case StatementType.Star:
                        Consume(StatementType.Star);
                        node = new StarNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.FSlash:
                        Consume(StatementType.FSlash);
                        node = new FSlashNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.Mod:
                        Consume(StatementType.Mod);
                        node = new ModuloNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.In:
                        Consume(StatementType.In);
                        node = new InNode(node, ComposeArgs());
                        break;

                    case StatementType.NotIn:
                        Consume(StatementType.NotIn);
                        node = new NotInNode(node, ComposeArgs());
                        break;
                    }
                }
                break;
            }

            case Precendence.Level2:
            {
                node = ComposeArithmeticOperators(Precendence.Level3);
                while (IsArithmeticOperator(Current, Precendence.Level2))
                {
                    switch (Current.TokenType)
                    {
                    case StatementType.Plus:
                        Consume(StatementType.Plus);
                        node = new AddNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.Hyphen:
                        Consume(StatementType.Hyphen);
                        node = new HyphenNode(node, ComposeBaseTypes());
                        break;
                    }
                }
                break;
            }

            case Precendence.Level3:
                node = ComposeBaseTypes();
                break;
            }
            return(node);
        }