|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.borland.primetime.editor.AbstractScanner
This class is the abstract base for language scanner classes used for syntax highlighting.
The scanner operates on one line at a time, and it's built to be able to do incremental updates of the syntax information. It starts scanning on the line on which the change began, and stops scanning when it reaches a line that has no style changes from what it was in the previous scan.
Subclasses will override this class to deal with the keywords specific to the language the scanner is being built for. Note that all of the token recognition methods were built for the Java language, but all of them can be overridden in a subclass to deal with languages that have different rules. For example, if the language has different comment rules, the checkComment(...) method will also need to be overridden.
EditorDocument.StyledLeafElement
,
EditorDocument.RunInfo
,
ScannerJava
Field Summary | |
protected int |
bp
The buffer pointer. |
protected char[] |
buf
The input buffer. |
protected char |
ch
The last character read. |
static char |
EOF
|
protected static int |
IN_COMMENT
In a comment |
protected static int |
NORMAL
Not in a comment |
protected int |
stateFlags
The scanner state after the last token was read. |
Constructor Summary | |
AbstractScanner()
|
Method Summary | |
protected int |
checkComment(int initialState)
Check to see if the buffer pointer is on a comment character. |
protected int |
checkIdentifier(int initialState)
Check to see if the buffer pointer is on the start of an identifier. |
protected int |
checkNumber(int initialState)
Check to see if the buffer pointer is on a numeric character. |
protected int |
checkString(int initialState)
Check to see if the buffer pointer is on a string character. |
protected int |
checkSymbol(int initialState)
Check to see if the buffer pointer is on a symbol character. |
protected int |
checkWhitespace(int initialState)
Check to see if the buffer pointer is on a whitespace character. |
protected void |
initialize(javax.swing.text.Segment text)
initialize is called before starting a scan. |
protected void |
initialize(javax.swing.text.Segment text,
javax.swing.text.Segment text2)
|
protected static int |
initMap(java.util.HashMap map,
java.lang.String[] words,
boolean caseSensitive)
Internal routine to intialize a HashMap with words to look up and associated integer values |
protected abstract boolean |
isExtendedKeyword(java.lang.String str)
The default implementation of checkIdentifier will call this method to determine whether or not a particular string is an extended keyword. |
protected abstract boolean |
isKeyword(java.lang.String str)
The default implementation of checkIdentifier will call this method to determine whether or not a particular string is a keyword. |
protected boolean |
isSymbol(char ch)
The default implementation of checkSymbol will call this method to determine whether or not a particular character is a valid symbol. |
protected boolean |
isValidIdentifierPart(char ch)
The default implementation of checkIdentifier will call this method to determine whether or not a particular character can be a part of an identifier. |
protected boolean |
isValidIdentifierStart(char ch)
The default implementation of checkIdentifier will call this method to determine whether or not a particular character can be the start of an identifier. |
protected int |
nextToken(int initialState)
nextToken is called by scanLine to read the next run. |
void |
parse(javax.swing.event.DocumentEvent e)
the parse method is called externally to start the scanner. |
protected boolean |
scanLine(EditorDocument.StyledLeafElement leaf,
EditorDocument.StyledLeafElement leaf2,
int initialState)
|
protected boolean |
scanLine(EditorDocument.StyledLeafElement leaf,
int initialState)
scanLine is called by parse to actually scan a leaf of the document (which corresponds to a line of text). |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final char EOF
protected static final int NORMAL
protected static final int IN_COMMENT
protected char[] buf
protected int bp
protected char ch
protected int stateFlags
Constructor Detail |
public AbstractScanner()
Method Detail |
protected static int initMap(java.util.HashMap map, java.lang.String[] words, boolean caseSensitive)
map
- the HashMap to fillwords
- the words to put into the hash map as keyscaseSensitive
- the words to put into the hash map as keyspublic void parse(javax.swing.event.DocumentEvent e)
e
- The DocumentEvent that generated this parse call. From this
event, the scanner determines where to start parsing and how
much of the document must be processed.protected boolean scanLine(EditorDocument.StyledLeafElement leaf, int initialState)
leaf
- the leaf of the document that needs to be scanned.stateFlags
- The flags in effect at the start of this line. This
state carries over from previous lines, and retains information
such as whether the scanner should treat this line as part of a
multi-line comment block.protected boolean scanLine(EditorDocument.StyledLeafElement leaf, EditorDocument.StyledLeafElement leaf2, int initialState)
protected void initialize(javax.swing.text.Segment text)
text
- A Segment object that contains the text that needs to be scanned.protected void initialize(javax.swing.text.Segment text, javax.swing.text.Segment text2)
protected int nextToken(int initialState)
initalState
- The state of the scanner when nextToken was called.protected abstract boolean isKeyword(java.lang.String str)
str
- the string to be checkedcheckIdentifier
protected abstract boolean isExtendedKeyword(java.lang.String str)
str
- the string to be checkedcheckIdentifier
protected boolean isValidIdentifierStart(char ch)
ch
- the char to be checkedcheckIdentifier
protected boolean isValidIdentifierPart(char ch)
ch
- the char to be checkedcheckIdentifier
protected boolean isSymbol(char ch)
ch
- the char to be checkedcheckSymbol
protected int checkWhitespace(int initialState)
-1
otherwise.protected int checkComment(int initialState)
-1
otherwise.protected int checkIdentifier(int initialState)
-1
otherwise.isValidIdentifierStart
,
isValidIdentifierPart
,
isKeyword
,
isExtendedKeyword
protected int checkNumber(int initialState)
-1
otherwise.protected int checkString(int initialState)
-1
otherwise.protected int checkSymbol(int initialState)
-1
otherwise.isSymbol
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |