|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatt.grappa.Lexer
public class Lexer
A class for doing lexical analysis of dot formatted input.
Field Summary | |
---|---|
private java.util.Hashtable |
char_symbols
|
private java.lang.StringBuffer |
cmnstrbuf
common StringBuffer (suggested by Ginny Travers (bbn.com)) |
private int |
current_line
Current line number for use in error messages. |
private int |
current_position
Character position in current line. |
private static int |
EOF_CHAR
EOF constant. |
private int |
error_count
Count of total errors detected so far. |
private java.io.PrintWriter |
errWriter
|
private boolean |
haveId
needed to handle anonymous subgraphs since parser has no precedence |
private java.io.Reader |
inReader
|
private java.util.Hashtable |
keywords
hash tables to hold symbols |
private int |
next_char
First character of lookahead. |
private int |
next_char2
Second character of lookahead. |
private int |
old_char
needed for retreating |
private int |
old_position
|
(package private) boolean |
retreated
|
private int |
warning_count
Count of warnings issued so far |
Constructor Summary | |
---|---|
Lexer(java.io.Reader input,
java.io.PrintWriter error)
Create an instance of Lexer that reads from input and
sends error messages to error . |
Method Summary | |
---|---|
void |
advance()
Advance the scanner one character in the input stream. |
private Symbol |
do_html_string()
Swallow up an html-like string. |
private Symbol |
do_id()
Process an identifier. |
private Symbol |
do_quote_string()
Swallow up a quote string. |
private void |
emit_error(java.lang.String message)
Emit an error message. |
private void |
emit_warn(java.lang.String message)
Emit a warning message. |
private int |
find_single_char(int ch)
Try to look up a single character symbol, returns -1 for not found. |
java.lang.String |
getLocation()
Get the current location in the form "[line_number(character_offser)]". |
static boolean |
id_char(char ch)
Check if character is a valid id character; |
static boolean |
id_char(int ch)
Check if character is a valid id character; |
void |
init()
Initialize internal tables and read two characters of input for look-ahead purposes. |
Symbol |
next_token(int debugLevel)
Return one Symbol. |
private Symbol |
real_next_token()
The actual routine to return one Symbol. |
private void |
retreat()
|
private 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 |
---|
private int next_char
private int next_char2
private int current_line
private int current_position
private static final int EOF_CHAR
private boolean haveId
private int old_char
private int old_position
boolean retreated
private int error_count
private int warning_count
private java.util.Hashtable keywords
private java.util.Hashtable char_symbols
private java.io.Reader inReader
private java.io.PrintWriter errWriter
private java.lang.StringBuffer cmnstrbuf
Constructor Detail |
---|
public Lexer(java.io.Reader input, java.io.PrintWriter error) throws java.lang.IllegalArgumentException
Lexer
that reads from input
and
sends error messages to error
.
input
- input Reader
objecterror
- error output Writer
object
java.lang.IllegalArgumentException
- whenever input
is nullMethod Detail |
---|
public void init() throws java.io.IOException
java.io.IOException
- if advance()
doesadvance()
public void advance() throws java.io.IOException
java.io.IOException
- whenever a problem reading from input
is encounteredprivate void retreat()
private void emit_error(java.lang.String message)
message
- the message to print.public java.lang.String getLocation()
private void emit_warn(java.lang.String message)
message
- the message to print.public static boolean id_char(int ch)
ch
- the character in question.public static boolean id_char(char ch)
ch
- the character in question.private int find_single_char(int ch)
ch
- the character in question.private void swallow_comment() throws java.io.IOException
java.io.IOException
private Symbol do_quote_string() throws java.io.IOException
java.io.IOException
private Symbol do_html_string() throws java.io.IOException
java.io.IOException
private Symbol do_id() throws java.io.IOException
java.io.IOException
private Symbol real_next_token() throws java.io.IOException
java.io.IOException
public Symbol next_token(int debugLevel) throws java.io.IOException
java.io.IOException
- if advance()
does
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |