|
SWT LPEX v3.0.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.lpex.core.LpexCharStream
A stream interface for LPEX document parsers. This class feeds a lexer with the text in an LPEX document view, formatted as a stream of Unicode characters. It also provides methods for a document parser to set element classes and styles in the text.
Field Summary | |
---|---|
StringBuffer | bufferStyles
The current styles for the text element in the stream buffer. |
Fields inherited from interface com.ibm.lpex.cc.UCode_CharStream |
---|
staticFlag |
Constructor Summary | |
---|---|
LpexCharStream(LpexView lpexView)
Constructor. |
Method Summary | |
---|---|
void | backup(int amount)
Back up input stream by amount steps. |
void | backupToStart()
Go (back) to the start of the current element. |
char | BeginToken()
Return the next character that marks the beginning of the next token. |
void | Done()
The lexer calls this method to indicate it is done with the stream, so that we can free any resources we hold. |
boolean | EOFSeen()
Check whether EOF was encountered on the last character read. |
int | Expand(int endElement)
Expand the existing stream in the same LpexView with one or more elements. |
int | getBeginColumn()
Return ONE-based column number of the first character for the current token (being matched after the last call to BeginToken()). |
int | getBeginLine()
Return the element number of the first character for the current token (being matched after the last call to BeginToken()). |
int | getEndColumn()
Return ONE-based column number of the last character for the current token (being matched after the last call to BeginToken()). |
int | getEndElement()
Return the end element of the parse range. |
int | getEndLine()
Return the element number of the last character for the current token (being matched after the last call to BeginToken()). |
String | GetImage()
Return the string from the marked token-beginning to the current buffer position. |
LpexView | getLpexView()
Return the document view that provides this input stream. |
char[] | GetSuffix(int len)
Return an array of characters that make up the suffix of length len for the currently matched token. |
void | Init(int beginElement,
int beginPosition,
int endElement,
long classClear,
long classSet,
char styleDefault,
boolean clearPending)
Initialize the stream for a parse range, for a specific document parser. |
void | Init(int beginElement,
int endElement,
long classClear,
long classSet,
char styleDefault,
boolean clearPending)
Initialize the stream for a parse range, for a specific document parser. |
char | readChar()
Return the next character in the stream. |
void | setClasses(long classes)
Set additional classes in the current element. |
void | setCurrentStyles()
Set the styles and classes of the current element in the editor. |
boolean | setMargins(int beginMargin,
int endMargin,
char outMarginsStyle)
Set a begin and/or an end margin for the characters to return. |
void | setStyles(int beginCol,
int endCol,
char style)
Set additional styles in the current element. |
void | skipChar()
Skip a character in the stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public StringBuffer bufferStyles
Constructor Detail |
public LpexCharStream(LpexView lpexView)
Method Detail |
public final char readChar() throws IOException
An attempt to read a character beyond the end element of the stream will throw a java.io.EOFException. The range of elements in the stream is specified by beginElement .. endElement in methods Init() and Expand().
public final int getEndColumn()
public final int getEndLine()
public final int getBeginColumn()
public final int getBeginLine()
public final void backup(int amount)
This method may back up to a previous element (an element previously readChar()-ed in this stream). The same margins setting is assumed for previous elements as is now in effect.
public final char BeginToken() throws IOException
Note: LpexCharStream guarantees that all the characters remain in the buffer between two successive calls to this method (i.e., the characters from tokenBegin on), so that backup() works correctly.
public String GetImage()
The current implementation of this method always returns an empty string ("").
public char[] GetSuffix(int len)
The current implementation of this method always returns an array which contains just one ('\n') character.
public void Done()
public final void Init(int beginElement, int endElement, long classClear, long classSet, char styleDefault, boolean clearPending)
public final void Init(int beginElement, int beginPosition, int endElement, long classClear, long classSet, char styleDefault, boolean clearPending)
public final boolean setMargins(int beginMargin, int endMargin, char outMarginsStyle)
Method readChar() only returns characters that are positioned in columns beginMargin .. endMargin of text elements. The first column of a text element is 1. Setting margins for the characters to be considered as part of the input stream buffer received by the parser is useful in certain column-sensitive languages, such as PL/I.
A call to Init() clears any margins in effect: all the characters in the text elements of the view will be returned by subsequent readChar() calls.
The style indicated will be set in the editor (by setCurrentStyles()) for the characters outside the margins in effect.
public final int Expand(int endElement)
If any margins were previously set, they remain in effect. If endElement is not above the current end element, no change takes place in the existing range.
public final LpexView getLpexView()
public final int getEndElement()
public final boolean EOFSeen()
public final void skipChar()
public final void backupToStart()
public final void setStyles(int beginCol, int endCol, char style)
Style characters for the text element in the stream buffer are being set by the document parser (e.g., through this method) as it parses the tokens; then, the entire styles string is automatically set in the editor by LpexCharStream (through setCurrentStyles()) when a new element is read in.
public final void setClasses(long classes)
The current classes for the text element in the stream buffer are being set by the document parser (through this method) as it parses the tokens; then, the accumulated classes bit-mask is automatically set in the editor by LpexCharStream (through setCurrentStyles()) when a new element is read in.
public final void setCurrentStyles()
This method is called automatically by LpexCharStream when a new element is being read in an attempt to fill the stream buffer for the next readChar(). A parser may want to explicitly call this method when, for example, a lexical error caused by EOF was raised (i.e., after LpexCharStream has already called this method for the element), in order to update the element with this error's styles & classes. A parser may also call this method when switching to another subparser (lexer) for the rest of an element.
If margin settings are in effect, the style indicated by outMarginsStyle in setMargins() will be set in the editor for all the characters outside the margins.
|
SWT LPEX v3.0.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |