//----------------------------------------------------
// The following code was generated by CUP v0.10k
// Wed May 03 15:15:49 NZST 2006
//----------------------------------------------------
package grammar;
import node.*;
import node.stmtNode.*;
import node.exprNode.*;
import node.exprNode.prefixNode.*;
import node.exprNode.postfixNode.*;
import node.exprNode.binaryNode.*;
import java.io.*;
import java.util.*;
import java_cup.runtime.*;
/** CUP v0.10k generated parser.
* @version Wed May 03 15:15:49 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\002\000\002\003" +
"\004\000\002\004\004\000\002\004\004\000\002\004\003" +
"\000\002\005\005\000\002\005\005\000\002\005\005\000" +
"\002\005\005\000\002\005\005\000\002\005\004\000\002" +
"\005\004\000\002\005\004\000\002\005\004\000\002\005" +
"\004\000\002\005\004\000\002\005\004\000\002\005\006" +
"\000\002\005\005\000\002\005\003\000\002\005\003\000" +
"\002\006\002\000\002\006\003\000\002\007\003\000\002" +
"\007\005\000\002\010\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\054\000\030\002\000\003\000\004\000\006\000\010" +
"\000\011\000\014\000\015\000\016\000\021\000\022\000" +
"\001\002\000\030\002\016\003\020\004\010\006\021\010" +
"\006\011\015\014\005\015\014\016\022\021\013\022\007" +
"\001\002\000\022\004\010\010\006\011\015\014\005\015" +
"\014\016\022\021\013\022\007\001\002\000\022\004\010" +
"\010\006\011\015\014\005\015\014\016\022\021\013\022" +
"\007\001\002\000\030\004\uffe7\005\uffe7\006\uffe7\007\uffe7" +
"\010\uffe7\011\uffe7\012\uffe7\013\uffe7\014\uffe7\015\uffe7\017" +
"\uffe7\001\002\000\022\004\010\010\006\011\015\014\005" +
"\015\014\016\022\021\013\022\007\001\002\000\022\006" +
"\052\007\026\010\030\011\025\012\031\013\032\014\027" +
"\015\024\001\002\000\030\004\043\005\uffec\006\uffec\007" +
"\uffec\010\uffec\011\uffec\012\uffec\013\uffec\014\uffec\015\uffec" +
"\017\uffec\001\002\000\026\005\uffed\006\uffed\007\uffed\010" +
"\uffed\011\uffed\012\uffed\013\uffed\014\uffed\015\uffed\017\uffed" +
"\001\002\000\022\004\010\010\006\011\015\014\005\015" +
"\014\016\022\021\013\022\007\001\002\000\022\004\010" +
"\010\006\011\015\014\005\015\014\016\022\021\013\022" +
"\007\001\002\000\004\002\001\001\002\000\030\002\uffff" +
"\003\uffff\004\uffff\006\uffff\010\uffff\011\uffff\014\uffff\015" +
"\uffff\016\uffff\021\uffff\022\uffff\001\002\000\004\006\040" +
"\001\002\000\030\002\ufffc\003\ufffc\004\ufffc\006\ufffc\010" +
"\ufffc\011\ufffc\014\ufffc\015\ufffc\016\ufffc\021\ufffc\022\ufffc" +
"\001\002\000\022\004\010\010\006\011\015\014\005\015" +
"\014\016\022\021\013\022\007\001\002\000\026\005\ufff2" +
"\006\ufff2\007\ufff2\010\ufff2\011\ufff2\012\ufff2\013\ufff2\014" +
"\027\015\024\017\ufff2\001\002\000\026\005\ufff0\006\ufff0" +
"\007\ufff0\010\ufff0\011\ufff0\012\ufff0\013\ufff0\014\ufff0\015" +
"\ufff0\017\ufff0\001\002\000\022\004\010\010\006\011\015" +
"\014\005\015\014\016\022\021\013\022\007\001\002\000" +
"\022\004\010\010\006\011\015\014\005\015\014\016\022" +
"\021\013\022\007\001\002\000\026\005\ufff1\006\ufff1\007" +
"\ufff1\010\ufff1\011\ufff1\012\ufff1\013\ufff1\014\ufff1\015\ufff1" +
"\017\ufff1\001\002\000\022\004\010\010\006\011\015\014" +
"\005\015\014\016\022\021\013\022\007\001\002\000\022" +
"\004\010\010\006\011\015\014\005\015\014\016\022\021" +
"\013\022\007\001\002\000\022\004\010\010\006\011\015" +
"\014\005\015\014\016\022\021\013\022\007\001\002\000" +
"\026\005\ufffb\006\ufffb\007\026\010\030\011\025\012\031" +
"\013\032\014\027\015\024\017\ufffb\001\002\000\026\005" +
"\ufff7\006\ufff7\007\ufff7\010\ufff7\011\ufff7\012\ufff7\013\ufff7" +
"\014\027\015\024\017\ufff7\001\002\000\026\005\ufff9\006" +
"\ufff9\007\ufff9\010\ufff9\011\025\012\031\013\ufff9\014\027" +
"\015\024\017\ufff9\001\002\000\026\005\ufffa\006\ufffa\007" +
"\ufffa\010\ufffa\011\025\012\031\013\ufffa\014\027\015\024" +
"\017\ufffa\001\002\000\026\005\ufff8\006\ufff8\007\ufff8\010" +
"\ufff8\011\ufff8\012\ufff8\013\ufff8\014\027\015\024\017\ufff8" +
"\001\002\000\030\002\ufffd\003\ufffd\004\ufffd\006\ufffd\010" +
"\ufffd\011\ufffd\014\ufffd\015\ufffd\016\ufffd\021\ufffd\022\ufffd" +
"\001\002\000\026\005\ufff3\006\ufff3\007\ufff3\010\ufff3\011" +
"\ufff3\012\ufff3\013\ufff3\014\027\015\024\017\ufff3\001\002" +
"\000\026\005\ufff4\006\ufff4\007\ufff4\010\ufff4\011\ufff4\012" +
"\ufff4\013\ufff4\014\027\015\024\017\ufff4\001\002\000\024" +
"\004\010\005\uffeb\010\006\011\015\014\005\015\014\016" +
"\022\021\013\022\007\001\002\000\024\005\uffe9\007\026" +
"\010\030\011\025\012\031\013\032\014\027\015\024\017" +
"\uffe9\001\002\000\006\005\uffea\017\050\001\002\000\004" +
"\005\047\001\002\000\026\005\uffef\006\uffef\007\uffef\010" +
"\uffef\011\uffef\012\uffef\013\uffef\014\uffef\015\uffef\017\uffef" +
"\001\002\000\022\004\010\010\006\011\015\014\005\015" +
"\014\016\022\021\013\022\007\001\002\000\024\005\uffe8" +
"\007\026\010\030\011\025\012\031\013\032\014\027\015" +
"\024\017\uffe8\001\002\000\030\002\ufffe\003\ufffe\004\ufffe" +
"\006\ufffe\010\ufffe\011\ufffe\014\ufffe\015\ufffe\016\ufffe\021" +
"\ufffe\022\ufffe\001\002\000\022\005\054\007\026\010\030" +
"\011\025\012\031\013\032\014\027\015\024\001\002\000" +
"\026\005\uffee\006\uffee\007\uffee\010\uffee\011\uffee\012\uffee" +
"\013\uffee\014\uffee\015\uffee\017\uffee\001\002\000\026\005" +
"\ufff6\006\ufff6\007\ufff6\010\ufff6\011\ufff6\012\ufff6\013\ufff6" +
"\014\027\015\024\017\ufff6\001\002\000\026\005\ufff5\006" +
"\ufff5\007\ufff5\010\ufff5\011\ufff5\012\ufff5\013\ufff5\014\027" +
"\015\024\017\ufff5\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\054\000\004\003\003\001\001\000\010\004\016\005" +
"\010\010\011\001\001\000\006\005\055\010\011\001\001" +
"\000\006\005\054\010\011\001\001\000\002\001\001\000" +
"\006\005\052\010\011\001\001\000\002\001\001\000\002" +
"\001\001\000\002\001\001\000\006\005\041\010\011\001" +
"\001\000\006\005\040\010\011\001\001\000\002\001\001" +
"\000\002\001\001\000\002\001\001\000\002\001\001\000" +
"\006\005\022\010\011\001\001\000\002\001\001\000\002" +
"\001\001\000\006\005\036\010\011\001\001\000\006\005" +
"\035\010\011\001\001\000\002\001\001\000\006\005\034" +
"\010\011\001\001\000\006\005\033\010\011\001\001\000" +
"\006\005\032\010\011\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\012\005\043\006\045\007\044\010\011\001\001\000" +
"\002\001\001\000\002\001\001\000\002\001\001\000\002" +
"\001\001\000\006\005\050\010\011\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" });
/** 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 ) {
System.err.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++ )
System.err.print( text[ i ] );
System.err.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: // Ident ::= IDENT
{
IdentNode 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(6/*Ident*/, ((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: // ExprList ::= ExprList COMMA Expr
{
ExprListNode RESULT = null;
int exprListleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int exprListright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ExprListNode exprList = (ExprListNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
exprList.addElement( expr );
RESULT = exprList;
CUP$parser$result = new java_cup.runtime.Symbol(5/*ExprList*/, ((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 24: // ExprList ::= Expr
{
ExprListNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
ExprListNode exprList = new ExprListNode();
exprList.addElement( expr );
RESULT = exprList;
CUP$parser$result = new java_cup.runtime.Symbol(5/*ExprList*/, ((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 23: // ExprListOpt ::= ExprList
{
ExprListNode RESULT = null;
int exprListleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprListright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprListNode exprList = (ExprListNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = exprList;
CUP$parser$result = new java_cup.runtime.Symbol(4/*ExprListOpt*/, ((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: // ExprListOpt ::=
{
ExprListNode RESULT = null;
RESULT = new ExprListNode();
CUP$parser$result = new java_cup.runtime.Symbol(4/*ExprListOpt*/, ((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 21: // Expr ::= Ident
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
IdentNode expr = (IdentNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = expr;
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 20: // Expr ::= 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(3/*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 ::= 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(3/*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 18: // Expr ::= Ident LEFT ExprListOpt RIGHT
{
ExprNode RESULT = null;
int procleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
int procright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
IdentNode proc = (IdentNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;
int exprListOptleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
int exprListOptright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
ExprListNode exprListOpt = (ExprListNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = new ProcInvocNode( proc, exprListOpt );
CUP$parser$result = new java_cup.runtime.Symbol(3/*Expr*/, ((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 17: // Expr ::= Expr DECR
{
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 = new PostDecrNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 16: // Expr ::= Expr INCR
{
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 = new PostIncrNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 15: // Expr ::= AMPERSAND Expr
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new AddressNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 14: // Expr ::= STAR Expr
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new ContentsNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 13: // Expr ::= DECR Expr
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new PreDecrNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 12: // Expr ::= INCR Expr
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new PreIncrNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 11: // Expr ::= MINUS Expr
{
ExprNode RESULT = null;
int exprleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int exprright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
ExprNode expr = (ExprNode)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new NegateNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 10: // Expr ::= Expr DIVIDE 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 DivideNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 9: // Expr ::= Expr STAR 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 TimesNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 8: // Expr ::= Expr MINUS 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 MinusNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 7: // Expr ::= Expr PLUS 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 PlusNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 6: // Expr ::= Expr ASSIGN 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 AssignNode( expr1, expr2 );
CUP$parser$result = new java_cup.runtime.Symbol(3/*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 5: // Stmt ::= NEWLINE
{
StmtNode RESULT = null;
RESULT = new NullStmtNode();
CUP$parser$result = new java_cup.runtime.Symbol(2/*Stmt*/, ((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 4: // Stmt ::= error NEWLINE
{
StmtNode RESULT = null;
RESULT = new ErrorStmtNode();
CUP$parser$result = new java_cup.runtime.Symbol(2/*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 3: // Stmt ::= Expr NEWLINE
{
StmtNode 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 = new PrintStmtNode( expr );
CUP$parser$result = new java_cup.runtime.Symbol(2/*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 2: // 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(1/*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 1: // StmtList ::=
{
StmtListNode RESULT = null;
RESULT = new StmtListNode();
CUP$parser$result = new java_cup.runtime.Symbol(1/*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 0: // $START ::= StmtList 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;
StmtListNode start_val = (StmtListNode)((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");
}
}
}