Example #1
0
 /**
  * may be called by a callback to retrieve see <a
  * href="doc-files/resyntax.html#rse">submatches</a>. Retrieving submatches must be done before
  * the match is changed in any way. A typical call within an {@link FaAction} looks like
  *
  * <pre>
  *   public void invoke(StringBuilder out, int start, DfaRun r)
  *     throws CallbackException {
  *   {
  *     TextStore ts = r.submatches(out, start);
  *     ...
  *   }</pre>
  *
  * Parameter <code>txt</code> is not changed in any way.
  *
  * @param txt must contain the full match starting at position <code>start</code>. It may contain
  *     more characters.
  * @param start is the position where the full match starts within <code>txt</code>
  * @return a <code>TextStore</code> that contains the whole match as part 0 and submatches as
  *     subsequent parts. The return value is private to <code>this</code> and its contents may
  *     only be used locally in a callback. After returning from the callback, the contents of the
  *     result may soon change.
  */
 public TextStore submatches(StringBuilder txt, int start) {
   readTs.clear();
   // System.out.println("-->"+txt+"<--, `"+txt.substring(start)
   // +"'  "+smd.size);
   readTs.appendPart(txt, start, txt.length());
   smd.analyze(readTs, action);
   return readTs;
 }
Example #2
0
 /**
  * returns a <code>TextStore</code> which contains submatches, if any, pertaining to the most
  * recent match. The object returned should be treated read-only. Its contents are only valid
  * until the next match operation.
  *
  * @throws IllegalStateException if the most recent application of <code>this</code> did not yield
  *     a match.
  */
 public TextStore submatches() {
   if (a == null || a == DfaRun.EOF) {
     throw new IllegalStateException("no recent match available");
   }
   if (!analyzed) {
     analyzed = true;
     ts.clear();
     ts.appendPart(out, 0, out.length());
     smd.analyze(ts, a);
   }
   return ts;
 }