code: public void substitute(SAXRule r) {
      // System.out.println("[sequitur debug] *substitute* " + this.value + " with rule "
      // + r.asDebugLine());
      // clean up this place and the next
  
      // here we keep the original position in the input string
      //
      r.addIndex(this.originalPosition);
  
      this.cleanUp();
      this.n.cleanUp();
      // link the rule instead of digram
      SAXNonTerminal nt = new SAXNonTerminal(r);
      nt.originalPosition = this.originalPosition;
      this.p.insertAfter(nt);
      // do p check
      //
      // TODO: not getting this
      if (!p.check()) {
        p.n.check();
      }
    }
docs: Replace a digram with a non-terminal.
  
  @param r a rule to use.