public class RuleBasedScanner extends java.lang.Object implements ICharacterScanner, ITokenScanner
true when calling isOther, unless the end
of the file is reached. In this case the token returns true when calling
isEOF.IRule| Modifier and Type | Field and Description |
|---|---|
protected int |
fColumn
The cached column of the current scanner position
|
protected IToken |
fDefaultReturnToken
The token to be returned by default if no rule fires
|
protected char[][] |
fDelimiters
The cached legal line delimiters of the document
|
protected IDocument |
fDocument
The document to be scanned
|
protected int |
fOffset
The offset of the next character to be read
|
protected int |
fRangeEnd
The end offset of the range to be scanned
|
protected IRule[] |
fRules
The list of rules of this scanner
|
protected int |
fTokenOffset
The offset of the last read token
|
protected static int |
UNDEFINED
Internal setting for the un-initialized column cache.
|
EOF| Constructor and Description |
|---|
RuleBasedScanner()
Creates a new rule based scanner which does not have any rule.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getColumn()
Returns the column of the character scanner.
|
char[][] |
getLegalLineDelimiters()
Provides rules access to the legal line delimiters.
|
int |
getTokenLength()
Returns the length of the last token read by this scanner.
|
int |
getTokenOffset()
Returns the offset of the last token read by this scanner.
|
IToken |
nextToken()
Returns the next token in the document.
|
int |
read()
Returns the next character or EOF if end of file has been reached
|
void |
setDefaultReturnToken(IToken defaultReturnToken)
Configures the scanner's default return token.
|
void |
setRange(IDocument document,
int offset,
int length)
Configures the scanner by providing access to the document range that should
be scanned.
|
void |
setRules(IRule[] rules)
Configures the scanner with the given sequence of rules.
|
void |
unread()
Rewinds the scanner before the last read character.
|
protected IRule[] fRules
protected IToken fDefaultReturnToken
protected IDocument fDocument
protected char[][] fDelimiters
protected int fOffset
protected int fRangeEnd
protected int fTokenOffset
protected int fColumn
protected static final int UNDEFINED
public RuleBasedScanner()
public void setRules(IRule[] rules)
rules - the sequence of rules controlling this scannerpublic void setDefaultReturnToken(IToken defaultReturnToken)
defaultReturnToken - the default return tokenpublic void setRange(IDocument document,
int offset,
int length)
ITokenScannersetRange in interface ITokenScannerdocument - the document to scanoffset - the offset of the document range to scanlength - the length of the document range to scanpublic int getTokenOffset()
ITokenScannergetTokenOffset in interface ITokenScannerpublic int getTokenLength()
ITokenScannergetTokenLength in interface ITokenScannerpublic int getColumn()
ICharacterScannergetColumn in interface ICharacterScannerpublic char[][] getLegalLineDelimiters()
ICharacterScannergetLegalLineDelimiters in interface ICharacterScannerpublic IToken nextToken()
ITokenScannernextToken in interface ITokenScannerpublic int read()
ICharacterScannerread in interface ICharacterScannerpublic void unread()
ICharacterScannerunread in interface ICharacterScanner