|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava_cup.runtime.lr_parser
att.grappa.Parser
public class 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:
Field Summary | |
---|---|
protected static short[][] |
_action_table
Parse-action table. |
protected static short[][] |
_production_table
Production table. |
protected static short[][] |
_reduce_table
reduce_goto table. |
protected CUP$Parser$actions |
action_obj
Instance of action encapsulation class. |
private int |
debugLevel
|
private java.io.PrintWriter |
errWriter
|
private Lexer |
lexer
|
private Graph |
theGraph
|
Fields inherited from class java_cup.runtime.lr_parser |
---|
_done_parsing, _error_sync_size, action_tab, cur_token, lookahead, lookahead_pos, production_tab, reduce_tab, stack, tos |
Constructor Summary | |
---|---|
Parser()
Default constructor. |
|
Parser(java.io.InputStream inputStream)
A convenience constructor equivalent to Parser(inputStream,null,null) . |
|
Parser(java.io.InputStream inputStream,
java.io.OutputStream errorStream)
A convenience constructor equivalent to Parser(inputStream,errorStream,null) . |
|
Parser(java.io.InputStream inputStream,
java.io.OutputStream errorStream,
Graph graph)
Create an instance of Parser with input, error output and
a supplied Graph object. |
|
Parser(java.io.Reader inputReader)
A convenience constructor equivalent to Parser(inputReader,null,null) . |
|
Parser(java.io.Reader inputReader,
java.io.PrintWriter errorWriter)
A convenience constructor equivalent to Parser(inputReader,errorWriter,null) . |
|
Parser(java.io.Reader inputReader,
java.io.PrintWriter errorWriter,
Graph graph)
Create an instance of Parser with input, error output and
a supplied Graph object. |
|
Parser(Scanner s)
Constructor which sets the default scanner. |
Method Summary | |
---|---|
short[][] |
action_table()
Access to parse-action table. |
void |
debug_message(int level,
java.lang.String message)
Write a debugging message to the error stream. |
void |
debug_message(java.lang.String message)
Write a debugging message to the error stream. |
Symbol |
debug_parse(int debug)
Invokes the parser in debug mode. |
Symbol |
do_action(int act_num,
lr_parser parser,
java.util.Stack stack,
int top)
Invoke a user supplied parse action. |
int |
EOF_sym()
EOF Symbol index. |
int |
error_sym()
error Symbol index. |
(package private) CUP$Parser$actions |
getActionObject()
|
int |
getDebugLevel()
Get the debug level for this parser. |
java.io.PrintWriter |
getErrorWriter()
Get the error writer, if any, for this parser. |
Graph |
getGraph()
Get the graph resulting from the parsing operations. |
Lexer |
getLexer()
Get the Lexer object associated with this parser. |
protected void |
init_actions()
Action encapsulation object initializer. |
short[][] |
production_table()
Access to production table. |
short[][] |
reduce_table()
Access to reduce_goto table. |
void |
report_error(java.lang.String message,
java.lang.Object info)
Report a fatal error. |
void |
report_warning(java.lang.String message,
java.lang.Object info)
Report a non-fatal error. |
Symbol |
scan()
Scan to get the next Symbol. |
int |
start_production()
Indicates start production. |
int |
start_state()
Indicates start state. |
void |
user_init()
User initialization code. |
Methods inherited from class java_cup.runtime.lr_parser |
---|
advance_lookahead, cur_err_token, debug_parse, debug_reduce, debug_shift, debug_stack, done_parsing, dump_stack, error_recovery, error_sync_size, find_recovery_config, get_action, get_reduce, getScanner, parse_lookahead, parse, read_lookahead, report_fatal_error, restart_lookahead, setScanner, shift_under_error, syntax_error, try_parse_ahead, unpackFromStrings, unrecovered_syntax_error |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final short[][] _production_table
protected static final short[][] _action_table
protected static final short[][] _reduce_table
reduce_goto
table.
protected CUP$Parser$actions action_obj
private Graph theGraph
private java.io.PrintWriter errWriter
private Lexer lexer
private int debugLevel
Constructor Detail |
---|
public Parser()
public Parser(Scanner s)
public Parser(java.io.Reader inputReader, java.io.PrintWriter errorWriter, Graph graph)
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.
inputReader
- input Reader
objecterrorWriter
- 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)public Parser(java.io.Reader inputReader, java.io.PrintWriter errorWriter)
Parser(inputReader,errorWriter,null)
.
inputReader
- input Reader
objecterrorWriter
- error output Writer
object (or null to suppress error output)public Parser(java.io.Reader inputReader)
Parser(inputReader,null,null)
.
inputReader
- input Reader
objectpublic Parser(java.io.InputStream inputStream, java.io.OutputStream errorStream, Graph graph)
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
.
inputStream
- input InputStream
objecterrorStream
- 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)public Parser(java.io.InputStream inputStream, java.io.OutputStream errorStream)
Parser(inputStream,errorStream,null)
.
inputStream
- input InputStream
objecterrorStream
- error output OutputStream
objectpublic Parser(java.io.InputStream inputStream)
Parser(inputStream,null,null)
.
inputStream
- input InputStream
objectMethod Detail |
---|
public short[][] production_table()
production_table
in class lr_parser
public short[][] action_table()
action_table
in class lr_parser
lr_parser.get_action(int, int)
public short[][] reduce_table()
reduce_goto
table.
reduce_table
in class lr_parser
lr_parser.get_reduce(int, int)
protected void init_actions()
init_actions
in class lr_parser
public Symbol do_action(int act_num, lr_parser parser, java.util.Stack stack, int top) throws java.lang.Exception
do_action
in class lr_parser
act_num
- the internal index of the action to be performed.parser
- the parser object we are acting for.stack
- the parse stack of that object.top
- the index of the top element of the parse stack.
java.lang.Exception
public int start_state()
start_state
in class lr_parser
public int start_production()
start_production
in class lr_parser
public int EOF_sym()
EOF
Symbol index.
EOF_sym
in class lr_parser
public int error_sym()
error
Symbol index.
error_sym
in class lr_parser
public void user_init() throws java.lang.Exception
user_init
in class lr_parser
java.lang.Exception
public Symbol scan() throws java.lang.Exception
scan
in class lr_parser
java.lang.Exception
public Lexer getLexer()
Lexer
object associated with this parser.
public java.io.PrintWriter getErrorWriter()
public int getDebugLevel()
debug_parse
.
debug_parse(int)
public void report_error(java.lang.String message, java.lang.Object info) throws GraphParserException
GraphParserException
.
report_error
in class lr_parser
message
- the error message to send to the error stream and include in the thrown exceptioninfo
- not used
GraphParserException
- whenver this method is calledpublic void report_warning(java.lang.String message, java.lang.Object info)
message
- the warning message to send to the error stream, if the stream non-null.info
- not usedpublic void debug_message(java.lang.String message)
debug_message
in class lr_parser
message
- the debug message to send to the error stream, if the stream non-null.debug_message(int,String)
public void debug_message(int level, java.lang.String message)
level
- the level of the messagemessage
- the debug message to send to the error stream, if the stream non-null.getDebugLevel()
public Symbol debug_parse(int debug) throws java.lang.Exception
debug
- the debug level to use for filtering debug messages based on priority.
java.lang.Exception
- if parse()
doesCUP$Parser$actions getActionObject()
public Graph getGraph()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |