| java.lang.Object org.isqlviewer.sql.processor.AbstractProcessor
All known Subclasses: org.isqlviewer.sql.processor.SqlProcessor,
AbstractProcessor | abstract public class AbstractProcessor (Code) | | TODO Add Scanner JavaDoc inforamation
author: Mark A. Kobold <mkobold at isqlviewer dot com> version: 1.0 |
Field Summary | |
protected char[] | buffer The current buffer of text being scanned. | protected int | end The end offset in the buffer. | protected int | start The current offset within the buffer, at which to scan the next token. | protected TokenType | state The current scanner state, as a representative token type. | protected TreeMap<String, TextSymbol> | symbolTable The symbol table can be accessed by initSymbolTable or lookup , if they are
overridden. |
Method Summary | |
public int | change(int firstIndex, int len, int newLen) Report the position of an edit, the length of the text being replaced, and the length of the replacement text, to
prepare for rescanning. | public int | find(int p) Find the index of the valid token starting before, but nearest to, text position p. | public Token | getToken(int n) Find the n'th token, or null if it is not currently valid. | abstract protected void | initSymbolTable() Create the initial symbol table. | protected TextSymbol | lookup(TokenType type, String name) Lookup a symbol in the symbol table. | public int | position() Find out at what text position any remaining scanning work should start, or -1 if scanning is complete. | protected TokenType | read()
Read one token from the start of the current text buffer, given the start offset, end offset, and current scanner
state. | public int | scan(char[] array, int offset, int length) Scan or rescan a given read-only segment of text. | public int | size() Find the number of available valid tokens, not counting tokens in or after any area yet to be rescanned. |
buffer | protected char[] buffer(Code) | | The current buffer of text being scanned.
|
end | protected int end(Code) | | The end offset in the buffer.
|
start | protected int start(Code) | | The current offset within the buffer, at which to scan the next token.
|
state | protected TokenType state(Code) | | The current scanner state, as a representative token type.
|
symbolTable | protected TreeMap<String, TextSymbol> symbolTable(Code) | | The symbol table can be accessed by initSymbolTable or lookup , if they are
overridden. Symbols are inserted with symbolTable.put(sym,sym) and extracted with
symbolTable.get(sym) .
|
AbstractProcessor | public AbstractProcessor()(Code) | | |
change | public int change(int firstIndex, int len, int newLen)(Code) | | Report the position of an edit, the length of the text being replaced, and the length of the replacement text, to
prepare for rescanning. The call returns the index of the token at which rescanning will start.
|
find | public int find(int p)(Code) | | Find the index of the valid token starting before, but nearest to, text position p. This uses an O(log(n)) binary
chop search.
|
getToken | public Token getToken(int n)(Code) | | Find the n'th token, or null if it is not currently valid.
|
initSymbolTable | abstract protected void initSymbolTable()(Code) | | Create the initial symbol table. This can be overridden to enter keywords, for example. The default
implementation does nothing.
|
lookup | protected TextSymbol lookup(TokenType type, String name)(Code) | | Lookup a symbol in the symbol table. This can be overridden to implement keyword detection, for example. The
default implementation just uses the table to ensure that there is only one shared occurrence of each symbol.
|
position | public int position()(Code) | | Find out at what text position any remaining scanning work should start, or -1 if scanning is complete.
|
read | protected TokenType read()(Code) | |
Read one token from the start of the current text buffer, given the start offset, end offset, and current scanner
state. The method moves the start offset past the token, updates the scanner state, and returns the type of the
token just scanned.
The scanner state is a representative token type. It is either the state left after the last call to read, or the
type of the old token at the same position if rescanning, or WHITESPACE if at the start of a document. The method
succeeds in all cases, returning whitespace or comment or error tokens where necessary. Each line of a multi-line
comment is treated as a separate token, to improve incremental rescanning. If the buffer does not extend to the
end of the document, the last token returned for the buffer may be incomplete and the caller must rescan it. The
read method can be overridden to implement different languages. The default version splits plain text into words,
numbers and punctuation.
|
scan | public int scan(char[] array, int offset, int length)(Code) | | Scan or rescan a given read-only segment of text. The segment is assumed to represent a portion of the document
starting at position() . Return the number of tokens successfully scanned, excluding any partial
token at the end of the text segment but not at the end of the document. If the result is 0, the call should be
retried with a longer segment.
|
size | public int size()(Code) | | Find the number of available valid tokens, not counting tokens in or after any area yet to be rescanned.
|
|
|