kmy.regex.interp
Class RInterpMachine
java.lang.Object
|
+--kmy.regex.compiler.RMachine
|
+--kmy.regex.interp.RInterpMachine
- public class RInterpMachine
- extends RMachine
- implements RInterpCommands, CharClassCodes
| Fields inherited from interface kmy.regex.interp.RInterpCommands |
ASSERT_CHAR,
ASSERT_CLASS,
ASSERT_CLASS_RANGE,
ASSERT_EXT_VAR,
ASSERT_RANGE,
ASSERT_VAR,
ASSIGN,
BOUNDARY,
CHARLEFT,
DECFAIL,
DECJUMP,
FAIL,
FORK,
HARDASSIGN,
JUMP,
JUMP_CHAR,
JUMP_MAX_LEFT,
JUMP_MIN_LEFT,
JUMP_RANGE,
MFEND,
MFENDLIMIT,
MFSTART,
MFSTART_HEAD,
PICK,
SHIFTTBL,
SKIP,
SKIP_NON_NEWLINE,
STOP |
|
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()
|
private void |
finishLabels(byte[] codes)
|
void |
forget(RVariable var)
|
void |
fork(RLabel forkLabel)
Add a fork record to backtracing stack. |
int |
getNVars()
|
void |
hardAssign(RVariable v,
int value)
|
void |
hint(int flags,
int minLength,
int maxLength)
|
void |
jump(RLabel label)
|
Regex |
makeRegex()
|
void |
mark(RLabel label)
Makes the given label to refer to the next RMachine instruction. |
void |
mfEnd(int max)
maxCount got minCount subtracted from it! |
void |
mfStart(int headDecrement,
int min)
|
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. |
void |
pick(RVariable v)
Store current character position (in the main buffer) into a given variable. |
void |
shiftTable(boolean beginning,
int charsAhead,
char[] chars,
int[] shifts)
|
void |
skip()
Increment current position by 1 (skip a character). |
private void |
writeCode(int code)
|
private void |
writeLabel(RLabel rl)
|
| Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
buf
java.io.ByteArrayOutputStream buf
vars
java.util.Hashtable vars
varCells
int varCells
extCells
int extCells
minLength
int minLength
maxLength
int maxLength
flags
int flags
labelUses
java.util.Vector labelUses
mfLabel
RInterpMachine.Label mfLabel
RInterpMachine
public RInterpMachine()
writeLabel
private void writeLabel(RLabel rl)
writeCode
private void writeCode(int code)
finishLabels
private void finishLabels(byte[] codes)
makeRegex
public Regex makeRegex()
- Overrides:
- makeRegex in class RMachine
getNVars
public int getNVars()
- Overrides:
- getNVars in class RMachine
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
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
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
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(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(char[] constStr)
- 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
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
fail
public void fail()
- Overrides:
- fail 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 min)
- Overrides:
- mfStart in class RMachine
mfEnd
public void mfEnd(int max)
- Description copied from class: RMachine
- maxCount got minCount subtracted from it!
- Overrides:
- mfEnd in class RMachine
condJump
public void condJump(char[] ranges,
RLabel label)
- Jump if char is NOT in range
- Overrides:
- condJump in class RMachine
condJump
public void condJump(int atLeastCharLeft,
int atMostCharLeft,
RLabel label)
- Jump if less then atLeast or more then atMost chars left
- Overrides:
- condJump in class RMachine
condJump
public void condJump(char c,
RLabel label)
- 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