
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
// Wed Dec 02 21:58:23 CET 2009
//----------------------------------------------------

package ppdz;

import java_cup.runtime.*;
import java.io.*;

/** CUP v0.11a beta 20060608 generated parser.
  * @version Wed Dec 02 21:58:23 CET 2009
  */
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);}

  /** Constructor which sets the default scanner. */
  public parser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}

  /** Production table. */
  protected static final short _production_table[][] = 
    unpackFromStrings(new String[] {
    "\000\100\000\002\002\010\000\002\002\004\000\002\036" +
    "\003\000\002\003\004\000\002\003\002\000\002\024\003" +
    "\000\002\024\003\000\002\011\010\000\002\025\003\000" +
    "\002\006\003\000\002\006\003\000\002\040\002\000\002" +
    "\005\006\000\002\007\005\000\002\007\003\000\002\010" +
    "\003\000\002\010\005\000\002\020\004\000\002\020\002" +
    "\000\002\004\004\000\002\004\002\000\002\037\004\000" +
    "\002\037\004\000\002\041\002\000\002\012\013\000\002" +
    "\013\003\000\002\013\002\000\002\023\005\000\002\023" +
    "\003\000\002\015\004\000\002\015\006\000\002\014\004" +
    "\000\002\014\002\000\002\016\006\000\002\016\006\000" +
    "\002\016\007\000\002\016\004\000\002\016\005\000\002" +
    "\016\007\000\002\034\003\000\002\042\002\000\002\035" +
    "\007\000\002\035\003\000\002\021\003\000\002\021\003" +
    "\000\002\022\003\000\002\022\003\000\002\017\003\000" +
    "\002\027\005\000\002\027\003\000\002\026\003\000\002" +
    "\030\005\000\002\030\003\000\002\031\003\000\002\033" +
    "\005\000\002\033\003\000\002\033\004\000\002\032\006" +
    "\000\002\032\003\000\002\032\005\000\002\032\003\000" +
    "\002\032\003\000\002\032\007\000\002\032\005" });

  /** Access to production table. */
  public short[][] production_table() {return _production_table;}

  /** Parse-action table. */
  protected static final short[][] _action_table = 
    unpackFromStrings(new String[] {
    "\000\162\000\004\021\005\001\002\000\004\002\164\001" +
    "\002\000\004\031\007\001\002\000\010\017\ufffd\025\ufffd" +
    "\031\ufffd\001\002\000\010\017\uffff\025\uffff\031\uffff\001" +
    "\002\000\010\017\011\025\016\031\015\001\002\000\010" +
    "\020\uffed\024\uffed\031\uffed\001\002\000\010\017\ufffc\025" +
    "\ufffc\031\ufffc\001\002\000\010\017\ufffe\025\ufffe\031\ufffe" +
    "\001\002\000\004\031\ufff6\001\002\000\006\015\ufff9\031" +
    "\ufff9\001\002\000\004\031\015\001\002\000\010\017\ufffb" +
    "\025\ufffb\031\ufffb\001\002\000\004\031\021\001\002\000" +
    "\004\010\022\001\002\000\006\027\023\030\024\001\002" +
    "\000\004\011\ufff8\001\002\000\004\011\ufff7\001\002\000" +
    "\004\011\026\001\002\000\010\017\ufffa\025\ufffa\031\ufffa" +
    "\001\002\000\004\031\031\001\002\000\006\011\036\012" +
    "\035\001\002\000\010\011\ufff2\012\ufff2\015\033\001\002" +
    "\000\006\011\ufff3\012\ufff3\001\002\000\004\016\034\001" +
    "\002\000\006\011\ufff1\012\ufff1\001\002\000\004\031\031" +
    "\001\002\000\010\017\ufff5\025\ufff5\031\ufff5\001\002\000" +
    "\006\011\ufff4\012\ufff4\001\002\000\010\020\044\024\045" +
    "\031\015\001\002\000\010\020\uffee\024\uffee\031\uffee\001" +
    "\002\000\004\031\163\001\002\000\004\013\047\001\002" +
    "\000\004\002\001\001\002\000\004\031\046\001\002\000" +
    "\004\013\uffeb\001\002\000\006\014\uffe7\031\015\001\002" +
    "\000\004\031\160\001\002\000\004\014\056\001\002\000" +
    "\006\012\054\014\uffe8\001\002\000\006\012\uffe5\014\uffe5" +
    "\001\002\000\004\031\015\001\002\000\006\012\uffe6\014" +
    "\uffe6\001\002\000\006\017\uffef\031\uffef\001\002\000\006" +
    "\017\060\031\015\001\002\000\012\020\uffea\022\uffea\023" +
    "\uffea\031\uffea\001\002\000\006\017\ufff0\031\ufff0\001\002" +
    "\000\012\020\uffe1\022\uffe1\023\uffe1\031\uffe1\001\002\000" +
    "\012\020\070\022\065\023\067\031\072\001\002\000\006" +
    "\010\147\013\150\001\002\000\004\013\143\001\002\000" +
    "\030\004\uffda\005\uffda\006\uffda\007\uffda\010\uffda\011\uffda" +
    "\012\uffda\013\uffda\014\uffda\015\137\016\uffda\001\002\000" +
    "\020\005\073\011\100\013\106\026\074\027\075\030\101" +
    "\031\072\001\002\000\010\020\uffe9\024\uffe9\031\uffe9\001" +
    "\002\000\012\020\uffe2\022\uffe2\023\uffe2\031\uffe2\001\002" +
    "\000\030\004\uffd7\005\uffd7\006\uffd7\007\uffd7\010\uffd7\011" +
    "\uffd7\012\uffd7\013\uffd7\014\uffd7\015\uffd7\016\uffd7\001\002" +
    "\000\014\013\106\026\074\027\075\030\101\031\072\001" +
    "\002\000\004\031\015\001\002\000\022\004\uffc5\005\uffc5" +
    "\006\uffc5\007\uffc5\011\uffc5\012\uffc5\014\uffc5\016\uffc5\001" +
    "\002\000\016\004\uffcd\005\uffcd\011\uffcd\012\uffcd\014\uffcd" +
    "\016\uffcd\001\002\000\024\004\uffc7\005\uffc7\006\uffc7\007" +
    "\uffc7\011\uffc7\012\uffc7\013\122\014\uffc7\016\uffc7\001\002" +
    "\000\012\020\uffdd\022\uffdd\023\uffdd\031\uffdd\001\002\000" +
    "\022\004\uffc4\005\uffc4\006\uffc4\007\uffc4\011\uffc4\012\uffc4" +
    "\014\uffc4\016\uffc4\001\002\000\016\004\117\005\120\011" +
    "\uffcf\012\uffcf\014\uffcf\016\uffcf\001\002\000\022\004\uffca" +
    "\005\uffca\006\uffca\007\uffca\011\uffca\012\uffca\014\uffca\016" +
    "\uffca\001\002\000\004\011\115\001\002\000\022\004\uffcc" +
    "\005\uffcc\006\113\007\112\011\uffcc\012\uffcc\014\uffcc\016" +
    "\uffcc\001\002\000\016\005\073\013\106\026\074\027\075" +
    "\030\101\031\072\001\002\000\004\014\110\001\002\000" +
    "\022\004\uffc2\005\uffc2\006\uffc2\007\uffc2\011\uffc2\012\uffc2" +
    "\014\uffc2\016\uffc2\001\002\000\014\013\106\026\074\027" +
    "\075\030\101\031\072\001\002\000\014\013\uffd3\026\uffd3" +
    "\027\uffd3\030\uffd3\031\uffd3\001\002\000\014\013\uffd4\026" +
    "\uffd4\027\uffd4\030\uffd4\031\uffd4\001\002\000\022\004\uffcb" +
    "\005\uffcb\006\uffcb\007\uffcb\011\uffcb\012\uffcb\014\uffcb\016" +
    "\uffcb\001\002\000\012\020\uffdc\022\uffdc\023\uffdc\031\uffdc" +
    "\001\002\000\016\005\073\013\106\026\074\027\075\030" +
    "\101\031\072\001\002\000\016\005\uffd6\013\uffd6\026\uffd6" +
    "\027\uffd6\030\uffd6\031\uffd6\001\002\000\016\005\uffd5\013" +
    "\uffd5\026\uffd5\027\uffd5\030\uffd5\031\uffd5\001\002\000\016" +
    "\004\uffce\005\uffce\011\uffce\012\uffce\014\uffce\016\uffce\001" +
    "\002\000\020\005\073\013\106\014\124\026\074\027\075" +
    "\030\101\031\072\001\002\000\006\012\130\014\uffd2\001" +
    "\002\000\022\004\uffc6\005\uffc6\006\uffc6\007\uffc6\011\uffc6" +
    "\012\uffc6\014\uffc6\016\uffc6\001\002\000\006\012\uffd0\014" +
    "\uffd0\001\002\000\004\014\127\001\002\000\022\004\uffc8" +
    "\005\uffc8\006\uffc8\007\uffc8\011\uffc8\012\uffc8\014\uffc8\016" +
    "\uffc8\001\002\000\016\005\073\013\106\026\074\027\075" +
    "\030\101\031\072\001\002\000\006\012\uffd1\014\uffd1\001" +
    "\002\000\004\015\133\001\002\000\016\005\073\013\106" +
    "\026\074\027\075\030\101\031\072\001\002\000\004\016" +
    "\135\001\002\000\022\004\uffc3\005\uffc3\006\uffc3\007\uffc3" +
    "\011\uffc3\012\uffc3\014\uffc3\016\uffc3\001\002\000\022\004" +
    "\uffc9\005\uffc9\006\uffc9\007\uffc9\011\uffc9\012\uffc9\014\uffc9" +
    "\016\uffc9\001\002\000\016\005\uffd9\013\uffd9\026\uffd9\027" +
    "\uffd9\030\uffd9\031\uffd9\001\002\000\016\005\073\013\106" +
    "\026\074\027\075\030\101\031\072\001\002\000\004\016" +
    "\142\001\002\000\030\004\uffd8\005\uffd8\006\uffd8\007\uffd8" +
    "\010\uffd8\011\uffd8\012\uffd8\013\uffd8\014\uffd8\015\uffd8\016" +
    "\uffd8\001\002\000\016\005\073\013\106\026\074\027\075" +
    "\030\101\031\072\001\002\000\004\014\145\001\002\000" +
    "\004\011\146\001\002\000\012\020\uffdb\022\uffdb\023\uffdb" +
    "\031\uffdb\001\002\000\016\005\073\013\106\026\074\027" +
    "\075\030\101\031\072\001\002\000\020\005\073\013\106" +
    "\014\151\026\074\027\075\030\101\031\072\001\002\000" +
    "\004\011\155\001\002\000\004\014\153\001\002\000\004" +
    "\011\154\001\002\000\012\020\uffde\022\uffde\023\uffde\031" +
    "\uffde\001\002\000\012\020\uffdf\022\uffdf\023\uffdf\031\uffdf" +
    "\001\002\000\004\011\157\001\002\000\012\020\uffe0\022" +
    "\uffe0\023\uffe0\031\uffe0\001\002\000\010\012\uffe4\014\uffe4" +
    "\015\161\001\002\000\004\016\162\001\002\000\006\012" +
    "\uffe3\014\uffe3\001\002\000\004\013\uffec\001\002\000\004" +
    "\002\000\001\002" });

  /** Access to parse-action table. */
  public short[][] action_table() {return _action_table;}

  /** <code>reduce_goto</code> table. */
  protected static final short[][] _reduce_table = 
    unpackFromStrings(new String[] {
    "\000\162\000\004\002\003\001\001\000\002\001\001\000" +
    "\004\036\005\001\001\000\004\003\007\001\001\000\002" +
    "\001\001\000\012\005\016\011\011\024\012\025\013\001" +
    "\001\000\004\004\037\001\001\000\002\001\001\000\002" +
    "\001\001\000\004\040\026\001\001\000\002\001\001\000" +
    "\004\025\017\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\004\006\024\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\006\007\027\010\031\001\001\000\002\001\001\000" +
    "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
    "\001\001\000\004\010\036\001\001\000\002\001\001\000" +
    "\002\001\001\000\010\012\040\025\041\037\042\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" +
    "\013\050\015\052\023\051\025\047\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\006\015\054\025\047\001\001\000\002\001\001\000" +
    "\004\020\056\001\001\000\006\005\060\025\013\001\001" +
    "\000\004\041\061\001\001\000\002\001\001\000\004\014" +
    "\062\001\001\000\010\016\070\034\063\035\065\001\001" +
    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
    "\020\026\103\030\101\031\075\032\102\033\104\034\076" +
    "\035\065\001\001\000\002\001\001\000\002\001\001\000" +
    "\002\001\001\000\010\032\135\034\076\035\065\001\001" +
    "\000\004\025\131\001\001\000\002\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\004\021\115\001\001\000\002\001\001\000\002\001" +
    "\001\000\004\022\110\001\001\000\020\026\106\030\101" +
    "\031\075\032\102\033\104\034\076\035\065\001\001\000" +
    "\002\001\001\000\002\001\001\000\010\032\113\034\076" +
    "\035\065\001\001\000\002\001\001\000\002\001\001\000" +
    "\002\001\001\000\002\001\001\000\014\031\120\032\102" +
    "\033\104\034\076\035\065\001\001\000\002\001\001\000" +
    "\002\001\001\000\002\001\001\000\024\017\125\026\124" +
    "\027\122\030\101\031\075\032\102\033\104\034\076\035" +
    "\065\001\001\000\002\001\001\000\002\001\001\000\002" +
    "\001\001\000\002\001\001\000\002\001\001\000\020\026" +
    "\130\030\101\031\075\032\102\033\104\034\076\035\065" +
    "\001\001\000\002\001\001\000\002\001\001\000\020\026" +
    "\133\030\101\031\075\032\102\033\104\034\076\035\065" +
    "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
    "\001\000\004\042\137\001\001\000\020\026\140\030\101" +
    "\031\075\032\102\033\104\034\076\035\065\001\001\000" +
    "\002\001\001\000\002\001\001\000\020\026\143\030\101" +
    "\031\075\032\102\033\104\034\076\035\065\001\001\000" +
    "\002\001\001\000\002\001\001\000\002\001\001\000\020" +
    "\026\155\030\101\031\075\032\102\033\104\034\076\035" +
    "\065\001\001\000\024\017\151\026\124\027\122\030\101" +
    "\031\075\032\102\033\104\034\076\035\065\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\002\001\001" });

  /** Access to <code>reduce_goto</code> 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 1;}

  /** <code>EOF</code> Symbol index. */
  public int EOF_sym() {return 0;}

  /** <code>error</code> Symbol index. */
  public int error_sym() {return 1;}



    
    boolean greska=false; // da li je prijavljena greska u toku prevodjenja
        
    // glavni program, kao metod klase parser
    public static void main(String args[]) throws Exception {
    		FileReader r=null;
    		try {
    		   r = new FileReader(args[0]);
    		} catch(Exception e) {
    		    System.err.println("Greska pri otvaranju ulaznog fajla");
    		    System.exit(1);
    		}
    		Yylex skener = new Yylex(r);
    		parser p = new parser(skener);
        /******************************************************************
        * Staticka metoda init tabele simbola sluzi za pocetno pravljenje 
        * tabele simbola, odnosno "universe" opsega.
        ******************************************************************/
    	  Tab.init();
    		Symbol s = p.parse();  //pocetak parsiranja
        /*****************************************************************
        * Po zavrsetku analize, pozivom metode dump(), vrsimo ispis 
        * sadrzaja tabele simbola.
        *****************************************************************/ 
    		Tab.dump();
    		try {
    		   if ( !p.greska && !Tab.greska && !Code.greska ) 
    		      Code.write(new FileOutputStream(args[1]));
    		} catch(Exception e) {
    		    System.err.println("Greska pri kreiranju objektnog fajla");
    		}
    }
  
    /***********************************************************************
    * slede redefinisani metodi za prijavu gresaka radi izmene teksta poruke
    ***********************************************************************/ 
    public void report_fatal_error(String message, Object   info) throws java.lang.Exception {
      done_parsing();
      report_error(message, info);
    }
  
    public void syntax_error(Symbol cur_token) {
        report_error("\nSintaksna greska", cur_token);
    }
  
    public void unrecovered_syntax_error(Symbol cur_token) throws java.lang.Exception {
        report_fatal_error("Fatalna greska, parsiranje se ne moze nastaviti", cur_token);
    }

  public void report_error(String message, Object info)
    {
      greska=true;
      System.err.print(message);
      System.err.flush();
      if (info instanceof Symbol)
	        System.err.println(" u liniji " + ((Symbol)info).left);
      else System.err.println("");
    }


}

/** Cup generated class to encapsulate user supplied action code.*/
class CUP$parser$actions {


    /*****************************************************************
    * Sledece promenljive ce biti vidljive iz akcija u svim 
    * smenama. var_type sluzi za cuvanje cvora Struct koji 
    * odgovara tipu na pocetku deklaracije grupe promenljivih.
    * method_type cuva povratni tip tekuceg metoda za semanticke provere  
    * kod return. promenljiva returnExists ima vrednost true ako telo metoda ima 
    * return iskaz.
    *****************************************************************/ 
    Struct var_type=Tab.noType;
    Struct method_type=Tab.noType;
    boolean returnExists=false; 

  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 63: // factor ::= LPAREN expr RPAREN 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		 RESULT=t; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 62: // factor ::= NEW type LSQUARE expr RSQUARE 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;
		int t1left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int t1right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Struct t1 = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		  if ( t1 != Tab.intType)
                            parser.report_error("Greska u liniji "+tleft+": velicina niza mora biti tipa int",null);
                        Code.put(Code.newarray);
                        if ( t == Tab.charType ) Code.put(0); 
                        else Code.put(1);
                        RESULT=new Struct(Struct.Arr, t);
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 61: // factor ::= CHARCONST 
            {
              Struct RESULT =null;
		int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Character c = (Character)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 Obj o = new Obj(Obj.Con, "", Tab.charType);
                       o.adr=c.charValue(); Code.load(o); 
                       RESULT=Tab.charType; 
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 60: // factor ::= NUMBER 
            {
              Struct RESULT =null;
		int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Integer i = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 Obj c = new Obj(Obj.Con, "", Tab.intType);
                       c.adr=i.intValue(); Code.load(c); 
                       RESULT=Tab.intType; 
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 59: // factor ::= designator LPAREN RPAREN 
            {
              Struct RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		 if (o.kind!=Obj.Meth )
                           parser.report_error("Greska u liniji "+oleft+": Ocekivan metod",null);
                       if (o.type==Tab.noType )
                           parser.report_error("Greska u liniji "+oleft+": Procedura pozvana kao funkcija",null);
                       int dest_adr=o.adr-Code.pc; // racunanje relativne adrese
                       Code.put(Code.call);
                       Code.put2(dest_adr);
                       RESULT=o.type; 
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 58: // factor ::= designator 
            {
              Struct RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		  if ( o.kind!=Obj.Var && o.kind!=Obj.Elem )
                             parser.report_error("Greska u liniji "+oleft+": Ocekivana promenljiva ili element niza",null);
                       Code.load(o);
                       RESULT=o.type;
                   
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 57: // factor ::= designator LPAREN act_pars RPAREN 
            {
              Struct RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;
		 // obrada stvarnih parametara nije implementirana
                       if (o.kind!=Obj.Meth )
                           parser.report_error("Greska u liniji "+oleft+": Ocekivan metod",null);
                       if (o.type==Tab.noType )
                           parser.report_error("Greska u liniji "+oleft+": Procedura pozvana kao funkcija",null);
                       int dest_adr=o.adr-Code.pc; // racunanje relativne adrese 
                       Code.put(Code.call); 
                       Code.put2(dest_adr);
                       RESULT=o.type;                     
                     
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor",24, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 56: // factor_list ::= MINUS factor 
            {
              Struct RESULT =null;
		 // nije implementirano
                       RESULT=Tab.noType; 
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor_list",25, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 55: // factor_list ::= factor 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 RESULT=t; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor_list",25, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 54: // factor_list ::= factor_list mulop factor 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		 // nije implementirano
                       RESULT=Tab.noType; 
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("factor_list",25, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 53: // term ::= factor_list 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 RESULT=t; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("term",23, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 52: // term_list ::= term 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 RESULT=t; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("term_list",22, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 51: // term_list ::= term_list addop term 
            {
              Struct RESULT =null;
		 // nije implementirano
                       RESULT=Tab.noType; 
                    
              CUP$parser$result = parser.getSymbolFactory().newSymbol("term_list",22, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 50: // expr ::= term_list 
            {
              Struct RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 RESULT=t; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("expr",20, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 49: // expr_list ::= expr 
            {
              Struct RESULT =null;
		 Code.put(Code.pop); 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("expr_list",21, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 48: // expr_list ::= expr_list COMMA expr 
            {
              Struct RESULT =null;
		 Code.put(Code.pop); 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("expr_list",21, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 47: // act_pars ::= expr_list 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("act_pars",13, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 46: // mulop ::= DIV 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("mulop",16, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 45: // mulop ::= TIMES 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("mulop",16, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 44: // addop ::= MINUS 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("addop",15, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 43: // addop ::= PLUS 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("addop",15, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 42: // ident_expr_list ::= IDENT 
            {
              Obj RESULT =null;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		
    		                   Obj ob=Tab.find(id, idleft); // find prijavljuje gresku u slucaju da ne nadje
                           if (ob != Tab.noObj) 
                               System.out.println("Pretraga "+idleft+" ("+id+"), nadjeno "+ob);
                           RESULT=ob; 
                       
              CUP$parser$result = parser.getSymbolFactory().newSymbol("ident_expr_list",27, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 41: // ident_expr_list ::= ident_expr_list LSQUARE NT$2 expr RSQUARE 
            {
              Obj RESULT =null;
              // propagate RESULT from NT$2
                RESULT = (Obj) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value;
		 if (o.type.kind!=Struct.Arr) {
                              parser.report_error("Greska u liniji "+oleft+": Ocekivan niz",null);
                              RESULT=o;
                          }
                       
              CUP$parser$result = parser.getSymbolFactory().newSymbol("ident_expr_list",27, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 40: // NT$2 ::= 
            {
              Obj RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
 if (o.type.kind==Struct.Arr) {
                              // generisanje koda 
                              Code.load(o);
                              // dalje prenosimo element niza
                              RESULT=new Obj(Obj.Elem, "", o.type.elemType);
                          }
                       
              CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$2",32, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 39: // designator ::= ident_expr_list 
            {
              Obj RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 RESULT=o; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("designator",26, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 38: // statement ::= PRINT LPAREN expr RPAREN SEMI 
            {
              Object RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		  if (t != Tab.intType && t!=Tab.charType ) 
	                   parser.report_error("Greska u liniji "+tleft+": tip izraza mora biti int ili char",null);
	               // generisanje koda
	               if (t == Tab.intType) {
	                   Code.loadConst(5); // sirina ispisa na e-stek, expr je vec na e-steku
	                   Code.put(Code.print);
	               } else {
	                   Code.loadConst(1); // sirina ispisa na e-stek, expr je vec na e-steku
	                   Code.put(Code.bprint);
	               }
	           
              CUP$parser$result = parser.getSymbolFactory().newSymbol("statement",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 37: // statement ::= RETURN expr SEMI 
            {
              Object RESULT =null;
		int dummyleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
		int dummyright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
		Object dummy = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		 
	               returnExists=true;
		             if (method_type==Tab.noType)
			                parser.report_error("Greska u liniji "+dummyleft+": metod ne sme imati return sa izrazom jer je deklarisan sa void",null);
	               if (!t.assignableTo(method_type))
	                    parser.report_error("Greska u liniji "+dummyleft+": tip izraza nekompatibilan sa deklaracijom metoda",null);
	               Code.put(Code.exit);
	               Code.put(Code.return_);
	           
              CUP$parser$result = parser.getSymbolFactory().newSymbol("statement",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 36: // statement ::= RETURN SEMI 
            {
              Object RESULT =null;
		int dummyleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int dummyright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Object dummy = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		 
	               returnExists=true;
		             if (method_type!=Tab.noType)
			               parser.report_error("Greska u liniji "+dummyleft+": metod mora imati return iskaz sa izrazom jer nije deklarisan sa void",null);
	               // generisanje koda
	               Code.put(Code.exit);
	               Code.put(Code.return_);
	           
              CUP$parser$result = parser.getSymbolFactory().newSymbol("statement",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 35: // statement ::= designator LPAREN act_pars RPAREN SEMI 
            {
              Object RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value;
		 // obrada stvarnih parametara nije implementirana
                       if (o.kind!=Obj.Meth )
                           parser.report_error("Greska u liniji "+oleft+": Ocekivan metod",null);
                       int dest_adr=o.adr-Code.pc; // racunanje relativne adrese 
                       Code.put(Code.call); 
                       Code.put2(dest_adr);
                       if (o.type!=Tab.noType )
                           Code.put(Code.pop); // rezultat poziva nece biti koriscen
                     
              CUP$parser$result = parser.getSymbolFactory().newSymbol("statement",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 34: // statement ::= designator LPAREN RPAREN SEMI 
            {
              Object RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;
		 
                       if (o.kind!=Obj.Meth )
                           parser.report_error("Greska u liniji "+oleft+": Ocekivan metod",null);
                       int dest_adr=o.adr-Code.pc; // racunanje relativne adrese 
                       Code.put(Code.call); 
                       Code.put2(dest_adr);
                       if (o.type!=Tab.noType )
                           Code.put(Code.pop); // rezultat poziva nece biti koriscen
                     
              CUP$parser$result = parser.getSymbolFactory().newSymbol("statement",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 33: // statement ::= designator EQUAL expr SEMI 
            {
              Object RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		 if ( t.assignableTo(o.type) )
                         Code.store(o);
                    else
                        parser.report_error("Greska u liniji "+oleft+": nekompatibilni tipovi za dodelu",null);
                 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("statement",12, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 32: // stmt_list ::= 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("stmt_list",10, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 31: // stmt_list ::= stmt_list statement 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("stmt_list",10, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 30: // parameter ::= type IDENT LSQUARE RSQUARE 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("parameter",11, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 29: // parameter ::= type IDENT 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("parameter",11, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 28: // parameter_list ::= parameter 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("parameter_list",17, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 27: // parameter_list ::= parameter_list COMMA parameter 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("parameter_list",17, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 26: // form_pars ::= 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("form_pars",9, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 25: // form_pars ::= parameter_list 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("form_pars",9, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 24: // method_dec ::= return_type_ident LPAREN form_pars RPAREN local_var_list LBRACE NT$1 stmt_list RBRACE 
            {
              Object RESULT =null;
              // propagate RESULT from NT$1
                RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value;
		
		                  if (method_type!=Tab.noType && !returnExists) { 
			                    parser.report_error("Greska u liniji "+oleft+": Metod mora imati return iskaz jer nije deklarisan sa void",null);
			                }
                      returnExists=false;
                      o.locals = Tab.topScope.locals; Tab.closeScope();
                      // generisanje koda
                      if (method_type==Tab.noType) {
                          Code.put(Code.exit); Code.put(Code.return_);
                      } else { // end of function reached without a return statement
                          Code.put(Code.trap); Code.put(1);
                      }
	               
              CUP$parser$result = parser.getSymbolFactory().newSymbol("method_dec",8, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 23: // NT$1 ::= 
            {
              Object RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value;
 // generisanje koda
                    if (o.name.equals("main")) {
												Code.mainPc = Code.pc;
												if (method_type!=Tab.noType) parser.report_error("Greska u liniji "+oleft+": metod main mora biti void",null);
										}
                    o.level = 0; // za metode, broj parametara, ovde ignorisemo parametre
                    o.adr = Code.pc;
                    Code.put(Code.enter);
                    Code.put(o.level);
                    Code.put(Tab.topScope.nVars);
                 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$1",31, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 22: // return_type_ident ::= VOID IDENT 
            {
              Obj RESULT =null;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 method_type=Tab.noType; 
		                RESULT = Tab.insert( Obj.Meth, id, idleft, Tab.noType); 
                    Tab.openScope(); 
                  
              CUP$parser$result = parser.getSymbolFactory().newSymbol("return_type_ident",29, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 21: // return_type_ident ::= type IDENT 
            {
              Obj RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 method_type = t;
		                RESULT = Tab.insert( Obj.Meth, id, idleft, t); 
                    Tab.openScope(); 
		             
              CUP$parser$result = parser.getSymbolFactory().newSymbol("return_type_ident",29, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 20: // method_declaration_list ::= 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("method_declaration_list",2, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 19: // method_declaration_list ::= method_declaration_list method_dec 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("method_declaration_list",2, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 18: // local_var_list ::= 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("local_var_list",14, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 17: // local_var_list ::= local_var_list var_dec 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("local_var_list",14, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 16: // var_part ::= IDENT LSQUARE RSQUARE 
            {
              Object RESULT =null;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		 Tab.insert(Obj.Var, id, idleft, new Struct(Struct.Arr, var_type));
                  
              CUP$parser$result = parser.getSymbolFactory().newSymbol("var_part",6, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 15: // var_part ::= IDENT 
            {
              Object RESULT =null;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 Tab.insert(Obj.Var, id, idleft, var_type);
                  
              CUP$parser$result = parser.getSymbolFactory().newSymbol("var_part",6, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 14: // var_list ::= var_part 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("var_list",5, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 13: // var_list ::= var_list COMMA var_part 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("var_list",5, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 12: // var_dec ::= type NT$0 var_list SEMI 
            {
              Object RESULT =null;
              // propagate RESULT from NT$0
                RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("var_dec",3, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 11: // NT$0 ::= 
            {
              Object RESULT =null;
		int tleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int tright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		Struct t = (Struct)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
 var_type=t; 
              CUP$parser$result = parser.getSymbolFactory().newSymbol("NT$0",30, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 10: // rhs ::= CHARCONST 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("rhs",4, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 9: // rhs ::= NUMBER 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("rhs",4, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 8: // type ::= IDENT 
            {
              Struct RESULT =null;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 Obj novi=Tab.find(id, idleft);
                if (novi.kind == Obj.Type )
                   RESULT = novi.type;
                else {
                   parser.report_error("Greska u liniji "+idleft+" ("+id+") nije tip",null);
                   RESULT=Tab.noType;
               }
             
              CUP$parser$result = parser.getSymbolFactory().newSymbol("type",19, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 7: // const_dec ::= FINAL type IDENT EQUAL rhs SEMI 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("const_dec",7, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 6: // declaration_part ::= var_dec 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("declaration_part",18, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 5: // declaration_part ::= const_dec 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("declaration_part",18, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 4: // declaration_list ::= 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("declaration_list",1, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 3: // declaration_list ::= declaration_list declaration_part 
            {
              Object RESULT =null;

              CUP$parser$result = parser.getSymbolFactory().newSymbol("declaration_list",1, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 2: // prog_id ::= IDENT 
            {
              Obj RESULT =null;
		int idleft = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).left;
		int idright = ((java_cup.runtime.Symbol)CUP$parser$stack.peek()).right;
		String id = (String)((java_cup.runtime.Symbol) CUP$parser$stack.peek()).value;
		 RESULT = Tab.insert(Obj.Prog,id,idleft,Tab.noType);
                   Tab.openScope(); 
                
              CUP$parser$result = parser.getSymbolFactory().newSymbol("prog_id",28, ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 1: // $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;
		Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
		RESULT = start_val;
              CUP$parser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          /* ACCEPT */
          CUP$parser$parser.done_parsing();
          return CUP$parser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 0: // program ::= CLASS prog_id declaration_list LBRACE method_declaration_list RBRACE 
            {
              Object RESULT =null;
		int oleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left;
		int oright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right;
		Obj o = (Obj)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value;
		 o.locals=Tab.topScope.locals;
	               Code.dataSize=Tab.topScope.nVars;
                 Tab.closeScope();
		          
              CUP$parser$result = parser.getSymbolFactory().newSymbol("program",0, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)), ((java_cup.runtime.Symbol)CUP$parser$stack.peek()), RESULT);
            }
          return CUP$parser$result;

          /* . . . . . .*/
          default:
            throw new Exception(
               "Invalid action number found in internal parse table");

        }
    }
}

