Ejemplo n.º 1
0
        public static bool Run(TexlNode node)
        {
            ChainTrackerVisitor visitor = new ChainTrackerVisitor();

            node.Accept(visitor);
            return(visitor._usesChains);
        }
Ejemplo n.º 2
0
        // Public entry point for prettyprinting TEXL parse trees
        public static string PrettyPrint(TexlNode node)
        {
            Contracts.AssertValue(node);

            TexlPretty pretty = new TexlPretty();

            return(string.Concat(node.Accept(pretty, Precedence.None)));
        }
Ejemplo n.º 3
0
        // Public entry point for prettyprinting TEXL parse trees
        public static string Print(TexlNode node, TexlBinding binding = null)
        {
            Contracts.AssertValue(node);

            var pretty = new StructuralPrint(binding);

            return(string.Concat(node.Accept(pretty, Precedence.None)));
        }
Ejemplo n.º 4
0
        public static HashSet <string> FindDependencies(TexlNode node, TexlBinding binding)
        {
            var v = new DependencyFinder
            {
                _binding = binding
            };

            node.Accept(v);
            return(v._vars);
        }
Ejemplo n.º 5
0
        public static BinderNodesVisitor Run(TexlNode node)
        {
            Contracts.AssertValue(node);

            var instance = new BinderNodesVisitor(node);

            node.Accept(instance);

            return(instance);
        }
Ejemplo n.º 6
0
        public static TexlNode Run(TexlNode node, int cursorPosition)
        {
            Contracts.AssertValue(node);
            Contracts.Assert(cursorPosition >= 0);

            var visitor = new FindNodeVisitor(cursorPosition);

            node.Accept(visitor);
            return(visitor._result);
        }
Ejemplo n.º 7
0
        private LazyList <string> PrettyBinary(string strOp, Precedence parentPrecedence, Precedence precLeft, Precedence precRight, TexlNode left, TexlNode right)
        {
            Contracts.AssertNonEmpty(strOp);

            return(ApplyPrecedence(
                       parentPrecedence,
                       precLeft,
                       left.Accept(this, precLeft)
                       .With(strOp)
                       .With(right.Accept(this, precRight))));
        }
Ejemplo n.º 8
0
        // Public entry point for prettyprinting TEXL parse trees
        public static string Format(TexlNode node, SourceList before, SourceList after, string script)
        {
            Contracts.AssertValue(node);

            var pretty   = new PrettyPrintVisitor(script);
            var preRegex = string.Concat(pretty.CommentsOf(before)
                                         .With(node.Accept(pretty, new Context(0)))
                                         .With(pretty.CommentsOf(after)))
                           .Replace("\n\n", "\n");

            return(new Regex(@"\n +(\n +)").Replace(preRegex, (Match match) => match.Groups[1].Value));
        }