Examples of JumpOperation


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

      // 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);
    return new AlternativeCommandState(template, lastForkPoint, nextPartLabel, endLabel);
  }
View Full Code Here

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

        template.nopOperation(lastForkPoint);
        template.nopOperation(lastForkPoint + 1);
        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

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

    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

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

    @Override
    public PlainBlockCommandState parseCommand(MatchTemplateImpl template,
        String commandName, String parameters) {
      template.appendOperation(new IncrementCounterOperation(template.getCurrentTemplatePosition(), co));
      template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), startLabel));
      endLabel.setDestinationToNextCommand(template);
      return null;
    }
View Full Code Here

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

    // 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

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

  @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;
    if (pos == -1) {
      commandName = parameters.toLowerCase();
      commandParameters = "";
    } else {
      commandName = parameters.substring(0, pos).toLowerCase();
      commandParameters = parameters.substring(pos + 1);
    }
    Command cmd = Command.getCommand(commandName);
    if (cmd != null) {
      PlainBlockCommandState bcs = cmd.parse(template, commandParameters);
      if (bcs != null)
        throw new RuntimeException("Optional/Repeated command cannot be used for block commands!");
    } else {
      throw new RuntimeException("Unsupported command: " + commandName);
    }
    if (repeated) {
      template.appendOperation(new JumpOperation(template.getCurrentTemplatePosition(), startLabel));
    }
    endLabel.setDestinationToNextCommand(template);
    return null;
  }
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.