Logo Search packages:      
Sourcecode: jasmin-sable version File versions  Download package

java_cup::emit Class Reference

List of all members.

Detailed Description

This class handles emitting generated code for the resulting parser. The various parse tables must be constructed, etc. before calling any routines in this class.

Three classes are produced by this code:

symbol constant class
this contains constant declarations for each terminal (and optionally each non-terminal).
action class
this non-public class contains code to invoke all the user actions that were embedded in the parser specification.
parser class
the specialized parser class consisting primarily of some user supplied general and initialization code, and the parse tables.

Three parse tables are created as part of the parser class:

production table
lists the LHS non terminal number, and the length of the RHS of each production.
action table
for each state of the parse machine, gives the action to be taken (shift, reduce, or error) under each lookahead symbol.
reduce-goto table
when a reduce on a given production is taken, the parse stack is popped back a number of elements corresponding to the RHS of the production. This reveals a prior state, which we transition out of under the LHS non terminal symbol for the production (as if we had seen the LHS symbol rather than all the symbols matching the RHS). This table is indexed by non terminal numbers and indicates how to make these transitions.

In addition to the method interface, this class maintains a series of public global variables and flags indicating how misc. parts of the code and other output is to be produced, and counting things such as number of conflicts detected (see the source code and public variables below for more details).

This class is "static" (contains only static data and methods).

See also:
last update: 11/25/95
Scott Hudson

Definition at line 98 of file emit.java.

Static Public Member Functions

static boolean lr_values ()
static void parser (PrintWriter out, parse_action_table action_table, parse_reduce_table reduce_table, int start_st, production start_prod, boolean compact_reduces, boolean suppress_scanner) throws internal_error
static void symbols (PrintWriter out, boolean emit_non_terms, boolean sym_interface)

Static Public Attributes

static String action_code = null
static long action_code_time = 0
static long action_table_time = 0
static long goto_table_time = 0
static Stack import_list = new Stack()
static String init_code = null
static int not_reduced = 0
static boolean nowarn = false
static int num_conflicts = 0
static String package_name = null
static String parser_class_name = "parser"
static String parser_code = null
static long parser_time = 0
static String prefix = "CUP$"
static long production_table_time = 0
static String scan_code = null
static production start_production = null
static String symbol_const_class_name = "sym"
static long symbols_time = 0
static int unused_non_term = 0
static int unused_term = 0

Static Protected Member Functions

static void do_action_table (PrintWriter out, parse_action_table act_tab, boolean compact_reduces) throws internal_error
static int do_escaped (PrintWriter out, char c)
static int do_newline (PrintWriter out, int nchar, int nbytes)
static void do_reduce_table (PrintWriter out, parse_reduce_table red_tab)
static void do_table_as_string (PrintWriter out, short[][] sa)
static void emit_action_code (PrintWriter out, production start_prod) throws internal_error
static void emit_package (PrintWriter out)
static void emit_production_table (PrintWriter out)
static String pre (String str)
static void set_lr_values (boolean b)

Static Protected Attributes

static boolean _lr_values

Private Member Functions

 emit ()

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index