|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.io.TokenAdapter
public class TokenAdapter
Default generic lexical token implementation.
This is a simple implementation for any kind of lexical token object, which
is constructed by some form of lexical analyzer (lexer) such as any that
implements the LexerI
interface. A token object represents a single
lexical entity from an input source text stream. A lexer provides a stream of
tokens read from such an input stream, which can then be used by a syntactical
parser (such as any that implements the ParserI
interface) for parsing
sequences of source tokens into a symbol table or parse tree.
A token object has the following attributes:
Field Summary | |
---|---|
protected int |
m_colNo
Source column number. |
protected java.lang.String |
m_fileName
Source filename. |
protected int |
m_lineNo
Source line number. |
protected java.lang.String |
m_text
Token text. |
protected int |
m_tok
Token code. |
(package private) static java.lang.String |
REV
Revision information. |
Constructor Summary | |
---|---|
TokenAdapter()
Default constructor. |
|
TokenAdapter(int type,
java.lang.String text,
int ln)
Constructor. |
|
TokenAdapter(int type,
java.lang.String text,
int ln,
int col)
Constructor. |
|
TokenAdapter(int type,
java.lang.String text,
java.lang.String fname,
int ln,
int col)
Constructor. |
|
TokenAdapter(java.lang.String text)
Constructor. |
Method Summary | |
---|---|
void |
copyFrom(TokenAdapter tok)
Copy the contents of another token into this token. |
void |
dump(java.io.PrintWriter out)
Dump the contents of this token to a (debugging) output stream. |
int |
getColumnNumber()
Retrieve the source column number of this token. |
java.lang.String |
getFileName()
Retrieve the source filename of this token. |
int |
getLineNumber()
Retrieve the source line number of this token. |
java.lang.String |
getText()
Retrieve the textual contents of this token. |
int |
getType()
Retrieve the type code of this token. |
void |
setColumnNumber(int col)
Establish the source column number of this token. |
void |
setFileName(java.lang.String fname)
Establish the source filename of this token. |
void |
setLineNumber(int ln)
Establish the source line number of this token. |
void |
setText(java.lang.String text)
Establish the textual contents of this token. |
void |
setType(int type)
Establish the token type code of this token. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
protected int m_tok
protected java.lang.String m_text
protected int m_lineNo
protected int m_colNo
protected java.lang.String m_fileName
Constructor Detail |
---|
public TokenAdapter()
public TokenAdapter(java.lang.String text)
text
- The string containing the textual contents for this token.public TokenAdapter(int type, java.lang.String text, int ln)
type
- The token type code for this token.text
- The string containing the textual contents for this token.ln
- The source line number for this token.public TokenAdapter(int type, java.lang.String text, int ln, int col)
type
- The token type code for this token.text
- The string containing the textual contents for this token.ln
- The source line number for this token.col
- The source column number for this token.public TokenAdapter(int type, java.lang.String text, java.lang.String fname, int ln, int col)
type
- The token type code for this token.text
- The string containing the textual contents for this token.fname
- The source filename for this token.ln
- The source line number for this token.col
- The source column number for this token.Method Detail |
---|
public void setText(java.lang.String text)
setText
in interface TokenI
text
- The string containing the textual contents for this token.public java.lang.String getText()
getText
in interface TokenI
public void setType(int type)
setType
in interface TokenI
type
- The token type code for this token.public int getType()
getType
in interface TokenI
public void setLineNumber(int ln)
setLineNumber
in interface TokenI
ln
- The source line number for this token.
If this number is negative, the line number setting of this token is not
modified.public int getLineNumber()
getLineNumber
in interface TokenI
public void setColumnNumber(int col)
setColumnNumber
in interface TokenI
col
- The source column number for this token.
If this number is negative, the column number setting of this token is not
modified.public int getColumnNumber()
getColumnNumber
in interface TokenI
public void setFileName(java.lang.String fname)
setFileName
in interface TokenI
fname
- The source filename for this token.public java.lang.String getFileName()
getFileName
in interface TokenI
public void dump(java.io.PrintWriter out)
dump
in interface TraceableI
out
- A (debugging) output stream.public void copyFrom(TokenAdapter tok)
tok
- Another token to copy from.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |