//----------------------------------------------------
// The following code was generated by CUP v0.10k
// Wed May 03 15:15:01 NZST 2006
//----------------------------------------------------
package grammar;
import node.*;
import node.stmtNode.*;
import node.exprNode.*;
import node.exprNode.prefixNode.*;
import node.exprNode.valueNode.*;
import node.exprNode.binaryNode.*;
import node.exprNode.binaryNode.arithNode.*;
import node.exprNode.binaryNode.relationNode.*;
import text.*;
import java.io.*;
import java_cup.runtime.*;
/** CUP v0.10k generated parser.
* @version Wed May 03 15:15:01 NZST 2006
*/
public class parser extends java_cup.runtime.lr_parser {
/** Default constructor. */
public parser() {super();}
/** Constructor which sets the default scanner. */
public parser(java_cup.runtime.Scanner s) {super(s);}
/** Production table. */
protected static final short _production_table[][] =
unpackFromStrings(new String[] {
"\000\033\000\002\002\004\000\002\003\003\000\002\004" +
"\002\000\002\004\004\000\002\005\006\000\002\005\010" +
"\000\002\005\006\000\002\005\006\000\002\005\005\000" +
"\002\005\004\000\002\005\004\000\002\006\005\000\002" +
"\006\005\000\002\006\005\000\002\006\005\000\002\006" +
"\005\000\002\006\005\000\002\007\005\000\002\007\005" +
"\000\002\007\004\000\002\007\003\000\002\010\005\000" +
"\002\010\005\000\002\010\003\000\002\011\005\000\002" +
"\011\003\000\002\011\003" });
/** Access to production table. */
public short[][] production_table() {return _production_table;}
/** Parse-action table. */
protected static final short[][] _action_table =
unpackFromStrings(new String[] {
"\000\067\000\016\002\uffff\003\uffff\022\uffff\025\uffff\027" +
"\uffff\032\uffff\001\002\000\004\002\071\001\002\000\016" +
"\002\000\003\006\022\013\025\012\027\011\032\010\001" +
"\002\000\006\013\067\030\070\001\002\000\020\002\ufffe" +
"\003\ufffe\022\ufffe\025\ufffe\027\ufffe\030\ufffe\032\ufffe\001" +
"\002\000\004\012\064\001\002\000\016\003\uffff\022\uffff" +
"\025\uffff\027\uffff\030\uffff\032\uffff\001\002\000\012\004" +
"\016\007\021\031\017\032\022\001\002\000\012\004\016" +
"\007\021\031\017\032\022\001\002\000\036\005\uffea\006" +
"\uffea\007\uffea\010\uffea\011\uffea\013\uffea\014\uffea\015\uffea" +
"\016\uffea\017\uffea\020\uffea\021\uffea\023\uffea\026\uffea\001" +
"\002\000\036\005\uffed\006\uffed\007\uffed\010\032\011\031" +
"\013\uffed\014\uffed\015\uffed\016\uffed\017\uffed\020\uffed\021" +
"\uffed\023\uffed\026\uffed\001\002\000\012\004\016\007\021" +
"\031\017\032\022\001\002\000\036\005\uffe8\006\uffe8\007" +
"\uffe8\010\uffe8\011\uffe8\013\uffe8\014\uffe8\015\uffe8\016\uffe8" +
"\017\uffe8\020\uffe8\021\uffe8\023\uffe8\026\uffe8\001\002\000" +
"\022\006\040\007\043\014\035\015\041\016\037\017\042" +
"\020\036\021\044\001\002\000\010\004\016\031\017\032" +
"\022\001\002\000\036\005\uffe7\006\uffe7\007\uffe7\010\uffe7" +
"\011\uffe7\013\uffe7\014\uffe7\015\uffe7\016\uffe7\017\uffe7\020" +
"\uffe7\021\uffe7\023\uffe7\026\uffe7\001\002\000\004\023\024" +
"\001\002\000\014\003\006\022\013\025\012\027\011\032" +
"\010\001\002\000\022\002\ufffb\003\ufffb\022\ufffb\024\026" +
"\025\ufffb\027\ufffb\030\ufffb\032\ufffb\001\002\000\014\003" +
"\006\022\013\025\012\027\011\032\010\001\002\000\022" +
"\002\ufffc\003\ufffc\022\ufffc\024\ufffc\025\ufffc\027\ufffc\030" +
"\ufffc\032\ufffc\001\002\000\036\005\uffee\006\uffee\007\uffee" +
"\010\032\011\031\013\uffee\014\uffee\015\uffee\016\uffee\017" +
"\uffee\020\uffee\021\uffee\023\uffee\026\uffee\001\002\000\010" +
"\004\016\031\017\032\022\001\002\000\010\004\016\031" +
"\017\032\022\001\002\000\036\005\uffec\006\uffec\007\uffec" +
"\010\uffec\011\uffec\013\uffec\014\uffec\015\uffec\016\uffec\017" +
"\uffec\020\uffec\021\uffec\023\uffec\026\uffec\001\002\000\036" +
"\005\uffeb\006\uffeb\007\uffeb\010\uffeb\011\uffeb\013\uffeb\014" +
"\uffeb\015\uffeb\016\uffeb\017\uffeb\020\uffeb\021\uffeb\023\uffeb" +
"\026\uffeb\001\002\000\012\004\016\007\021\031\017\032" +
"\022\001\002\000\012\004\016\007\021\031\017\032\022" +
"\001\002\000\012\004\016\007\021\031\017\032\022\001" +
"\002\000\010\004\016\031\017\032\022\001\002\000\012" +
"\004\016\007\021\031\017\032\022\001\002\000\012\004" +
"\016\007\021\031\017\032\022\001\002\000\010\004\016" +
"\031\017\032\022\001\002\000\012\004\016\007\021\031" +
"\017\032\022\001\002\000\012\006\040\007\043\023\ufff1" +
"\026\ufff1\001\002\000\036\005\uffef\006\uffef\007\uffef\010" +
"\032\011\031\013\uffef\014\uffef\015\uffef\016\uffef\017\uffef" +
"\020\uffef\021\uffef\023\uffef\026\uffef\001\002\000\012\006" +
"\040\007\043\023\ufff3\026\ufff3\001\002\000\012\006\040" +
"\007\043\023\ufff5\026\ufff5\001\002\000\036\005\ufff0\006" +
"\ufff0\007\ufff0\010\032\011\031\013\ufff0\014\ufff0\015\ufff0" +
"\016\ufff0\017\ufff0\020\ufff0\021\ufff0\023\ufff0\026\ufff0\001" +
"\002\000\012\006\040\007\043\023\ufff4\026\ufff4\001\002" +
"\000\012\006\040\007\043\023\ufff2\026\ufff2\001\002\000" +
"\012\006\040\007\043\023\ufff6\026\ufff6\001\002\000\010" +
"\005\056\006\040\007\043\001\002\000\036\005\uffe9\006" +
"\uffe9\007\uffe9\010\uffe9\011\uffe9\013\uffe9\014\uffe9\015\uffe9" +
"\016\uffe9\017\uffe9\020\uffe9\021\uffe9\023\uffe9\026\uffe9\001" +
"\002\000\004\026\060\001\002\000\014\003\006\022\013" +
"\025\012\027\011\032\010\001\002\000\022\002\ufffa\003" +
"\ufffa\022\ufffa\024\ufffa\025\ufffa\027\ufffa\030\ufffa\032\ufffa" +
"\001\002\000\016\003\006\022\013\025\012\027\011\030" +
"\063\032\010\001\002\000\022\002\ufff9\003\ufff9\022\ufff9" +
"\024\ufff9\025\ufff9\027\ufff9\030\ufff9\032\ufff9\001\002\000" +
"\012\004\016\007\021\031\017\032\022\001\002\000\010" +
"\006\040\007\043\013\066\001\002\000\022\002\ufffd\003" +
"\ufffd\022\ufffd\024\ufffd\025\ufffd\027\ufffd\030\ufffd\032\ufffd" +
"\001\002\000\022\002\ufff8\003\ufff8\022\ufff8\024\ufff8\025" +
"\ufff8\027\ufff8\030\ufff8\032\ufff8\001\002\000\022\002\ufff7" +
"\003\ufff7\022\ufff7\024\ufff7\025\ufff7\027\ufff7\030\ufff7\032" +
"\ufff7\001\002\000\004\002\001\001\002" });
/** Access to parse-action table. */
public short[][] action_table() {return _action_table;}
/** reduce_goto
table. */
protected static final short[][] _reduce_table =
unpackFromStrings(new String[] {
"\000\067\000\006\003\003\004\004\001\001\000\002\001" +
"\001\000\004\005\006\001\001\000\002\001\001\000\002" +
"\001\001\000\002\001\001\000\004\004\061\001\001\000" +
"\012\006\056\007\017\010\014\011\013\001\001\000\012" +
"\006\022\007\017\010\014\011\013\001\001\000\002\001" +
"\001\000\002\001\001\000\010\007\054\010\014\011\013" +
"\001\001\000\002\001\001\000\002\001\001\000\006\010" +
"\027\011\013\001\001\000\002\001\001\000\002\001\001" +
"\000\004\005\024\001\001\000\002\001\001\000\004\005" +
"\026\001\001\000\002\001\001\000\002\001\001\000\004" +
"\011\033\001\001\000\004\011\032\001\001\000\002\001" +
"\001\000\002\001\001\000\010\007\053\010\014\011\013" +
"\001\001\000\010\007\052\010\014\011\013\001\001\000" +
"\010\007\051\010\014\011\013\001\001\000\006\010\050" +
"\011\013\001\001\000\010\007\047\010\014\011\013\001" +
"\001\000\010\007\046\010\014\011\013\001\001\000\006" +
"\010\045\011\013\001\001\000\010\007\044\010\014\011" +
"\013\001\001\000\002\001\001\000\002\001\001\000\002" +
"\001\001\000\002\001\001\000\002\001\001\000\002\001" +
"\001\000\002\001\001\000\002\001\001\000\002\001\001" +
"\000\002\001\001\000\002\001\001\000\004\005\060\001" +
"\001\000\002\001\001\000\004\005\006\001\001\000\002" +
"\001\001\000\010\007\064\010\014\011\013\001\001\000" +
"\002\001\001\000\002\001\001\000\002\001\001\000\002" +
"\001\001\000\002\001\001" });
/** Access to reduce_goto
table. */
public short[][] reduce_table() {return _reduce_table;}
/** Instance of action encapsulation class. */
protected CUP$parser$actions action_obj;
/** Action encapsulation object initializer. */
protected void init_actions()
{
action_obj = new CUP$parser$actions(this);
}
/** Invoke a user supplied parse action. */
public java_cup.runtime.Symbol do_action(
int act_num,
java_cup.runtime.lr_parser parser,
java.util.Stack stack,
int top)
throws java.lang.Exception
{
/* call code in generated class */
return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
}
/** Indicates start state. */
public int start_state() {return 0;}
/** Indicates start production. */
public int start_production() {return 0;}
/** EOF
Symbol index. */
public int EOF_sym() {return 0;}
/** error
Symbol index. */
public int error_sym() {return 1;}
/** Scan to get the next Symbol. */
public java_cup.runtime.Symbol scan()
throws java.lang.Exception
{
return lexer.yylex();
}
private Yylex lexer;
private File file;
public parser( File file ) {
this();
this.file = file;
try {
lexer = new Yylex( new FileReader( file ) );
}
catch ( IOException exception ) {
throw new Error( "Unable to open file \"" + file + "\"" );
}
}
public String terminal_name( int id ) {
return sym.terminal_name( id );
}
public String non_terminal_name( int id ) {
return sym.non_terminal_name( id );
}
public String rule_name( int id ) {
return sym.rule_name( id );
}
public void report_error( String message, Object info ) {
Print.error().println( file + " ( " + lexer.lineNumber() + " ): " + message );
try {
if ( info instanceof Symbol ) {
Symbol symbol = ( Symbol ) info;
printText( symbol.left, symbol.right );
}
}
catch ( IOException e ) {
}
}
private void printText( int left, int right ) throws IOException {
Reader sourceReader = new FileReader( file );
int veryLeft = Math.max( left - 50, 0 ),
veryRight = Math.min( right + 20,
( int ) file.length() );
char[] text = new char[ veryRight - veryLeft ];
char[] underline = new char[ veryRight - veryLeft ];
sourceReader.skip( veryLeft );
sourceReader.read( text );
for ( int i = 0; i < text.length; i++ ) {
if ( text[ i ] < ' ' ) {
text[ i ] = '|';
underline[ i ] = '|';
}
else
underline[ i ] = ' ';
if ( left <= veryLeft + i && veryLeft + i < right )
underline[ i ] = '^';
}
printLine( text );
printLine( underline );
}
private static void printLine( char[] text ) {
for ( int i = 0; i < text.length; i++ )
Print.error().print( text[ i ] );
Print.error().println();
}
public void syntax_error( Symbol currToken ) {
report_error( "Syntax Error", currToken );
}
}
/** Cup generated class to encapsulate user supplied action code.*/
class CUP$parser$actions {
private final parser parser;
/** Constructor */
CUP$parser$actions(parser parser) {
this.parser = parser;
}
/** Method with the actual generated action code. */
public final java_cup.runtime.Symbol CUP$parser$do_action(
int CUP$parser$act_num,
java_cup.runtime.lr_parser CUP$parser$parser,
java.util.Stack CUP$parser$stack,
int CUP$parser$top)
throws java.lang.Exception
{
/* Symbol object for return from actions */
java_cup.runtime.Symbol CUP$parser$result;
/* select the action based on the action number */
switch (CUP$parser$act_num)
{
/*. . . . . . . . . . . . . . . . . . . .*/
case 26: // Factor ::= IDENT
{
ExprNode RESULT = null;
int identleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int identright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
String ident = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new IdentNode( ident );
CUP$parser$result = new java_cup.runtime.Symbol(7/*Factor*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 25: // Factor ::= NUMBER
{
ExprNode RESULT = null;
int valueleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int valueright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
String value = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new NumberNode( new Integer( value ) );
CUP$parser$result = new java_cup.runtime.Symbol(7/*Factor*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 24: // Factor ::= LEFT Expr RIGHT
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = expr;
CUP$parser$result = new java_cup.runtime.Symbol(7/*Factor*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 23: // Term ::= Factor
{
ExprNode RESULT = null;
int factorleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int factorright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode factor = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = factor;
CUP$parser$result = new java_cup.runtime.Symbol(6/*Term*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 22: // Term ::= Term DIVIDE Factor
{
ExprNode RESULT = null;
int termleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int termright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode term = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int factorleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int factorright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode factor = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new DivideNode( term, factor );
CUP$parser$result = new java_cup.runtime.Symbol(6/*Term*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 21: // Term ::= Term TIMES Factor
{
ExprNode RESULT = null;
int termleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int termright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode term = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int factorleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int factorright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode factor = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new TimesNode( term, factor );
CUP$parser$result = new java_cup.runtime.Symbol(6/*Term*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 20: // Expr ::= Term
{
ExprNode RESULT = null;
int termleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int termright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode term = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = term;
CUP$parser$result = new java_cup.runtime.Symbol(5/*Expr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 19: // Expr ::= MINUS Term
{
ExprNode RESULT = null;
int termleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int termright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode term = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new NegateNode( term );
CUP$parser$result = new java_cup.runtime.Symbol(5/*Expr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 18: // Expr ::= Expr MINUS Term
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int termleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int termright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode term = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new MinusNode( expr, term );
CUP$parser$result = new java_cup.runtime.Symbol(5/*Expr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 17: // Expr ::= Expr PLUS Term
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int termleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int termright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode term = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new PlusNode( expr, term );
CUP$parser$result = new java_cup.runtime.Symbol(5/*Expr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 16: // BoolExpr ::= Expr NE Expr
{
ExprNode RESULT = null;
int expr1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int expr1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr1 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int expr2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int expr2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr2 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new NotEqualNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(4/*BoolExpr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 15: // BoolExpr ::= Expr EQ Expr
{
ExprNode RESULT = null;
int expr1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int expr1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr1 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int expr2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int expr2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr2 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new EqualNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(4/*BoolExpr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 14: // BoolExpr ::= Expr GE Expr
{
ExprNode RESULT = null;
int expr1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int expr1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr1 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int expr2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int expr2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr2 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new GreaterEqualNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(4/*BoolExpr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 13: // BoolExpr ::= Expr GT Expr
{
ExprNode RESULT = null;
int expr1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int expr1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr1 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int expr2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int expr2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr2 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new GreaterThanNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(4/*BoolExpr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 12: // BoolExpr ::= Expr LE Expr
{
ExprNode RESULT = null;
int expr1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int expr1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr1 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int expr2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int expr2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr2 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new LessEqualNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(4/*BoolExpr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 11: // BoolExpr ::= Expr LT Expr
{
ExprNode RESULT = null;
int expr1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int expr1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr1 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int expr2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int expr2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr2 = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new LessThanNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(4/*BoolExpr*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 10: // Stmt ::= error RIGHTCURLY
{
StmtNode RESULT = null;
RESULT = new ErrorStmtNode();
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 9: // Stmt ::= error SEMICOLON
{
StmtNode RESULT = null;
RESULT = new ErrorStmtNode();
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 8: // Stmt ::= LEFTCURLY StmtList RIGHTCURLY
{
StmtNode RESULT = null;
int stmtListleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
int stmtListright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
StmtListNode stmtList = (StmtListNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = new CompoundStmtNode( stmtList );
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 7: // Stmt ::= WHILE BoolExpr DO Stmt
{
StmtNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int stmt1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int stmt1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
StmtNode stmt1 = (StmtNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new WhileStmtNode( expr, stmt1 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 6: // Stmt ::= IF BoolExpr THEN Stmt
{
StmtNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int stmt1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int stmt1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
StmtNode stmt1 = (StmtNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new IfThenStmtNode( expr, stmt1 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 5: // Stmt ::= IF BoolExpr THEN Stmt ELSE Stmt
{
StmtNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value;
int stmt1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int stmt1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
StmtNode stmt1 = (StmtNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int stmt2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int stmt2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
StmtNode stmt2 = (StmtNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new IfThenElseStmtNode( expr, stmt1, stmt2 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 4: // Stmt ::= IDENT ASSIGN Expr SEMICOLON
{
StmtNode RESULT = null;
int identleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
int identright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
String ident = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = new AssignStmtNode( ident, expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*Stmt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 3: // StmtList ::= StmtList Stmt
{
StmtListNode RESULT = null;
int stmtListleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
int stmtListright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
StmtListNode stmtList = (StmtListNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
int stmtleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int stmtright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
StmtNode stmt = (StmtNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
stmtList.addElement( stmt );
RESULT = stmtList;
CUP$parser$result = new java_cup.runtime.Symbol(2/*StmtList*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 2: // StmtList ::=
{
StmtListNode RESULT = null;
RESULT = new StmtListNode();
CUP$parser$result = new java_cup.runtime.Symbol(2/*StmtList*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 1: // Program ::= StmtList
{
ProgramNode RESULT = null;
int stmtListleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int stmtListright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
StmtListNode stmtList = (StmtListNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new ProgramNode( stmtList );
CUP$parser$result = new java_cup.runtime.Symbol(1/*Program*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 0: // $START ::= Program EOF
{
Object RESULT = null;
int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
ProgramNode start_val = (ProgramNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = start_val;
CUP$parser$result = new java_cup.runtime.Symbol(0/*$START*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
}
/* ACCEPT */
CUP$parser$parser.done_parsing();
return CUP$parser$result;
/* . . . . . .*/
default:
throw new Exception(
"Invalid action number found in internal parse table");
}
}
}