public class MultiSyntax extends Syntax
Modifier and Type | Class and Description |
---|---|
static class |
MultiSyntax.MultiStateInfo
Class that can contain any number of the additional state infos from
other syntaxes.
|
Syntax.BaseStateInfo, Syntax.StateInfo
buffer, DIFFERENT_STATE, EQUAL_STATE, INIT, lastBuffer, offset, state, stopOffset, stopPosition, supposedTokenID, tokenContextPath, tokenLength, tokenOffset
Constructor and Description |
---|
MultiSyntax() |
Modifier and Type | Method and Description |
---|---|
int |
compareState(Syntax.StateInfo stateInfo)
Compare state of this analyzer to given state info.
|
Syntax.StateInfo |
createStateInfo()
Create state info appropriate for particular analyzer
|
void |
load(Syntax.StateInfo stateInfo,
char[] buffer,
int offset,
int len,
boolean lastBuffer,
int stopPosition)
Load the state from syntax mark into analyzer.
|
void |
loadInitState()
Initialize the analyzer when scanning from the begining
of the document or when the state stored in syntax mark
is null for some reason or to explicitly reset the analyzer
to the initial state.
|
protected void |
registerSyntax(Syntax slaveSyntax)
Register a particular slave syntax.
|
void |
storeState(Syntax.StateInfo stateInfo)
Store state of this analyzer into given mark state.
|
getBuffer, getOffset, getPreScan, getStateName, getSupposedTokenID, getTokenContextPath, getTokenLength, getTokenOffset, loadState, nextToken, parseToken, relocate, reset, toString
protected void registerSyntax(Syntax slaveSyntax)
public void storeState(Syntax.StateInfo stateInfo)
storeState
in class Syntax
public void loadInitState()
Syntax
loadInitState
in class Syntax
public void load(Syntax.StateInfo stateInfo, char[] buffer, int offset, int len, boolean lastBuffer, int stopPosition)
Syntax
load
in class Syntax
stateInfo
- info about the state of the lexical analyzer to load.
It can be null to indicate there's no previous state so the analyzer
starts from its initial state.buffer
- buffer that will be scannedoffset
- offset of the first character that will be scannedlen
- length of the area to be scannedlastBuffer
- whether this is the last buffer in the document. All the tokens
will be returned including the last possibly incomplete one. If the data
come from the document, the simple rule for this parameter
is (doc.getLength() == stop-position) where stop-position
is the position corresponding to the (offset + len) in the buffer
that comes from the document data.stopPosition
- position in the document that corresponds to (offset + len) offset
in the provided buffer. It has only sense if the data in the buffer come from the document.
It helps in writing the advanced analyzers that need to interact with some other data
in the document than only those provided in the character buffer.
If there is no relation to the document data, the stopPosition parameter
must be filled with -1 which means an invalid value.
The stop-position is passed (instead of start-position) because it doesn't
change through the analyzer operation. It corresponds to the stopOffset
that also doesn't change through the analyzer operation so any
buffer-offset can be transferred to position by computing
stopPosition + buffer-offset - stopOffset
where stopOffset is the instance variable that is assigned
to offset + len in the body of relocate().public Syntax.StateInfo createStateInfo()
Syntax
createStateInfo
in class Syntax
public int compareState(Syntax.StateInfo stateInfo)
compareState
in class Syntax