parser
Class DynamicParserFactory

java.lang.Object
  extended by parser.DynamicParserFactory
All Implemented Interfaces:
ParserFactory

public class DynamicParserFactory
extends java.lang.Object
implements ParserFactory

This class takes a filename of a JavaCup-file and creates a Parser from it


Constructor Summary
DynamicParserFactory(java.lang.String filename)
           
 
Method Summary
static void cleanup()
           
 void debug_parse()
           
 boolean errorsDuringParse()
          After parsing, the return value of this method will be valid.
 java.lang.String getDumpedAST()
          Returns the AST from the parse as dumped into a string.
 Program getResultAST()
           
 void parse()
          After setting the lexer, this parse() is the command to parse the stream coming from the lexer, debug_parse() does so in debug mode.
 void semant()
          Runs the semantic checker on the AST accessible by getResultAST().
 void setLexer(CoolTokenLexer lexer)
          This method is used to specify the input to the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicParserFactory

public DynamicParserFactory(java.lang.String filename)
                     throws java.lang.Exception
Parameters:
filename - -- JavaCup specification file
Throws:
java.lang.Exception
Method Detail

cleanup

public static void cleanup()

setLexer

public void setLexer(CoolTokenLexer lexer)
Description copied from interface: ParserFactory
This method is used to specify the input to the parser.

Specified by:
setLexer in interface ParserFactory
Parameters:
lexer - -- input to parser

parse

public void parse()
           throws java.lang.Exception
Description copied from interface: ParserFactory
After setting the lexer, this parse() is the command to parse the stream coming from the lexer, debug_parse() does so in debug mode.

Specified by:
parse in interface ParserFactory
Throws:
java.lang.Exception - -- if unrecoverable exception occured during parsing.

debug_parse

public void debug_parse()
                 throws java.lang.Exception
Specified by:
debug_parse in interface ParserFactory
Throws:
java.lang.Exception

errorsDuringParse

public boolean errorsDuringParse()
Description copied from interface: ParserFactory
After parsing, the return value of this method will be valid.

Specified by:
errorsDuringParse in interface ParserFactory

getResultAST

public Program getResultAST()
Specified by:
getResultAST in interface ParserFactory

semant

public void semant()
            throws SemanticError
Description copied from interface: ParserFactory
Runs the semantic checker on the AST accessible by getResultAST().

Specified by:
semant in interface ParserFactory
Throws:
SemanticError

getDumpedAST

public java.lang.String getDumpedAST()
Description copied from interface: ParserFactory
Returns the AST from the parse as dumped into a string.

Specified by:
getDumpedAST in interface ParserFactory