java_cup
public class lexer extends java.lang.Object
Symbols currently returned include:
Symbol Constant Returned Symbol Constant Returned ------ ----------------- ------ ----------------- "package" PACKAGE "import" IMPORT "code" CODE "action" ACTION "parser" PARSER "terminal" TERMINAL "non" NON "init" INIT "scan" SCAN "with" WITH "start" START "precedence" PRECEDENCE "left" LEFT "right" RIGHT "nonassoc" NONASSOC "%prec PRECENT_PREC [ LBRACK ] RBRACK ; SEMI , COMMA * STAR . DOT : COLON ::= COLON_COLON_EQUALS | BAR identifier ID {:...:} CODE_STRING "nonterminal" NONTERMINALAll symbol constants are defined in sym.java which is generated by JavaCup from parser.cup.
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.
This class is "static" (i.e., it has only static members and methods).
Modifier and Type | Field and Description |
---|---|
protected static int |
absolute_position
Character position in current line.
|
protected static java.util.Hashtable |
char_symbols
Table of single character symbols.
|
protected static int |
current_line
Current line number for use in error messages.
|
protected static int |
current_position
Character position in current line.
|
protected static int |
EOF_CHAR
EOF constant.
|
static int |
error_count
Count of total errors detected so far.
|
protected static java.util.Hashtable |
keywords
Table of keywords.
|
protected static int |
next_char
First character of lookahead.
|
protected static int |
next_char2
Second character of lookahead.
|
protected static int |
next_char3
Second character of lookahead.
|
protected static int |
next_char4
Second character of lookahead.
|
static int |
warning_count
Count of warnings issued so far
|
Modifier and Type | Method and Description |
---|---|
protected static void |
advance()
Advance the scanner one character in the input stream.
|
static Symbol |
debug_next_token()
Debugging version of next_token().
|
protected static Symbol |
do_code_string()
Swallow up a code string.
|
protected static Symbol |
do_id()
Process an identifier.
|
static void |
emit_error(java.lang.String message)
Emit an error message.
|
static void |
emit_warn(java.lang.String message)
Emit a warning message.
|
protected static int |
find_single_char(int ch)
Try to look up a single character symbol, returns -1 for not found.
|
protected static boolean |
id_char(int ch)
Determine if a character is ok for the middle of an id.
|
protected static boolean |
id_start_char(int ch)
Determine if a character is ok to start an id.
|
static void |
init()
Initialize the scanner.
|
static Symbol |
next_token()
Return one Symbol.
|
protected static Symbol |
real_next_token()
The actual routine to return one Symbol.
|
protected static void |
swallow_comment()
Handle swallowing up a comment.
|
protected static int next_char
protected static int next_char2
protected static int next_char3
protected static int next_char4
protected static final int EOF_CHAR
protected static java.util.Hashtable keywords
protected static java.util.Hashtable char_symbols
protected static int current_line
protected static int current_position
protected static int absolute_position
public static int error_count
public static int warning_count
public static void init() throws java.io.IOException
java.io.IOException
protected static void advance() throws java.io.IOException
java.io.IOException
public static void emit_error(java.lang.String message)
message
- the message to print.public static void emit_warn(java.lang.String message)
message
- the message to print.protected static boolean id_start_char(int ch)
ch
- the character in question.protected static boolean id_char(int ch)
ch
- the character in question.protected static int find_single_char(int ch)
ch
- the character in question.protected static void swallow_comment() throws java.io.IOException
java.io.IOException
protected static Symbol do_code_string() throws java.io.IOException
java.io.IOException
protected static Symbol do_id() throws java.io.IOException
java.io.IOException
public static Symbol next_token() throws java.io.IOException
java.io.IOException
public static Symbol debug_next_token() throws java.io.IOException
java.io.IOException
protected static Symbol real_next_token() throws java.io.IOException
java.io.IOException