geneseo.cs.miniml
Class MinimLLRParser

java.lang.Object
  |
  +--geneseo.cs.compiler.LRParser
        |
        +--geneseo.cs.miniml.MinimLLRParser
All Implemented Interfaces:
Parser

public class MinimLLRParser
extends LRParser

Represents LR parsers for MinimL.


Constructor Summary
MinimLLRParser()
          Initialize an LR parser for MinimL.
 
Method Summary
 void error(int code, TokenSeq input, java.util.Stack parseStack)
          Handle an error for a MinimL SLR parser.
protected  int leftSide(int production)
          Figures out the non-terminal on the left side of a production, given the production number.
protected  ParseNode reduce(int production)
          Reduce by a specified production during a parse.
 
Methods inherited from class geneseo.cs.compiler.LRParser
a, e, parse, popSymbol, r, s
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MinimLLRParser

public MinimLLRParser()
Initialize an LR parser for MinimL.
Method Detail

reduce

protected ParseNode reduce(int production)
                    throws CompilerException
Description copied from class: LRParser
Reduce by a specified production during a parse. The "parse" method invokes this to reduce in a language-specific manner.
Overrides:
reduce in class LRParser
Following copied from class: geneseo.cs.compiler.LRParser
Parameters:
production - The number of the production by which to reduce.
Returns:
The root of the piece of syntax tree resulting from the reduction.
Throws:
CompilerException - If the parse stack doesn't have enough items on it to complete the reduction, or if the production number is invalid.

leftSide

protected int leftSide(int production)
Description copied from class: LRParser
Figures out the non-terminal on the left side of a production, given the production number.
Overrides:
leftSide in class LRParser
Following copied from class: geneseo.cs.compiler.LRParser
Parameters:
production - The production number.
Returns:
The integer code for the left-hand side of the specified production.

error

public void error(int code,
                  TokenSeq input,
                  java.util.Stack parseStack)
           throws CompilerException
Handle an error for a MinimL SLR parser. Generally this means creating and throwing an exception that describes the error.
Overrides:
error in class LRParser
Parameters:
code - The error code from the parse table.
input - The sequence of tokens being processed when the error was detected.
parseStack - The parser's stack at the time of the error.
Throws:
CompilerException - To report the error to other parts of the compiler.