All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class att.grappa.Parser

java.lang.Object
   |
   +----java_cup.runtime.lr_parser
           |
           +----att.grappa.Parser

public class Parser
extends lr_parser
This class provides a parser for the dot graph representation format. It is used in conjunction with JavaCup, a yacc-like parser generator originally by:

Scott E. Hudson
Graphics Visualization and Usability Center
Georgia Institute of Technology

and more recently modified and maintained by a number of people at Princeton University.

Version:
1.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Variable Index

 o _action_table
parse action table
 o _production_table
production table
 o _reduce_table
reduce_goto table
 o action_obj
instance of action encapsulation class

Constructor Index

 o Parser()
constructor
 o Parser(InputStream)
A convenience constructor equivalent to Parser(inputStream,null,null).
 o Parser(InputStream, OutputStream)
A convenience constructor equivalent to Parser(inputStream,errorStream,null).
 o Parser(InputStream, OutputStream, Graph)
Create an instance of Parser with input, error output and a supplied Graph object.
 o Parser(Reader)
A convenience constructor equivalent to Parser(inputReader,null,null).
 o Parser(Reader, PrintWriter)
A convenience constructor equivalent to Parser(inputReader,errorWriter,null).
 o Parser(Reader, PrintWriter, Graph)
Create an instance of Parser with input, error output and a supplied Graph object.

Method Index

 o action_table()
access to parse action table
 o debug_message(int, String)
Write a debugging message to the error stream.
 o debug_message(String)
Write a debugging message to the error stream.
 o debug_parse(int)
Invokes the parser in debug mode.
 o do_action(int, lr_parser, Stack, int)
invoke a user supplied parse action
 o EOF_sym()
EOF Symbol index
 o error_sym()
error Symbol index
 o getDebugLevel()
Get the debug level for this parser.
 o getErrorWriter()
Get the error writer, if any, for this parser.
 o getGraph()
Get the graph resulting from the parsing operations.
 o getLexer()
Get the Lexer object associated with this parser.
 o init_actions()
action encapsulation object initializer
 o production_table()
access to production table
 o reduce_table()
access to reduce_goto table
 o report_error(String, Object)
Report a fatal error.
 o report_warning(String, Object)
Report a non-fatal error.
 o scan()
scan to get the next Symbol
 o start_production()
start production
 o start_state()
start state
 o user_init()
user initialization

Variables

 o _production_table
 protected static final short _production_table[][]
production table

 o _action_table
 protected static final short _action_table[][]
parse action table

 o _reduce_table
 protected static final short _reduce_table[][]
reduce_goto table

 o action_obj
 protected CUP$actions action_obj
instance of action encapsulation class

Constructors

 o Parser
 public Parser()
constructor

 o Parser
 public Parser(Reader inputReader,
               PrintWriter errorWriter,
               Graph graph)
Create an instance of Parser with input, error output and a supplied Graph object. The graph object is cleared (reset) before new graph components are added to it by this parsing operation.

Parameters:
inputReader - input Reader object
errorWriter - error output Writer object (or null to suppress error output)
graph - Graph object for storing parsed graph information (or null to create a new object)
 o Parser
 public Parser(Reader inputReader,
               PrintWriter errorWriter)
A convenience constructor equivalent to Parser(inputReader,errorWriter,null).

Parameters:
inputReader - input Reader object
errorWriter - error output Writer object (or null to suppress error output)
 o Parser
 public Parser(Reader inputReader)
A convenience constructor equivalent to Parser(inputReader,null,null).

Parameters:
inputReader - input Reader object
 o Parser
 public Parser(InputStream inputStream,
               OutputStream errorStream,
               Graph graph)
Create an instance of Parser with input, error output and a supplied Graph object. The input stream is converted to a Reader and the error stream is converted to a Writer.

Parameters:
inputStream - input InputStream object
errorStream - error output OutputStream object (or null to suppress error output)
graph - Graph object for storing parsed graph information (or null to create a new object)
 o Parser
 public Parser(InputStream inputStream,
               OutputStream errorStream)
A convenience constructor equivalent to Parser(inputStream,errorStream,null).

Parameters:
inputStream - input InputStream object
errorStream - error output OutputStream object
 o Parser
 public Parser(InputStream inputStream)
A convenience constructor equivalent to Parser(inputStream,null,null).

Parameters:
inputStream - input InputStream object

Methods

 o production_table
 public short[][] production_table()
access to production table

Overrides:
production_table in class lr_parser
 o action_table
 public short[][] action_table()
access to parse action table

Overrides:
action_table in class lr_parser
 o reduce_table
 public short[][] reduce_table()
access to reduce_goto table

Overrides:
reduce_table in class lr_parser
 o init_actions
 protected void init_actions()
action encapsulation object initializer

Overrides:
init_actions in class lr_parser
 o do_action
 public Symbol do_action(int act_num,
                         lr_parser parser,
                         Stack stack,
                         int top) throws Exception
invoke a user supplied parse action

Overrides:
do_action in class lr_parser
 o start_state
 public int start_state()
start state

Overrides:
start_state in class lr_parser
 o start_production
 public int start_production()
start production

Overrides:
start_production in class lr_parser
 o EOF_sym
 public int EOF_sym()
EOF Symbol index

Overrides:
EOF_sym in class lr_parser
 o error_sym
 public int error_sym()
error Symbol index

Overrides:
error_sym in class lr_parser
 o user_init
 public void user_init() throws Exception
user initialization

Overrides:
user_init in class lr_parser
 o scan
 public Symbol scan() throws Exception
scan to get the next Symbol

Overrides:
scan in class lr_parser
 o getLexer
 public Lexer getLexer()
Get the Lexer object associated with this parser.

Returns:
the associated lexical analyzer.
 o getErrorWriter
 public PrintWriter getErrorWriter()
Get the error writer, if any, for this parser.

Returns:
the error writer for this parser.
 o getDebugLevel
 public int getDebugLevel()
Get the debug level for this parser. The debug level is set to a non-zero value by calling debug_parse.

Returns:
the debug level of this parser.
See Also:
debug_parse
 o report_error
 public void report_error(String message,
                          Object info) throws GraphParserException
Report a fatal error. Calling this method will throw a GraphParserException.

Parameters:
message - the error message to send to the error stream and include in the thrown exception
info - not used
Throws: GraphParserException
whenver this method is called
Overrides:
report_error in class lr_parser
 o report_warning
 public void report_warning(String message,
                            Object info)
Report a non-fatal error.

Parameters:
message - the warning message to send to the error stream, if the stream non-null.
info - not used
 o debug_message
 public void debug_message(String message)
Write a debugging message to the error stream. The debug level of the message is 5.

Parameters:
message - the debug message to send to the error stream, if the stream non-null.
Overrides:
debug_message in class lr_parser
See Also:
debug_message
 o debug_message
 public void debug_message(int level,
                           String message)
Write a debugging message to the error stream. A message is written only if the error stream is not null and the debug level of the message is greater than or equal to the debugging level of the parser.

Parameters:
level - the level of the message
message - the debug message to send to the error stream, if the stream non-null.
See Also:
getDebugLevel
 o debug_parse
 public Symbol debug_parse(int debug) throws Exception
Invokes the parser in debug mode. The lowering the debug level reduces the amount of debugging output. A level of 0 inhibits all debugging messages, generally a level of 10 will let all messages get through.

Parameters:
debug - the debug level to use for filtering debug messages based on priority.
Throws: Exception
if parse() does
 o getGraph
 public Graph getGraph()
Get the graph resulting from the parsing operations.

Returns:
the graph generated from the input.

All Packages  Class Hierarchy  This Package  Previous  Next  Index