Package net.sf.jmatchparser.template.engine.operation

Examples of net.sf.jmatchparser.template.engine.operation.Label


    this.optional = optional;
  }

  @Override
  protected PlainBlockCommandState parse(MatchTemplateImpl template) {
    Label endLabel = new Label(), nextPartLabel = new Label(), forkLabel = new Label();
    if (optional) {
      // jump around here to make sure every path has at least one unique
      // operation
      Label dummyEndLabel = new Label();
      Label dummyContLabel = new Label();
      template.appendOperation(new ForkOperation(template.getCurrentTemplatePosition(), dummyEndLabel, false));
      template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), dummyContLabel));
      dummyEndLabel.setDestinationToNextCommand(template);
      template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), endLabel));
      dummyContLabel.setDestinationToNextCommand(template);
    }
    int lastForkPoint = template.getNextOperationIndex();
    template.appendOperation(new ForkOperation(template.getCurrentTemplatePosition(), forkLabel, false));
    template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), nextPartLabel));
    forkLabel.setDestinationToNextCommand(template);
View Full Code Here


        endLabel.setDestinationToNextCommand(template);
        return null;
      } else {
        template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), endLabel));
        nextPartLabel.setDestinationToNextCommand(template);
        nextPartLabel = new Label();
        Label forkLabel = new Label();
        lastForkPoint = template.getNextOperationIndex();
        template.appendOperation(new ForkOperation(template.getCurrentTemplatePosition(), forkLabel, false));
        template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), nextPartLabel));
        forkLabel.setDestinationToNextCommand(template);
        return this;
      }
    }
View Full Code Here

public class CheckOthersCommand extends ParameterlessCommand {

  @Override
  protected PlainBlockCommandState parse(MatchTemplateImpl template) {
    Label forkLabel = new Label();
    template.appendOperation(new ForkOperation(template.getCurrentTemplatePosition(), forkLabel, true));
    forkLabel.setDestinationToNextCommand(template);
    return null;
  }
View Full Code Here

    // a huge pile of queued of states to pile up if the loop repeats
    // a lot of times.
    Parameter[] params = Parameter.parseParameters(parameters, 0, 2, 1, template.getSpecialTags());
    if (params[0] == null)
      params[0] = Parameter.getLiteralParameter("0");
    Label startLabel = new Label(), endLabel = new Label(), forkLabel = new Label();
    CounterOperation co = new CounterOperation(template.getCurrentTemplatePosition());
    template.appendOperation(co);
    startLabel.setDestinationToNextCommand(template);
    template.appendOperation(new LoopForkOperation(template.getCurrentTemplatePosition(), forkLabel, co, params[0], params[1]));
    template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), endLabel));
    forkLabel.setDestinationToNextCommand(template);
    return new LoopCommandState(template, co, startLabel, endLabel);
  }
View Full Code Here

public class MatchAnyCommand extends Command {

  @Override
  public PlainBlockCommandState parse(MatchTemplateImpl template, String parameters) {
    Label nextInstruction = new Label();
    template.appendOperation(new MatchAnyOperation(template.getCurrentTemplatePosition(),
        Parameter.parseParameter(parameters, template.getSpecialTags()), nextInstruction));
    nextInstruction.setDestinationToNextCommand(template);
    return null;
  }
View Full Code Here

public class CallTemplateCommand extends Command {

  @Override
  public PlainBlockCommandState parse(MatchTemplateImpl template, String parameters) {
    Label returnLabel = new Label();
    Label templateLabel = template.getDefLabels().get(parameters);
    if (templateLabel == null)
      throw new RuntimeException("No DEFTEMPLATE named " + parameters + " found");
    template.appendOperation(new CallOperation(template.getCurrentTemplatePosition(), templateLabel, returnLabel));
    returnLabel.setDestinationToNextCommand(template);
    return null;
View Full Code Here

    // Continue after the loop and fork inside the loop.
    // The other way round is easier to code, but will cause
    // a huge pile of queued of states to pile up if the loop repeats
    // a lot of times.

    Label startLabel = new Label(), endLabel = new Label();
    template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), endLabel));
    startLabel.setDestinationToNextCommand(template);
    template.getDefLabels().put(parameters, startLabel);
    return new TemplateCommandState(template, endLabel);
  }
View Full Code Here

    this.repeated = repeated;
  }

  @Override
  public PlainBlockCommandState parse(MatchTemplateImpl template, String parameters) {
    Label startLabel = new Label(), endLabel = new Label(), forkLabel = new Label();
    startLabel.setDestinationToNextCommand(template);
    template.appendOperation(new ForkOperation(template.getCurrentTemplatePosition(), forkLabel, false));
    template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), endLabel));
    forkLabel.setDestinationToNextCommand(template);
    int pos = parameters.indexOf(" ");
    int pos2 = parameters.indexOf("\t");
    if (pos2 != -1 && (pos == -1 || pos > pos2))
      pos = pos2;
    String commandName, commandParameters;
View Full Code Here

TOP

Related Classes of net.sf.jmatchparser.template.engine.operation.Label

Copyright © 2018 www.massapicom. 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.