|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.raritantechnologies.utils.program.Lexer
This class implements a small scanner (aka lexical analyzer or lexer).
In addition to the scanner proper (called first via init() then with next_token() to get each Symbol) this class provides simple error and warning routines and keeps a count of errors and warnings that is publicly accessible.
| Field Summary | |
protected int |
absolute_position
Character position in entire query. |
protected boolean |
at_eof
State of the query stream |
protected char[] |
buf
build the token here. |
protected int |
buffer_position
Character position in the token buffer. |
protected static int |
BUFSIZ
|
protected int |
current_line
Current line number for use in error messages. |
protected int |
current_position
Character position in current line. |
protected static int |
EOF_CHAR
EOF constant. |
int |
error_count
Count of total errors detected so far. |
protected int |
ifLevel
If level (to support nested ifs) |
protected SymbolTable |
keywords
Symbol table holding keywords. |
protected int |
next_char
First character of lookahead. |
protected int |
next_char2
second character of lookahead. |
protected int |
parenLevel
Parenthesis level |
protected java.io.Reader |
reader_in
|
protected java.io.InputStream |
stream_in
Stream containing query to be parsed |
protected boolean |
then_clause
in the then clause or the else |
int |
warning_count
Count of warnings issued so far |
| Constructor Summary | |
Lexer(java.io.InputStream lexIn)
The constructor takes an inputStream as a parameter . |
|
Lexer(java.io.Reader lexIn)
The constructor takes a Reader as a parameter . |
|
| Method Summary | |
protected void |
advance()
Advance the scanner one character in the input stream. |
Token |
debug_next_token(java.util.HashMap typedef)
Debugging version of next_token(). |
void |
emit_error(java.lang.String message)
Emit an error message. |
void |
emit_warn(java.lang.String message)
Emit a warning message. |
int |
getCurrentLine()
Return the current line number |
int |
getCurrentPosition()
Return the current character position |
int |
getIfLevel()
Access to the ifLevel . |
int |
getParenLevel()
Access to the parenLevel . |
protected boolean |
id_char(int ch)
Determine if a character is ok for the middle of an id. |
protected boolean |
id_start_char(int ch)
Determine if a character is ok to start an id. |
void |
init_reader()
Initialize the scanner. |
void |
init_stream()
Initialize the scanner. |
Token |
next_token(java.util.HashMap typedef)
Return one Token. |
void |
push_token(Token t)
Pushes a token back onto the queue for re-evaluation |
protected Token |
real_next_token(java.util.HashMap typedef)
The actual routine to return one Token. |
protected void |
swallow_comment()
Handle swallowing up a comment. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final int EOF_CHAR
protected static final int BUFSIZ
protected java.io.InputStream stream_in
protected java.io.Reader reader_in
protected boolean at_eof
protected SymbolTable keywords
protected int next_char
protected int next_char2
protected char[] buf
protected int parenLevel
protected int ifLevel
protected boolean then_clause
protected int current_line
protected int current_position
protected int absolute_position
protected int buffer_position
public int error_count
public int warning_count
| Constructor Detail |
public Lexer(java.io.InputStream lexIn)
throws java.io.IOException
public Lexer(java.io.Reader lexIn)
throws java.io.IOException
| Method Detail |
public int getParenLevel()
public int getIfLevel()
public void init_stream()
throws java.io.IOException
java.io.IOException
public void init_reader()
throws java.io.IOException
java.io.IOException
protected void advance()
throws java.io.IOException
java.io.IOExceptionpublic int getCurrentLine()
public int getCurrentPosition()
public void emit_error(java.lang.String message)
message - the message to print.public void emit_warn(java.lang.String message)
message - the message to print.protected boolean id_start_char(int ch)
ch - the character in question.protected boolean id_char(int ch)
ch - the character in question.
protected void swallow_comment()
throws java.io.IOException
java.io.IOException
public Token next_token(java.util.HashMap typedef)
throws java.io.IOException
java.io.IOException
public Token debug_next_token(java.util.HashMap typedef)
throws java.io.IOException
java.io.IOExceptionpublic void push_token(Token t)
protected Token real_next_token(java.util.HashMap typedef)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||