Dump out abstract syntax tree for a given expression

@param args array with one element, containing the expression string
423492
public static void main(String[] args) {
		if (args.length != 1) {
			System.err.println("usage: java " + Builder.class.getName() + " <expression string>");
			System.exit(1);
		}
		PrintWriter out = new PrintWriter(System.out);
		Tree tree = null;
		try {
			tree = new Builder(Feature.METHOD_INVOCATIONS).build(args[0]);
		} catch (TreeBuilderException e) {
			System.out.println(e.getMessage());
			System.exit(0);
		}
		NodePrinter.dump(out, tree.getRoot());
		if (!tree.getFunctionNodes().iterator().hasNext() && !tree.getIdentifierNodes().iterator().hasNext()) {
			ELContext context = new ELContext() {
				@Override
				public VariableMapper getVariableMapper() {
					return null;
				}
				@Override
				public FunctionMapper getFunctionMapper() {
					return null;
				}
				@Override
				public ELResolver getELResolver() {
					return null;
				}
			};
			out.print(">> ");
			try {
				out.println(tree.getRoot().getValue(new Bindings(null, null), context, null));
			} catch (ELException e) {
				out.println(e.getMessage());
			}
		}
		out.flush();
	}
446514
public static void main(String[] args) {
		final String root = "..";
		final String projectName = "org.eclipse.xtext.xbase";
		final String runtimeProject = root + "/" + projectName;
		final String uiProject = System.getProperty("uiProject", root + "/../xtext-eclipse/" + projectName + ".ui");	
		final boolean backtrack = false;
		final boolean memoize = false;
		final String lineDelimiter = "\n";
		final String fileHeader = "/*******************************************************************************\n" +
			" * Copyright (c) 2010, ${year} itemis AG (http://www.itemis.eu) and others.\n" +
			" * All rights reserved. This program and the accompanying materials\n" +
			" * are made available under the terms of the Eclipse Public License v1.0\n" +
			" * which accompanies this distribution, and is available at\n" +
			" * http://www.eclipse.org/legal/epl-v10.html\n" +
			" *******************************************************************************/";
		final String xbaseGenModel = "platform:/resource/" + projectName + "/model/Xbase.genmodel";
		
		final AntlrOptions antlrOptions = new AntlrOptions();
		antlrOptions.setBacktrack(backtrack);
		antlrOptions.setMemoize(memoize);
		
		@SuppressWarnings("deprecation")
		final XtextGenerator generator = new XtextGenerator() {{
			setConfiguration(new DefaultGeneratorModule() {{
				setProject(new StandardProjectConfig() {{
					setRootPath(root);
					setBaseName(projectName);
					setCreateEclipseMetaData(true);
					BundleProjectConfig eclipsePlugin = getEclipsePlugin();
					eclipsePlugin.setEnabled(true);
					eclipsePlugin.setRoot(uiProject);
				}});
				setCode(new CodeConfig() {{
					setEncoding("ISO-8859-1");
					setLineDelimiter(lineDelimiter);
					setFileHeader(fileHeader);
					setPreferXtendStubs(true);
				}});
			}});

			addLanguage(new XtextGeneratorLanguage() {{
				String fileExtensions = "___xtype";
				
				setGrammarUri("classpath:/org/eclipse/xtext/xbase/Xtype.xtext");
				addReferencedResource(xbaseGenModel);
				setFileExtensions(fileExtensions);
				setGenerateXtendStubs(true);
				addFragment(new GrammarAccessFragment2());
				addFragment(new SerializerFragment2() {{ setGenerateSupportForDeprecatedContextEObject(true); setGenerateXtendStub(false); }} );
				addFragment(new Formatter2Fragment2());
				XtextAntlrGeneratorFragment2 antlr = new XtextAntlrGeneratorFragment2();
				ContentAssistFragment2 contentAssistFragment2 = new ContentAssistFragment2();
				contentAssistFragment2.setGenerateXtendStub(false);
				addFragment(contentAssistFragment2);
				antlr.setOptions(antlrOptions);
				addFragment(antlr);
				XtextAntlrGeneratorComparisonFragment comparison = new XtextAntlrGeneratorComparisonFragment();
				comparison.setOptions(antlrOptions);
				addFragment(comparison);
			}});
			addLanguage(new XtextGeneratorLanguage() {{
				String fileExtensions = "___xbase";
				
				setGrammarUri("classpath:/org/eclipse/xtext/xbase/Xbase.xtext");
				addReferencedResource(xbaseGenModel);
				setFileExtensions(fileExtensions);
				setGenerateXtendStubs(true);
				addFragment(new GrammarAccessFragment2());
				addFragment(new SerializerFragment2() {{ setGenerateSupportForDeprecatedContextEObject(true); setGenerateXtendStub(false); }} );
				addFragment(new ResourceFactoryFragment2());
				XtextAntlrGeneratorFragment2 antlr = new XtextAntlrGeneratorFragment2();
				antlr.setDebugGrammar(true);
				antlr.setOptions(antlrOptions);
				antlr.addAntlrParam("-Xconversiontimeout");
				antlr.addAntlrParam("10000");
				addFragment(antlr);
				ValidatorFragment2 validator = new ValidatorFragment2();
				validator.setInheritImplementation(false);
				validator.setGenerateXtendStub(false);
				validator.setGeneratePropertyPage(false);
				validator.setGenerateDeprecationValidation(false);
				addFragment(validator);
				ImportNamespacesScopingFragment2 scoping = new ImportNamespacesScopingFragment2();
				scoping.setGenerateXtendStub(false);
				addFragment(scoping);
				addFragment(new TypesGeneratorFragment2());
				XbaseGeneratorFragment2 xbase = new XbaseGeneratorFragment2();
				xbase.setGenerateXtendInferrer(false);
				xbase.setUseInferredJvmModel(false);
				xbase.setJdtTypeHierarchy(false);
				addFragment(xbase);
				addFragment(new BuilderIntegrationFragment2());
				addFragment(new Formatter2Fragment2());
				QuickfixProviderFragment2 quickfixProviderFragment2 = new QuickfixProviderFragment2();
				quickfixProviderFragment2.setGenerateXtendStub(false);
				addFragment(quickfixProviderFragment2);
				LabelProviderFragment2 label = new LabelProviderFragment2();
				label.setGenerateStub(false);
				addFragment(label);
				OutlineTreeProviderFragment2 outlineTreeProviderFragment2 = new OutlineTreeProviderFragment2();
				outlineTreeProviderFragment2.setGenerateXtendStub(false);
				addFragment(outlineTreeProviderFragment2);
				ContentAssistFragment2 contentAssistFragment2 = new ContentAssistFragment2();
				contentAssistFragment2.setGenerateXtendStub(false);
				addFragment(contentAssistFragment2);
				XtextAntlrGeneratorComparisonFragment comparison = new XtextAntlrGeneratorComparisonFragment();
				comparison.setOptions(antlrOptions);
				addFragment(comparison);
			}});
			addLanguage(new XtextGeneratorLanguage() {{
				String fileExtensions = "___xbasewithannotations";
				
				setGrammarUri("classpath:/org/eclipse/xtext/xbase/annotations/XbaseWithAnnotations.xtext");
				addReferencedResource(xbaseGenModel);
				setFileExtensions(fileExtensions);
				setGenerateXtendStubs(true);
				addFragment(new GrammarAccessFragment2());
				addFragment(new SerializerFragment2() {{ setGenerateSupportForDeprecatedContextEObject(true); setGenerateXtendStub(false); }} );
				addFragment(new ResourceFactoryFragment2());
				XtextAntlrGeneratorFragment2 antlr = new XtextAntlrGeneratorFragment2();
				antlr.setOptions(antlrOptions);
				antlr.setDebugGrammar(true);
				antlr.addAntlrParam("-Xconversiontimeout");
				antlr.addAntlrParam("10000");
				addFragment(antlr);
				ValidatorFragment2 validator = new ValidatorFragment2();
				validator.setGenerateXtendStub(false);
				validator.setGeneratePropertyPage(false);
				validator.setGenerateDeprecationValidation(false);
				addFragment(validator);
				ImportNamespacesScopingFragment2 scoping = new ImportNamespacesScopingFragment2();
				scoping.setGenerateXtendStub(false);
				addFragment(scoping);
				addFragment(new TypesGeneratorFragment2());
				XbaseGeneratorFragment2 xbase = new XbaseGeneratorFragment2();
				xbase.setGenerateXtendInferrer(false);
				xbase.setUseInferredJvmModel(false);
				xbase.setJdtTypeHierarchy(false);
				addFragment(xbase);
				addFragment(new BuilderIntegrationFragment2());
				addFragment(new Formatter2Fragment2());
				QuickfixProviderFragment2 quickfixProviderFragment2 = new QuickfixProviderFragment2();
				quickfixProviderFragment2.setGenerateXtendStub(false);
				addFragment(quickfixProviderFragment2);
				LabelProviderFragment2 label = new LabelProviderFragment2();
				label.setGenerateStub(false);
				addFragment(label);
				OutlineTreeProviderFragment2 outlineTreeProviderFragment2 = new OutlineTreeProviderFragment2();
				outlineTreeProviderFragment2.setGenerateXtendStub(false);
				addFragment(outlineTreeProviderFragment2);
				ContentAssistFragment2 contentAssistFragment2 = new ContentAssistFragment2();
				contentAssistFragment2.setGenerateXtendStub(false);
				addFragment(contentAssistFragment2);
				XtextAntlrGeneratorComparisonFragment comparison = new XtextAntlrGeneratorComparisonFragment();
				comparison.setOptions(antlrOptions);
				addFragment(comparison);
			}});
		}};
		
		generator.preInvoke();
		
		new DirectoryCleaner() {{
			setDirectory(runtimeProject + "/emf-gen");
		}}.invoke(null);
		
		new EcoreGenerator() {{
			setGenModel(xbaseGenModel);
			addSrcPath("platform:/resource/" + projectName + "/src");
			addSrcPath("platform:/resource/org.eclipse.xtext.common.types/src");
			setLineDelimiter(lineDelimiter);
		}}.invoke(null);
		
		generator.invoke(null);
		generator.postInvoke();
		new AbstractWorkflowComponent2() {
			@Override
			protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
				new File(runtimeProject, "plugin.properties").delete();
			}
		}.invoke(null);
		Logger.getLogger(GenerateXbase.class).info("Done."); 
	}
987287
public static void main(String[] args) {
        if(args.length != 1) {
            System.out.println("usage: " + ApplicationLauncher.class.getName() + " namespace");
            System.exit(0);
            return;
        }

        // generate configuration sources
        String namespace= args[0];
        AbstractConfiguration[] configs;
        try {
            configs= ConfigurationGenerator.execute(
                namespace,
                ApplicationLauncher.class.getClassLoader(),
                LoggerFactory.getLogger(ApplicationLauncher.class));
        } catch (Exception e) {
        	e.printStackTrace();
            System.err.println("namespace does not contain a valid application definition: " + e.getMessage());
            System.exit(1);
            return;
        }
        
        // prepare compilation
        JavaCompiler compiler= ToolProvider.getSystemJavaCompiler();
        if(compiler == null) {
            System.err.println("Java compiler could not be found. Possibly you are running a JRE instead of a JDK!");
            System.exit(1);
            return;
        }
        
        final List<NodeConfiguration> nodes= new ArrayList<NodeConfiguration>();
        ArrayList<JavaFileObject> sources= new ArrayList<JavaFileObject>();
        for(AbstractConfiguration config : configs) {
            sources.add(new CharSequenceJavaFileObject(config.className, config.source));
            
            // collect nodes for later execution
            if(config instanceof NodeConfiguration) {
                nodes.add((NodeConfiguration) config);
            }
        }
        
        StandardJavaFileManager stdFileManager= compiler.getStandardFileManager(null, null, null);
        ByteFileManager<StandardJavaFileManager> byteFileManager= new ByteFileManager<StandardJavaFileManager>(stdFileManager);
        ConfigurationDiagnosticListener listener= new ConfigurationDiagnosticListener();
        CompilationTask task= compiler.getTask(null, byteFileManager, listener, null, null, sources);
        
        // compile
        boolean success= task.call().booleanValue();
        try {
            byteFileManager.close();
        } catch (IOException e1) {
            e1.printStackTrace();
            System.err.println("could not close file manager");
        }
        
        if(!success) {
            System.err.println("could not compile node configurations");
            System.err.println("  trying to dump generated source files...");
            
            File targetFolder= dumpSources(configs);
            
            if(targetFolder != null) {
                System.err.println(" dumped into " + targetFolder.toString());
            } else {
                System.err.println(" failed");
            }
            System.exit(1);
            return;
        }
        
        // launch the nodes
        Map<String, ByteArrayJavaFileObject> classes= byteFileManager.getStore();
        if(nodes.size() <= 0) {
            System.err.println("no nodes configured");
            System.exit(1);
        } else if(nodes.size() == 1) {
            // start the node in the current vm
            launchInCurrentVM(nodes.get(0).className, classes);
        } else {
            // write the configuration
            launchInNewVMs(nodes, classes);
        }
    }
1170648
function(oUnitTest) {
          var _,
              /**
               * An array-like object representing the <abbr title=
               * "abstract syntax tree">AST</abbr> obtained after consolidation.
               * @type {!TSyntacticCodeUnit}
               */
              oSyntacticCodeUnitActual =
                  exports.ast_consolidate(oParser.parse(oUnitTest.sInput)),
              /**
               * An array-like object representing the expected <abbr title=
               * "abstract syntax tree">AST</abbr>.
               * @type {!TSyntacticCodeUnit}
               */
              oSyntacticCodeUnitExpected = oParser.parse(
                  oUnitTest.hasOwnProperty('sOutput') ?
                  oUnitTest.sOutput : oUnitTest.sInput);

          delete oSyntacticCodeUnitActual.scope;
          oWalker = oProcessor.ast_walker();
          oWalker.with_walkers(
              oWalkersPurifiers,
              cContext(oWalker, oSyntacticCodeUnitActual));
          try {
            oAssert.deepEqual(
                oSyntacticCodeUnitActual,
                oSyntacticCodeUnitExpected);
          } catch (oException) {
            console.error(
                '########## A unit test has failed.\n' +
                oUnitTest.sTitle + '\n' +
                '#####  actual code  (' +
                oProcessor.gen_code(oSyntacticCodeUnitActual).length +
                ' bytes)\n' +
                oProcessor.gen_code(
                    oSyntacticCodeUnitActual,
                    oCodeGenerationOptions) + '\n' +
                '##### expected code (' +
                oProcessor.gen_code(oSyntacticCodeUnitExpected).length +
                ' bytes)\n' +
                oProcessor.gen_code(
                    oSyntacticCodeUnitExpected,
                    oCodeGenerationOptions));
          }
        }
342677
@SuppressWarnings("unchecked")
	public static void main(String[] args)
	{
		List<File> filenames = new Vector<File>();
		List<File> pathnames = new Vector<File>();
		List<String> largs = Arrays.asList(args);
		VDMJ controller = null;
		Dialect dialect = Dialect.VDM_SL;
		String remoteName = null;
		Class<RemoteControl> remoteClass = null;
		String defaultName = null;

		Properties.init(); // Read properties file, if any
		Settings.usingCmdLine = true;
		
		if(largs.contains("-version"))
		{
			println(getOvertureVersion());
			System.exit(0);
		}
		
		for (Iterator<String> i = largs.iterator(); i.hasNext();)
		{
			String arg = i.next();

			if (arg.equals("-vdmsl"))
			{
				controller = new VDMSL();
				dialect = Dialect.VDM_SL;
			} else if (arg.equals("-vdmpp"))
			{
				controller = new VDMPP();
				dialect = Dialect.VDM_PP;
			} else if (arg.equals("-vdmrt"))
			{
				controller = new VDMRT();
				dialect = Dialect.VDM_RT;
			} else if (arg.equals("-w"))
			{
				warnings = false;
			} else if (arg.equals("-i"))
			{
				interpret = true;
			} else if (arg.equals("-p"))
			{
				pog = true;
			} else if (arg.equals("-q"))
			{
				quiet = true;
			} else if (arg.equals("-e"))
			{
				Settings.usingCmdLine = false;
				interpret = true;
				pog = false;

				if (i.hasNext())
				{
					script = i.next();
				} else
				{
					usage("-e option requires an expression");
				}
			} else if (arg.equals("-o"))
			{
				if (i.hasNext())
				{
					if (outfile != null)
					{
						usage("Only one -o option allowed");
					}

					outfile = i.next();
				} else
				{
					usage("-o option requires a filename");
				}
			} else if (arg.equals("-c"))
			{
				if (i.hasNext())
				{
					filecharset = validateCharset(i.next());
				} else
				{
					usage("-c option requires a charset name");
				}
			} else if (arg.equals("-t"))
			{
				if (i.hasNext())
				{
					Console.setCharset(validateCharset(i.next()));
				} else
				{
					usage("-t option requires a charset name");
				}
			} else if (arg.equals("-r"))
			{
				if (i.hasNext())
				{
					Settings.release = Release.lookup(i.next());

					if (Settings.release == null)
					{
						usage("-r option must be " + Release.list());
					}
				} else
				{
					usage("-r option requires a VDM release");
				}
			} else if (arg.equals("-pre"))
			{
				Settings.prechecks = false;
			} else if (arg.equals("-post"))
			{
				Settings.postchecks = false;
			} else if (arg.equals("-inv"))
			{
				Settings.invchecks = false;
			} else if (arg.equals("-dtc"))
			{
				// NB. Turn off both when no DTC
				Settings.invchecks = false;
				Settings.dynamictypechecks = false;
			} else if (arg.equals("-measures"))
			{
				Settings.measureChecks = false;
			} else if (arg.equals("-log"))
			{
				if (i.hasNext())
				{
					logfile = i.next();
				} else
				{
					usage("-log option requires a filename");
				}
			} else if (arg.equals("-remote"))
			{
				if (i.hasNext())
				{
					interpret = true;
					remoteName = i.next();
				} else
				{
					usage("-remote option requires a Java classname");
				}
			} else if (arg.equals("-default"))
			{
				if (i.hasNext())
				{
					defaultName = i.next();
				} else
				{
					usage("-default option requires a name");
				}
			} else if (arg.equals("-path"))
			{
				if (i.hasNext())
				{
					File path = new File(i.next());

					if (path.isDirectory())
					{
						pathnames.add(path);
					} else
					{
						usage(path + " is not a directory");
					}
				} else
				{
					usage("-path option requires a directory");
				}
			}else if (arg.equals("-baseDir"))
			{
				if (i.hasNext())
				{
					try
					{
						Settings.baseDir = new File(i.next());
					} catch (IllegalArgumentException e)
					{
						usage(e.getMessage() + ": " + arg);
					}
				} else
				{
					usage("-baseDir option requires a folder name");
				}
			}  else if (arg.startsWith("-"))
			{
				usage("Unknown option " + arg);
			} else
			{
				// It's a file or a directory
				File file = new File(arg);

				if (file.isDirectory())
				{
					for (File subFile : file.listFiles(dialect.getFilter()))
					{
						if (subFile.isFile())
						{
							filenames.add(subFile);
						}
					}
				} else
				{
					if (file.exists())
					{
						filenames.add(file);
					} else
					{
						boolean OK = false;

						for (File path : pathnames)
						{
							File pfile = new File(path, arg);

							if (pfile.exists())
							{
								filenames.add(pfile);
								OK = true;
								break;
							}
						}

						if (!OK)
						{
							usage("Cannot find file " + file);
						}

					}
				}
			}
		}

		if (controller == null)
		{
			usage("You must specify either -vdmsl, -vdmpp or -vdmrt");
		}

		if (logfile != null && !(controller instanceof VDMRT))
		{
			usage("The -log option can only be used with -vdmrt");
		}

		if (remoteName != null)
		{
			try
			{
				Class<?> cls = ClassLoader.getSystemClassLoader().loadClass(remoteName);
				remoteClass = (Class<RemoteControl>) cls;
			} catch (ClassNotFoundException e)
			{
				usage("Cannot locate " + remoteName + " on the CLASSPATH");
			}
		}

		ExitStatus status = null;

		if (filenames.isEmpty() && (!interpret || remoteClass != null))
		{
			usage("You didn't specify any files");
			status = ExitStatus.EXIT_ERRORS;
		} else
		{
			do
			{
				if (filenames.isEmpty())
				{
					status = controller.interpret(filenames, null);
				} else
				{
					status = controller.parse(filenames);

					if (status == ExitStatus.EXIT_OK)
					{
						status = controller.typeCheck();

						if (status == ExitStatus.EXIT_OK && interpret)
						{
							if (remoteClass == null)
							{
								status = controller.interpret(filenames, defaultName);
							} else
							{
								try
								{
									final RemoteControl remote = remoteClass.newInstance();
									Interpreter i = controller.getInterpreter();

									if (defaultName != null)
									{
										i.setDefaultName(defaultName);
									}

									i.init(null);

									try
									{
										// remote.run(new RemoteInterpreter(i, null));
										final RemoteInterpreter remoteInterpreter = new RemoteInterpreter(i, null);
										Thread remoteThread = new Thread(new Runnable()
										{

											public void run()
											{
												try
												{
													remote.run(remoteInterpreter);
												} catch (Exception e)
												{
													println(e.getMessage());
													// status = ExitStatus.EXIT_ERRORS;
												}
											}
										});
										remoteThread.setName("RemoteControl runner");
										remoteThread.setDaemon(true);
										remoteThread.start();
										remoteInterpreter.processRemoteCalls();
										status = ExitStatus.EXIT_OK;
									} catch (Exception e)
									{
										println(e.getMessage());
										status = ExitStatus.EXIT_ERRORS;
									}
								} catch (InstantiationException e)
								{
									usage("Cannot instantiate " + remoteName);
								} catch (Exception e)
								{
									usage(e.getMessage());
								}
							}
						}
					}
				}
			} while (status == ExitStatus.RELOAD);
		}

		if (interpret)
		{
			infoln("Bye");
		}

		System.exit(status == ExitStatus.EXIT_OK ? 0 : 1);
	}
1285174
public static void main(String args[]) {
        Statement stmts[] = null;
        try {
            stmts = getStatements(args[0]);
        } catch (Throwable e) {
            System.out.println(e.getMessage());
            return;
        }
        for (Statement s : stmts) {
            System.out.print(s.statement);
        }
    }
1311308
private StringBuffer getArgsString(Object[] args) {
        StringBuffer buffer = new StringBuffer();
        String prefix = "args ";
        for (int i = 0; i < args.length; i++) {
            if (args.length > 1) {
                buffer.append(prefix + (i + 1));
            }
            buffer.append("\r\t");
            buffer.append(getResultString(args[i]));
            buffer.append("\n");
        }
        return buffer;
    }
166658
function parseArguments(args) {
    const first = args[0];
    const second = args[1];

    return typeof first === 'string'
        ? { namespace: first, mappings: second }
        : { namespace: null, mappings: first };
}
761145
public void dumpTo(AreaTree tree, PrintWriter out)
    {
        if (produceHeader)
        {
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>" + tree.getRoot().getPage().getTitle() + "</title>");
            out.println("<meta charset=\"utf-8\">");
            out.println("<meta name=\"generator\" content=\"FITLayout - area tree dump\">");
            out.println("</head>");
            out.println("<body>");
        }
        recursiveDumpArea(tree.getRoot(), 1, out);
        if (produceHeader)
        {
            out.println("</body>");
            out.println("</html>");
        }
    }
867642
protected final void parse(List<String> args) {
    Pattern eqSeparatedOpt = Pattern.compile("(--[^=]+)=(.+)");

    int idx = 0;
    for (idx = 0; idx < args.size(); idx++) {
      String arg = args.get(idx);
      String value = null;

      Matcher m = eqSeparatedOpt.matcher(arg);
      if (m.matches()) {
        arg = m.group(1);
        value = m.group(2);
      }

      // Look for options with a value.
      String name = findCliOption(arg, opts);
      if (name != null) {
        if (value == null) {
          if (idx == args.size() - 1) {
            throw new IllegalArgumentException(
                String.format("Missing argument for option '%s'.", arg));
          }
          idx++;
          value = args.get(idx);
        }
        if (!handle(name, value)) {
          break;
        }
        continue;
      }

      // Look for a switch.
      name = findCliOption(arg, switches);
      if (name != null) {
        if (!handle(name, null)) {
          break;
        }
        continue;
      }

      if (!handleUnknown(arg)) {
        break;
      }
    }

    if (idx < args.size()) {
      idx++;
    }
    handleExtraArgs(args.subList(idx, args.size()));
  }
86641
private void printf( String pattern, Object... args )
    {
        if( m_log != null )
        {
            StringBuilder sb = new StringBuilder();
            Formatter formatter = new Formatter(sb);

            try
            {
                formatter.format(pattern, args);

                m_log.info(sb.toString());
            }
            finally
            {
                formatter.close();
            }
        }
    }
697457
public static void main(String[] args) {
    //TreeFactory tf = new LabeledScoredTreeFactory();
    Tree stringyTree = null;
    try {
      stringyTree = (new PennTreeReader(new StringReader("(S (VP (VBZ Try) (NP (DT this))) (. .))"), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
    } catch (IOException e) {
      // do nothing
    }
    System.out.println(stringyTree);
    Function<Tree, Tree> a = getLabeledTreeToCategoryWordTagTreeFunction();
    Tree adaptyTree = a.apply(stringyTree);
    System.out.println(adaptyTree);
    adaptyTree.percolateHeads(new CollinsHeadFinder());
    System.out.println(adaptyTree);

    Function<Tree, Tree> b = getLabeledTreeToStringLabeledTreeFunction();
    Tree stringLabelTree = b.apply(adaptyTree);
    System.out.println(stringLabelTree);

  }
45694
void parseArgs(String[] args) {
    int i = 0;
    while (true) {
      if (i >= args.length) {
        break;
      }

      String s = args[i];
      if (s.equals("-h") ||
              s.equals("help") ||
              s.equals("-help") ||
              s.equals("--help")) {
        usage();
      }
      else if (s.equals("-n") ||
              s.equals("-nodes")) {
        i++; if (i >= args.length) { usage(); }
        numNodes = Integer.parseInt(args[i]);
      }
      else if (s.equals("-o") ||
              s.equals("-output")) {
        i++; if (i >= args.length) { usage(); }
        outputPath = args[i];
      }
      else if (s.equals("-jobname")) {
        i++; if (i >= args.length) { usage(); }
        jobtrackerName = args[i];
      }
      else if (s.equals("-mapperXmx")) {
        i++; if (i >= args.length) { usage(); }
        mapperXmx = args[i];
      }
      else if (s.equals("-extramempercent")) {
        i++; if (i >= args.length) { usage(); }
        extraMemPercent = Integer.parseInt(args[i]);
      }
      else if (s.equals("-driverif")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackIp = args[i];
      }
      else if (s.equals("-driverport")) {
        i++; if (i >= args.length) { usage(); }
        driverCallbackPort = Integer.parseInt(args[i]);
      }
      else if (s.equals("-network")) {
        i++; if (i >= args.length) { usage(); }
        network = args[i];
      }
      else if (s.equals("-timeout")) {
        i++; if (i >= args.length) { usage(); }
        cloudFormationTimeoutSeconds = Integer.parseInt(args[i]);
      }
      else if (s.equals("-disown")) {
        disown = true;
      }
      else if (s.equals("-notify")) {
        i++; if (i >= args.length) { usage(); }
        clusterReadyFileName = args[i];
      }
      else if (s.equals("-nthreads")) {
        i++; if (i >= args.length) { usage(); }
        nthreads = Integer.parseInt(args[i]);
      }
      else if (s.equals("-many_cols")) {
        manyCols = true;
      }
      else if (s.equals("-chunk_bytes")) {
        i++; if (i >= args.length) { usage(); }
        chunk_bytes = Integer.parseInt(args[i]);
      }
      else if (s.equals("-data_max_factor_levels")) {
        i++; if (i >= args.length) { usage(); }
        data_max_factor_levels = Integer.parseInt(args[i]);
      }
      else if (s.equals("-baseport")) {
        i++; if (i >= args.length) { usage(); }
        basePort = Integer.parseInt(args[i]);
        if ((basePort < 0) || (basePort > 65535)) {
            error("Base port must be between 1 and 65535");
        }
      }
      else if (s.equals("-beta")) {
        beta = true;
      }
      else if (s.equals("-random_udp_drop")) {
        enableRandomUdpDrop = true;
      }
      else if (s.equals("-ea")) {
        enableExceptions = true;
      }
      else if (s.equals("-verbose:gc")) {
        enableVerboseGC = true;
      }
      else if (s.equals("-verbose:class")) {
        enableVerboseClass = true;
      }
      else if (s.equals("-XX:+PrintCompilation")) {
        enablePrintCompilation = true;
      }
      else if (s.equals("-exclude")) {
        enableExcludeMethods = true;
      }
      else if (s.equals("-Dlog4j.defaultInitOverride=true")) {
        enableLog4jDefaultInitOverride = true;
      }
      else if (s.equals("-debug")) {
        enableDebug = true;
      }
      else if (s.equals("-suspend")) {
        enableSuspend = true;
      }
      else if (s.equals("-debugport")) {
        i++; if (i >= args.length) { usage(); }
        debugPort = Integer.parseInt(args[i]);
        if ((debugPort < 0) || (debugPort > 65535)) {
          error("Debug port must be between 1 and 65535");
        }
      }
      else if (s.equals("-XX:+PrintGCDetails")) {
        enablePrintGCDetails = true;
      }
      else if (s.equals("-XX:+PrintGCTimeStamps")) {
        enablePrintGCTimeStamps = true;
      }
      else if (s.equals("-gc")) {
        enableVerboseGC = true;
        enablePrintGCDetails = true;
        enablePrintGCTimeStamps = true;
      }
      else if (s.equals("-license")) {
        i++; if (i >= args.length) { usage(); }
        licenseFileName = args[i];
      }
      else if (s.equals("-extraJavaOpts")) {
        i++; if (i >= args.length) { usage(); }
        extraJavaOpts = args[i];
      }
      else {
        error("Unrecognized option " + s);
      }

      i++;
    }

    // Check for mandatory arguments.
    if (numNodes < 1) {
      error("Number of H2O nodes must be greater than 0 (must specify -n)");
    }
    if (outputPath == null) {
      error("Missing required option -output");
    }
    if (mapperXmx == null) {
      error("Missing required option -mapperXmx");
    }

    // Check for sane arguments.
    if (! mapperXmx.matches("[1-9][0-9]*[mgMG]")) {
      error("-mapperXmx invalid (try something like -mapperXmx 4g)");
    }

    if (extraMemPercent < 0) {
      extraMemPercent = DEFAULT_EXTRA_MEM_PERCENT;
    }

    if (jobtrackerName == null) {
      Random rng = new Random();
      int num = rng.nextInt(99999);
      jobtrackerName = "H2O_" + num;
    }

    if (network == null) {
      network = "";
    }
    else {
      String[] networks;
      if (network.contains(",")) {
        networks = network.split(",");
      }
      else {
        networks = new String[1];
        networks[0] = network;
      }

      for (int j = 0; j < networks.length; j++) {
        String n = networks[j];
        Pattern p = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)/(\\d+)");
        Matcher m = p.matcher(n);
        boolean b = m.matches();
        if (! b) {
          error("network invalid: " + n);
        }

        for (int k = 1; k <=4; k++) {
          int o = Integer.parseInt(m.group(k));
          if ((o < 0) || (o > 255)) {
            error("network invalid: " + n);
          }

          int bits = Integer.parseInt(m.group(5));
          if ((bits < 0) || (bits > 32)) {
            error("network invalid: " + n);
          }
        }
      }
    }

    if (network == null) {
      error("Internal error, network should not be null at this point");
    }

    if ((nthreads >= 0) && (nthreads < 4)) {
      error("nthreads invalid (must be >= 4): " + nthreads);
    }

    if (licenseFileName != null) {
      try {
        licenseData = readFile(licenseFileName);
      }
      catch (Exception xe) {
        StringBuilder sb = new StringBuilder();
        sb.append("Failed to read license file: ");
        if (xe.getLocalizedMessage() != null) {
          sb.append(xe.getLocalizedMessage());
        }
        else {
          sb.append(licenseFileName);
        }

        error(sb.toString());
      }
    }
  }
192721
function compile (tree) {
    if (typeof tree === "string") tree = parse(tree);

    // Every compiled function gets called with a reference to the runtime.
    return new Function(["args", "runt"], [
      'var ret = [];',
      compileArgumentList(tree),
      'return ret;'
    ].join('\n'));
  }
99045
public static void main(String[] args) {
    Tree t;
    try {
      t = Tree.valueOf("(S (NP (NNP Sam)) (VP (VBD died) (NP-TMP (NN today))))");
    } catch (Exception e) {
      System.err.println("Horrible error: " + e);
      e.printStackTrace();
      return;
    }

    t.pennPrint();

    System.out.println("----------------------------");
    TreeGraph tg = new TreeGraph(t);
    System.out.println(tg);

    tg.root.percolateHeads(new SemanticHeadFinder());
    System.out.println("----------------------------");
    System.out.println(tg);

//    TreeGraphNode node1 = tg.getNodeByIndex(1);
//    TreeGraphNode node4 = tg.getNodeByIndex(4);
//    node1.addArc("1to4", node4);
//    node1.addArc("1TO4", node4);
//    node4.addArc("4to1", node1);
//    System.out.println("----------------------------");
//    System.out.println("arcs from 1 to 4: " + node1.arcLabelsToNode(node4));
//    System.out.println("arcs from 4 to 1: " + node4.arcLabelsToNode(node1));
//    System.out.println("arcs from 0 to 4: " + tg.root.arcLabelsToNode(node4));
//    for (int i = 0; i <= 9; i++) {
//      System.out.println("parent of " + i + ": " + tg.getNodeByIndex(i).parent());
//      System.out.println("highest node with same head as " + i + ": " + tg.getNodeByIndex(i).highestNodeWithSameHead());
//    }
  }
341637
private static String format(String template, @javax.annotation.Nullable Object... args) {
    // If no arguments return the template.
    if (args == null) {
      return template;
    }

    // start substituting the arguments into the '%s' placeholders
    StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
    int templateStart = 0;
    int i = 0;
    while (i < args.length) {
      int placeholderStart = template.indexOf("%s", templateStart);
      if (placeholderStart == -1) {
        break;
      }
      builder.append(template, templateStart, placeholderStart);
      builder.append(args[i++]);
      templateStart = placeholderStart + 2;
    }
    builder.append(template, templateStart, template.length());

    // if we run out of placeholders, append the extra args in square braces
    if (i < args.length) {
      builder.append(" [");
      builder.append(args[i++]);
      while (i < args.length) {
        builder.append(", ");
        builder.append(args[i++]);
      }
      builder.append(']');
    }

    return builder.toString();
  }
789042
@SuppressWarnings("checkstyle:regexp")
	public static void showCommandLineArguments(String[] args) {
		try (PrintStream os = getConsoleLogger()) {
			for (int i = 0; i < args.length; ++i) {
				os.println(i + ": " //$NON-NLS-1$
						+ args[i]);
			}
			os.flush();
		} catch (Throwable e) {
			e.printStackTrace();
		}
		getExiter().exit();
	}