Examples of ParserPicker


Examples of com.lastcalc.engines.ParserPickerFactory.ParserPicker

  public LinkedList<ParseStep> parse(final TokenList input,
      final ParserContext context,
      final TokenList... alternateInputs) {
    lastParseStepCount = 0;
    final TreeSet<ParseStep> candidates = Sets.<ParseStep> newTreeSet();
    final ParserPicker picker = ppf.getPicker();
    candidates.add(new ParseStep(input, NoopParser.singleton, ParseResult.success(input), null, 0));
    for (final TokenList alternateTL : alternateInputs) {
      candidates.add(new ParseStep(alternateTL, NoopParser.singleton, ParseResult.success(alternateTL), null, 0));
    }
    final long startTime = System.currentTimeMillis();
    ParserContext subContext;
    try {
      subContext = (ParserContext) context.clone();
    } catch (final CloneNotSupportedException e) {
      throw new RuntimeException(e);
    }
    subContext.timeout = context.timeout / 5;
    final Set<ParseStep> exhausted = Sets.newHashSet();
    outer: while (System.currentTimeMillis() - startTime < context.timeout && !candidates.first().isMinimal()) {
      for (final ParseStep candidateStep : candidates) {
        if (exhausted.contains(candidateStep)) {
          continue;
        }
        final ParseStep nextStep = picker.pickNext(subContext, candidateStep);
        if (nextStep != null && nextStep.result.isSuccess()) {
          lastParseStepCount++;
          if (dumpSteps) {
            System.out.println(lastParseStepCount + "\t" + nextStep);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.