Esempio n. 1
0
        /// <summary>
        /// Dump out abstract syntax tree for a given expression
        /// </summary>
        /// <param name="args"> array with one element, containing the expression string </param>
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                Console.Error.WriteLine("usage: java " + typeof(Builder).FullName + " <expression string>");
                Environment.Exit(1);
            }
            PrintWriter @out = new PrintWriter(System.out);
            Tree        tree = null;

            try
            {
                tree = (new Builder(Feature.METHOD_INVOCATIONS)).build(args[0]);
            }
            catch (TreeBuilderException e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }
            NodePrinter.dump(@out, tree.Root);
            if (!tree.FunctionNodes.GetEnumerator().hasNext() && !tree.IdentifierNodes.GetEnumerator().hasNext())
            {
                ELContext context = new ELContextAnonymousInnerClass();
                @out.print(">> ");
                try
                {
                    @out.println(tree.Root.getValue(new Bindings(null, null), context, null));
                }
                catch (ELException e)
                {
                    @out.println(e.Message);
                }
            }
            @out.flush();
        }
Esempio n. 2
0
 /// <summary>
 /// Print the parse tree. </summary>
 /// <param name="writer"> </param>
 public void dump(PrintWriter writer)
 {
     NodePrinter.dump(writer, node);
 }