|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.io.LexerAdapter
public abstract class LexerAdapter
Generic lexical analyzer (lexer) adapter.
This class is used as an abtract base class upon which to implement any kind
of lexical analyzer (lexer), which reads characters from an input source
stream (implementing the java.io.Reader class) and converting it into
a stream of tokens (which implement the TokenI
interface).
Such a lexer stream can be used to read the underlying source text for a
parser, such as those implementing the ParserI
interface.
ParserI
,
TokenI
,
CharReader
Field Summary | |
---|---|
protected int |
m_colNo
Input source column number. |
protected java.lang.String |
m_fName
Input source filename. |
protected java.io.Reader |
m_in
Lexer input stream. |
protected int |
m_lineNo
Input source line number. |
protected DiagnosticOutputI |
m_out
Diagnostic message output stream. |
(package private) static java.lang.String |
REV
Revision information. |
Constructor Summary | |
---|---|
protected |
LexerAdapter()
Default constructor. |
|
LexerAdapter(java.io.Reader in)
Constructor. |
Method Summary | |
---|---|
void |
close()
Close and disassociate the underlying input stream from this lexer. |
protected void |
finalize()
Finalization. |
TokenI |
getToken()
Read the next token from the input stream. |
abstract boolean |
getToken(TokenI tok)
Read the next token from the lexer input stream. |
void |
setInput(java.io.Reader in)
Establish the input stream for this lexer from which to read tokens. |
void |
setOutput(DiagnosticOutputI out)
Establish the output stream to which diagnostic messages (warning and error messages) are written during parsing. |
void |
setSourceName(java.lang.String fname)
Establish the input source filename. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
protected java.io.Reader m_in
protected DiagnosticOutputI m_out
protected java.lang.String m_fName
protected int m_lineNo
protected int m_colNo
Constructor Detail |
---|
public LexerAdapter(java.io.Reader in)
in
- A character input stream from which to read tokens.protected LexerAdapter()
Method Detail |
---|
public void setOutput(DiagnosticOutputI out)
setOutput
in interface DiagnosticWriterI
out
- The error output stream.public void setInput(java.io.Reader in)
setInput
in interface LexerI
in
- A character input stream from which to read tokens.public void setSourceName(java.lang.String fname)
setSourceName
in interface LexerI
fname
- The source filename.public void close()
close
in interface LexerI
public TokenI getToken() throws java.io.IOException
Either this method or getToken(TokenI)
may be used
interchangeably.
getToken
in interface LexerI
java.io.IOException
- Thrown if an I/O error or parsing error occurs.public abstract boolean getToken(TokenI tok) throws java.io.IOException
Either this method or getToken()
may be used interchangeably.
This method might be more efficient, since a new token object does not
need to be allocated on each call.
getToken
in interface LexerI
tok
- The token object which is filled in with the next token read from the
input stream.
java.io.IOException
- Thrown if an I/O error or parsing error occurs.protected void finalize() throws java.lang.Throwable
m_in
) from this lexer.
Also disassociates the diagnostic output stream (m_out
) from this
lexer.
finalize
in class java.lang.Object
java.lang.Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |