Пример #1
0
        public void TestUnescapeDot()
        {
            String [][] inout = new String[][] {
                new [] { "a", "a" },
                new [] { "", "" },
                new [] { " ", " " },
                new [] { ".", "." },
                new [] { " . .", " . ." },
                new [] { "a\\.", "a." },
                new [] { "\\.a", ".a" },
                new [] { "a\\.b", "a.b" },
                new [] { "a.b", "a.b" },
                new [] { ".a", ".a" },
                new [] { "a.", "a." },
                new [] { "a\\.\\.b", "a..b" },
                new [] { "a\\..\\.b", "a...b" },
                new [] { "a.\\..b", "a...b" },
                new [] { "a\\..b", "a..b" },
                new [] { "a.b\\.c", "a.b.c" },
            };

            for (int i = 0; i < inout.Length; i++)
            {
                String @in      = inout[i][0];
                String expected = inout[i][1];
                Assert.AreEqual(expected, ASTUtil.UnescapeDot(@in), "for input " + @in);
            }
        }
Пример #2
0
        /// <summary>
        /// Resolve "table" and "table.property" when nested-property, not chainable
        /// </summary>
        public static ExprTableAccessNode CheckTableNameGetExprForProperty(TableService tableService, string propertyName)
        {
            // handle "var_name" alone, without chained, like an simple event property
            var index = ASTUtil.UnescapedIndexOfDot(propertyName);

            if (index == -1)
            {
                if (tableService.GetTableMetadata(propertyName) != null)
                {
                    return(new ExprTableAccessNodeTopLevel(propertyName));
                }
                return(null);
            }

            // handle "var_name.column", without chained, like a nested event property
            var tableName = ASTUtil.UnescapeDot(propertyName.Substring(0, index));

            if (tableService.GetTableMetadata(tableName) == null)
            {
                return(null);
            }

            // it is a tables's subproperty
            var sub = propertyName.Substring(index + 1);

            return(new ExprTableAccessNodeSubprop(tableName, sub));
        }
Пример #3
0
        public static Pair <ExprTableAccessNode, IList <ExprChainedSpec> > CheckTableNameGetLibFunc(
            TableService tableService,
            EngineImportService engineImportService,
            LazyAllocatedMap <ConfigurationPlugInAggregationMultiFunction, PlugInAggregationMultiFunctionFactory> plugInAggregations,
            string engineURI,
            string classIdent,
            IList <ExprChainedSpec> chain)
        {
            var index = ASTUtil.UnescapedIndexOfDot(classIdent);

            // handle special case "table.Keys()" function
            if (index == -1)
            {
                if (tableService.GetTableMetadata(classIdent) == null)
                {
                    return(null); // not a table
                }
                var funcName = chain[1].Name;
                if (funcName.ToLowerInvariant().Equals("keys"))
                {
                    var subchain = chain.SubList(2, chain.Count);
                    var node     = new ExprTableAccessNodeKeys(classIdent);
                    return(new Pair <ExprTableAccessNode, IList <ExprChainedSpec> >(node, subchain));
                }
                else
                {
                    throw ASTWalkException.From(
                              "Invalid use of variable '" + classIdent + "', unrecognized use of function '" + funcName +
                              "', expected 'keys()'");
                }
            }

            // Handle "table.property" (without the variable[...] syntax since this is ungrouped use)
            var tableName = ASTUtil.UnescapeDot(classIdent.Substring(0, index));

            if (tableService.GetTableMetadata(tableName) == null)
            {
                return(null);
            }

            // this is a table access expression
            var sub = classIdent.Substring(index + 1);

            return(HandleTable(engineImportService, plugInAggregations, engineURI, tableName, sub, chain));
        }