public class lexer extends Object
Tokens 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 ; SEMI
, COMMA * STAR
. DOT : COLON
::= COLON_COLON_EQUALS | BAR
identifier ID {:...:} CODE_STRING
All 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 token) 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 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 Hashtable |
keywords
Table of keywords.
|
protected static int |
next_char
First character of lookahead.
|
protected static int |
next_char2
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 java_cup.runtime.token |
debug_next_token()
Debugging version of next_token().
|
protected static java_cup.runtime.token |
do_code_string()
Swallow up a code string.
|
protected static java_cup.runtime.token |
do_id()
Process an identifier.
|
static void |
emit_error(String message)
Emit an error message.
|
static void |
emit_warn(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 java_cup.runtime.token |
next_token()
Return one token.
|
protected static java_cup.runtime.token |
real_next_token()
The actual routine to return one token.
|
protected static void |
swallow_comment()
Handle swallowing up a comment.
|
protected static int next_char
protected static int next_char2
protected static final int EOF_CHAR
protected static Hashtable keywords
protected static Hashtable char_symbols
protected static int current_line
protected static int current_position
public static int error_count
public static int warning_count
public static void init()
throws IOException
IOExceptionprotected static void advance()
throws IOException
IOExceptionpublic static void emit_error(String message)
message - the message to print.public static void emit_warn(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 IOException
IOExceptionprotected static java_cup.runtime.token do_code_string()
throws IOException
IOExceptionprotected static java_cup.runtime.token do_id()
throws IOException
IOExceptionpublic static java_cup.runtime.token next_token()
throws IOException
IOExceptionpublic static java_cup.runtime.token debug_next_token()
throws IOException
IOExceptionprotected static java_cup.runtime.token real_next_token()
throws IOException
IOExceptionCopyright © 2014. All Rights Reserved.