kmy.regex.compiler
Class RDebugMachine

java.lang.Object
  |
  +--kmy.regex.compiler.RMachine
        |
        +--kmy.regex.compiler.RDebugMachine

public class RDebugMachine
extends RMachine

RDebugMachine is used to dump regex instruction sequence to stdout (or other output stream).


Field Summary
(package private)  int count
           
(package private)  java.io.PrintStream out
           
 
Fields inherited from class kmy.regex.compiler.RMachine
EXT_CONDJUMP, EXT_HINT, EXT_MULTIFORK, EXT_SHIFTTBL, extensions, FLAG_DOT_IS_ANY, HINT_CHAR_STAR_HEAD, HINT_END_ANCHORED, HINT_START_ANCHORED
 
Constructor Summary
RDebugMachine()
           
 
Method Summary
 void assert(char[] constStr)
           
 void assert(int charClass, char[] ranges)
          Make sure that current character belongs to the given character class.
 void assert(java.lang.String ref, boolean picked)
           
 void boundary(int boundaryClass)
          Check if current position is on the certain type of boundary given by.
 void condJump(char[] ranges, RLabel label)
          Jump if char is NOT in range
 void condJump(char c, RLabel label)
          Jump if char is NOT one that is given.
 void condJump(int atLeastCharLeft, int atMostCharLeft, RLabel label)
          Jump if less then atLeast or more then atMost chars left.
 void decfail(RVariable var)
           
 void decjump(RVariable var, RLabel label)
           
 void fail()
           
 void forget(RVariable var)
           
 void fork(RLabel forkLabel)
          Add a fork record to backtracing stack.
 void hardAssign(RVariable v, int value)
           
 void hint(int flags, int minLength, int maxLength)
           
 void jump(RLabel label)
           
 void mark(RLabel label)
          Makes the given label to refer to the next RMachine instruction.
 void mfEnd(int maxCount)
          maxCount got minCount subtracted from it!
 void mfStart(int headDecrement, int minCount)
           
 RLabel newLabel()
          Creates a new RMachine label.
 RVariable newTmpVar(int init)
          Creates a new RMachine temporary variable.
 RVariable newVar(java.lang.String name, boolean begin)
          Creates a new RMachine named variable.
private  RVariable newVarInt(java.lang.String nm)
           
 void pick(RVariable v)
          Store current character position (in the main buffer) into a given variable.
private  void printRange(char[] ranges)
           
 void shiftTable(boolean beginning, int charsAhead, char[] chars, int[] shifts)
           
 void skip()
          Increment current position by 1 (skip a character).
private  java.lang.String str(boolean neg, RLabel l)
           
 
Methods inherited from class kmy.regex.compiler.RMachine
finish, getExtensions, getNVars, init, makeRegex, setExtensions, setNoRefiller, tellName, tellPosition
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

out

java.io.PrintStream out

count

int count
Constructor Detail

RDebugMachine

public RDebugMachine()
Method Detail

str

private java.lang.String str(boolean neg,
                             RLabel l)

printRange

private void printRange(char[] ranges)

newVarInt

private RVariable newVarInt(java.lang.String nm)

newVar

public RVariable newVar(java.lang.String name,
                        boolean begin)
Description copied from class: RMachine
Creates a new RMachine named variable. Such variable can be used to hold position in the string that regex is being matched against. Every variable name actually corresponds to a substring so two positions are needed: one for the beginning of substring and one for the end (points to the first character after substring). Parameter begin is used to tell which variable is needed.
Overrides:
newVar in class RMachine

newLabel

public RLabel newLabel()
Description copied from class: RMachine
Creates a new RMachine label. Label can be used to mark RMachine instruction and can be jumped to.
Overrides:
newLabel in class RMachine

mark

public void mark(RLabel label)
Description copied from class: RMachine
Makes the given label to refer to the next RMachine instruction. Once a label is marked, it cannot be marked again.
Overrides:
mark in class RMachine

pick

public void pick(RVariable v)
Description copied from class: RMachine
Store current character position (in the main buffer) into a given variable. Adds an assignment-reversion record to backtracing stack.
Overrides:
pick in class RMachine

fail

public void fail()
Overrides:
fail in class RMachine

fork

public void fork(RLabel forkLabel)
Description copied from class: RMachine
Add a fork record to backtracing stack. If subsequent fail transfers control to this record, instruction pointer will be set to the given label.
Overrides:
fork in class RMachine

skip

public void skip()
Description copied from class: RMachine
Increment current position by 1 (skip a character).
Overrides:
skip in class RMachine

boundary

public void boundary(int boundaryClass)
Description copied from class: RMachine
Check if current position is on the certain type of boundary given by. boundaryClass. Boundary types:
  • '^' or 'A' - beginning of the string being matched.
  • '$' or 'Z' - end of the string being matched.
  • '<' - word beginning.
  • '>' - word end.
  • 'b' - word beginning or end.
  • 'B' - neither word beginning nor end.
Overrides:
boundary in class RMachine

assert

public void assert(char[] constStr)
Overrides:
assert in class RMachine

assert

public void assert(int charClass,
                   char[] ranges)
Description copied from class: RMachine
Make sure that current character belongs to the given character class. If it does, increment current char position by 1, otherwise fail. See kmy.regex.tree.CharSet and kmy.regex.tree.CharClassCodes.
Overrides:
assert in class RMachine

assert

public void assert(java.lang.String ref,
                   boolean picked)
Overrides:
assert in class RMachine

hardAssign

public void hardAssign(RVariable v,
                       int value)
Overrides:
hardAssign in class RMachine

newTmpVar

public RVariable newTmpVar(int init)
Description copied from class: RMachine
Creates a new RMachine temporary variable. Such variable can be used to hold loop counter or any other integer. Adds an assignment-reversion record to backtracing stack.
Overrides:
newTmpVar in class RMachine
Tags copied from class: RMachine
Parameters:
init - initial value for the variable

decjump

public void decjump(RVariable var,
                    RLabel label)
Overrides:
decjump in class RMachine

decfail

public void decfail(RVariable var)
Overrides:
decfail in class RMachine

forget

public void forget(RVariable var)
Overrides:
forget in class RMachine

jump

public void jump(RLabel label)
Overrides:
jump in class RMachine

hint

public void hint(int flags,
                 int minLength,
                 int maxLength)
Overrides:
hint in class RMachine

mfStart

public void mfStart(int headDecrement,
                    int minCount)
Overrides:
mfStart in class RMachine

mfEnd

public void mfEnd(int maxCount)
Description copied from class: RMachine
maxCount got minCount subtracted from it!
Overrides:
mfEnd in class RMachine

condJump

public void condJump(char[] ranges,
                     RLabel label)
Description copied from class: RMachine
Jump if char is NOT in range
Overrides:
condJump in class RMachine

condJump

public void condJump(int atLeastCharLeft,
                     int atMostCharLeft,
                     RLabel label)
Description copied from class: RMachine
Jump if less then atLeast or more then atMost chars left. If it is hard to determine how much left, it is OK not to jump.
Overrides:
condJump in class RMachine

condJump

public void condJump(char c,
                     RLabel label)
Description copied from class: RMachine
Jump if char is NOT one that is given.
Overrides:
condJump in class RMachine

shiftTable

public void shiftTable(boolean beginning,
                       int charsAhead,
                       char[] chars,
                       int[] shifts)
Overrides:
shiftTable in class RMachine