Creates a readable string represenation of the parse tree in the given {@link ParsingResult} object.

@param parsingResult the parsing result containing the parse tree
@return a new String
16243
public static <V> String printNodeTree(ParsingResult<V> parsingResult) {
        checkArgNotNull(parsingResult, "parsingResult");
        return printNodeTree(parsingResult, Predicates.<Node<V>>alwaysTrue(), Predicates.<Node<V>>alwaysTrue());
    }
1188616
private IckleParsingResult<TypeMetadata> makeFilterParsingResult(IckleParsingResult<TypeMetadata> parsingResult, BooleanExpr normalizedWhereClause,
                                                                    PropertyPath[] projection, Class<?>[] projectedTypes, Object[] projectedNullMarkers,
                                                                    SortField[] sortFields) {
      String queryString = SyntaxTreePrinter.printTree(parsingResult.getTargetEntityName(), projection, normalizedWhereClause, sortFields);
      return new IckleParsingResult<>(queryString, parsingResult.getParameterNames(),
            normalizedWhereClause, null,
            parsingResult.getTargetEntityName(), parsingResult.getTargetEntityMetadata(),
            projection, projectedTypes, projectedNullMarkers, null, sortFields);
   }
1374999
public static Locale parseLocale(String localeString) {
        if (localeString == null || localeString.length() == 0) {
            return Locale.getDefault();
        }
        localeString = localeString.trim();

        if (localeString == null) {
            return null;
        }

        String language = "";
        String country = "";
        String variant = "";

        // language
        int start = 0;
        int index = localeString.indexOf("_");

        if (index >= 0) {
            language = localeString.substring(start, index).trim();

            // country
            start = index + 1;
            index = localeString.indexOf("_", start);

            if (index >= 0) {
                country = localeString.substring(start, index).trim();

                // variant
                variant = localeString.substring(index + 1).trim();
            } else {
                country = localeString.substring(start).trim();
            }
        } else {
            language = localeString.substring(start).trim();
        }

        return new Locale(language, country, variant);
    }
1198138
public static boolean copyTreeToResult(Node tree, Result result)
    {
        try {
            // Use a Transformer for output
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();

            DOMSource source = new DOMSource(tree);
            transformer.transform(source, result);
            return true;    // Success
        } catch (TransformerConfigurationException tce) {
            // Error generated by the parser
            tce.printStackTrace();
        } catch (TransformerException te) {
            // Error generated by the parser
            te.printStackTrace();
        }
        return false;   // Failure
    }
734634
public void setResult(Result result) throws IllegalArgumentException {
		Check.notNull(result);
		if(result instanceof SAXResult) {
			setTarget((SAXResult)result);
		} else {
			 th = saxHelper.newIdentity();
			th.setResult(result);
			setTarget(new SAXResult(th));
		}
	}
17369
public static Locale parseLocale(String localeString) {
    if (localeString == null) {
      return Locale.US;
    }
    String[] groups = localeString.split("[-_]");
    switch (groups.length) {
      case 1:
        return new Locale(groups[0]);
      case 2:
        return new Locale(groups[0], Ascii.toUpperCase(groups[1]));
      case 3:
        return new Locale(groups[0], Ascii.toUpperCase(groups[1]), groups[2]);
      default:
        throw new IllegalArgumentException("Malformed localeString: " + localeString);
    }
  }
125766
public static Parseable newParseable(final CharSequence cs) {
        return new Parseable() {
            int i = 0;

            public void close() throws IOException {
            }

            public int read() throws IOException {
                try {
                    return cs.charAt(i++);
                } catch (IndexOutOfBoundsException suppressed) {
                    return Parseable.END_OF_INPUT;
                }
            }

            public void unread(int ch) throws IOException {
                i--;
            }
        };
    }
751108
public static TreeString of(final String s) {
        if (s == null) {
            return null;
        }
        return new TreeString(null, s);
    }
258774
final Parser<T> asDelimiter() {
    return new Parser<T>() {
      @Override boolean apply(ParseContext ctxt) {
        return ctxt.applyAsDelimiter(Parser.this);
      }
      @Override public String toString() {
        return Parser.this.toString();
      }
    };
  }
520112
@Override
	public String toNormalizedString() {
		String result = normalizedString;
		if(result == null) {
			normalizedString = result = toNormalizedString(false);
		}
		return result;
	}
696671
public final QueryParser.simple_return simple() throws RecognitionException {
        QueryParser.simple_return retval = new QueryParser.simple_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        QueryParser.t_return t23 = null;

        QueryParser.f_return f24 = null;

        QueryParser.nil_return nil25 = null;

        QueryParser.tagged_return tagged26 = null;

        QueryParser.approximately_return approximately27 = null;

        QueryParser.regex_match_return regex_match28 = null;

        QueryParser.lesser_return lesser29 = null;

        QueryParser.lesser_equal_return lesser_equal30 = null;

        QueryParser.greater_return greater31 = null;

        QueryParser.greater_equal_return greater_equal32 = null;

        QueryParser.not_equal_return not_equal33 = null;

        QueryParser.equal_return equal34 = null;



        try {
            // src/riemann/Query.g:41:8: ( ( t | f | nil | tagged | approximately | regex_match | lesser | lesser_equal | greater | greater_equal | not_equal | equal ) )
            // src/riemann/Query.g:41:10: ( t | f | nil | tagged | approximately | regex_match | lesser | lesser_equal | greater | greater_equal | not_equal | equal )
            {
            root_0 = (CommonTree)adaptor.nil();

            // src/riemann/Query.g:41:10: ( t | f | nil | tagged | approximately | regex_match | lesser | lesser_equal | greater | greater_equal | not_equal | equal )
            int alt12=12;
            alt12 = dfa12.predict(input);
            switch (alt12) {
                case 1 :
                    // src/riemann/Query.g:41:12: t
                    {
                    pushFollow(FOLLOW_t_in_simple282);
                    t23=t();

                    state._fsp--;

                    adaptor.addChild(root_0, t23.getTree());

                    }
                    break;
                case 2 :
                    // src/riemann/Query.g:41:16: f
                    {
                    pushFollow(FOLLOW_f_in_simple286);
                    f24=f();

                    state._fsp--;

                    adaptor.addChild(root_0, f24.getTree());

                    }
                    break;
                case 3 :
                    // src/riemann/Query.g:41:20: nil
                    {
                    pushFollow(FOLLOW_nil_in_simple290);
                    nil25=nil();

                    state._fsp--;

                    adaptor.addChild(root_0, nil25.getTree());

                    }
                    break;
                case 4 :
                    // src/riemann/Query.g:42:5: tagged
                    {
                    pushFollow(FOLLOW_tagged_in_simple296);
                    tagged26=tagged();

                    state._fsp--;

                    adaptor.addChild(root_0, tagged26.getTree());

                    }
                    break;
                case 5 :
                    // src/riemann/Query.g:43:5: approximately
                    {
                    pushFollow(FOLLOW_approximately_in_simple302);
                    approximately27=approximately();

                    state._fsp--;

                    adaptor.addChild(root_0, approximately27.getTree());

                    }
                    break;
                case 6 :
                    // src/riemann/Query.g:44:5: regex_match
                    {
                    pushFollow(FOLLOW_regex_match_in_simple308);
                    regex_match28=regex_match();

                    state._fsp--;

                    adaptor.addChild(root_0, regex_match28.getTree());

                    }
                    break;
                case 7 :
                    // src/riemann/Query.g:45:5: lesser
                    {
                    pushFollow(FOLLOW_lesser_in_simple314);
                    lesser29=lesser();

                    state._fsp--;

                    adaptor.addChild(root_0, lesser29.getTree());

                    }
                    break;
                case 8 :
                    // src/riemann/Query.g:46:5: lesser_equal
                    {
                    pushFollow(FOLLOW_lesser_equal_in_simple320);
                    lesser_equal30=lesser_equal();

                    state._fsp--;

                    adaptor.addChild(root_0, lesser_equal30.getTree());

                    }
                    break;
                case 9 :
                    // src/riemann/Query.g:47:5: greater
                    {
                    pushFollow(FOLLOW_greater_in_simple326);
                    greater31=greater();

                    state._fsp--;

                    adaptor.addChild(root_0, greater31.getTree());

                    }
                    break;
                case 10 :
                    // src/riemann/Query.g:48:5: greater_equal
                    {
                    pushFollow(FOLLOW_greater_equal_in_simple332);
                    greater_equal32=greater_equal();

                    state._fsp--;

                    adaptor.addChild(root_0, greater_equal32.getTree());

                    }
                    break;
                case 11 :
                    // src/riemann/Query.g:49:5: not_equal
                    {
                    pushFollow(FOLLOW_not_equal_in_simple338);
                    not_equal33=not_equal();

                    state._fsp--;

                    adaptor.addChild(root_0, not_equal33.getTree());

                    }
                    break;
                case 12 :
                    // src/riemann/Query.g:50:5: equal
                    {
                    pushFollow(FOLLOW_equal_in_simple344);
                    equal34=equal();

                    state._fsp--;

                    adaptor.addChild(root_0, equal34.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
1187
@Override
    public ParseResult parse(final Source source) {
        return Util.execute(new ExceptionAction<ParseResult>() {
            @Override
            public ParseResult doAction() throws Throwable {
                logger.fine("Parsing " + source.getSrcInfo());
                final BufferedReader reader = source.createReader();
                try {
                    final ParserImpl impl = factory.create(source.getSrcInfo(),
                            reader);
                    final Doc doc = impl.doc();
                    return new ParseResult(doc, impl.errors());
                } finally {
                    reader.close();
                }
            }
        });
    }
14721
public String getResultString() throws TransformerException {
        return withExceptionHandling(new Trans<String>() {
                public String transform() {
                    return transformation.transformToString();
                }
            });
    }
1209023
private Object parseObjectString(Class<?> objectType, final String objectString) {
        Object res;
        if (ResourceParams.class.isAssignableFrom(objectType)) {
            // Setup the default object
            if (this.object instanceof List<?>) {
                ResourceParams rp = (ResourceParams) ((List<?>) this.object).get(0);
                try {
                    rp = (ResourceParams) rp.clone();
                    rp.parse(objectString.split(PARAMETER_SEPARATOR_REGEX));
                    rp.getKey();
                } catch (final CloneNotSupportedException e) {
                }
                res = rp;
            } else {
                ((ResourceParams) this.object).parse(objectString.split(PARAMETER_SEPARATOR_REGEX));
                // return the new value
                res = this.object;
            }
        } else if (Class.class.isAssignableFrom(objectType)) {
            res = parseClassParameter(objectString);
        } else if (Enum.class.isAssignableFrom(objectType)) {
            res = parseEnumParameter((Enum<?>) this.object, objectString);
        } else if (File.class.isAssignableFrom(objectType)) {
            res = parseFileParameter(objectString);
        } else if (List.class.isAssignableFrom(objectType)) {
            res = parseListParameter(objectString);
        } else {
            res = parsePrimitive(objectType, objectString);
        }
        return res;
    }
916157
protected AbcNode getParseTree(String abcString) {
		long startTime = System.currentTimeMillis();
		AbcGrammar grammar = AbcGrammar.getInstance();
		// AbcGrammar parser = Parboiled.createParser(AbcGrammar.class);
		ParsingResult<?> result = RecoveringParseRunner.run(grammar.AbcFile(),
				abcString);
		if (DEBUG) {
			System.out.println("Parse : "+(System.currentTimeMillis() - startTime) + "ms");
		}
		if (result.hasErrors()) {
			System.err.println("Parse errors: "
					+ result.parseErrors.size());
			/*Iterator it = result.parseErrors.iterator();
			while (it.hasNext()) {
				ParseError pe = (ParseError) it.next();
				System.err.println("- " + pe.getErrorMessage()
						+ "("+pe.getStartIndex()+"->"+pe.getEndIndex()+")");
			}*/
		}

		AbcNode abcRoot = new AbcNode(result.parseTreeRoot, result.inputBuffer,
				result.parseErrors, new AbcInputBuffer(abcString.toCharArray()));
		if (result.hasErrors() || DEBUG)
			debugTree(abcRoot);
		return abcRoot;
	}
1168116
public Properties parsePropertiesString(String propertiesAsString) {
        final Properties p = new Properties();
        try (StringReader reader = new StringReader(propertiesAsString)) {
            p.load(reader);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unable to parse .properties: " + propertiesAsString, e);
        }
        return p;
    }
634918
public void parseString(String xml) throws ParserException {

        try {
            nanoElement.parseString(xml);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        }
    }