NAME
     procedure - controls the main flow of a procedure.
     inblock   - checks the inblock.

SYNOPSIS
     #include "getsym.h"
     procedure.c

     void
     procedure(void);

     void
     inblock(void);

DESCRIPTION
     The file "procedure.c" contains all the functions mentioned above.
     It controls the main flow of a procedure.

     At the very beginning procedure function sets the procedure_flag to
     1(on), so that the code_generator will produce appropiate assembly 
     codes. At first it looks it makes sure that a procedure is declared
     appropiately with a procedure identifier follwed by the real
     identifier:

		 -----------     -------     ---------
          ----->| procedure |-->| ident |-->| inblock |--->
		 -----------     -------     ---------

     It passes the control over inblock when it succeed. 

     Inside inblock a local table is declared:

	  procedure_table = init_table();

     And this local table is used to register all the variables declared
     in the procedure:

	  table(tok.charvalue, procedure_table);

     Variable registration is performed in two stages:

          o Stage 1:

		         ___     _______      ___
                  ----->| ( |-->| ident |----| ) |----
		         ---  ^  -------   |  ---     |
	                      |     ___    |          |
                              |____| , |___|          |
	                            ---               |	
	                ___                           | 
                  <----| ; |__________________________|
	                ---     

          o Stage 2:

		         _____     _______
                  ----->| var |-->| ident |----------- 
		         -----  ^  -------            |
	                ___	|        ___          |
                  <----| ; |____|_______| , |_________|
	                ---              --- 	

     If inblock registers variable successfully, it passes the control
     over statement. Though procedure_flag forces the code_generator
     to produce codes like:

	  loadi   r3, 1
	  store   r3, 0(BR) # considering the address of a is 0

     It will never the less search the glabal variable table for a
     unmatched variable in the local table. For example:

	  ------- exmaple program starts below ---------
          program test;
	  var sum;

	  procedure proc1(a, b);
	  var c;
	      .
	      .
	      .
	    sum := a;

	  begin
	    proc1(1, 2);
	  end.
	  ------- exmaple program ends here ---------

     will force the code_generatore to use the global variable sum,
     since sum doesn't exists in the local variable table. However,

	  ------- exmaple program starts below ---------
          program test;
	  var sum;

	  procedure proc1(a, b);
	  var c, sum;
	      .
	      .
	      .
	    sum := a;

	  begin
	    proc1(1, 2);
	  end.
	  ------- exmaple program ends here ---------

     will use the local variable sum instead of global variable. So,
     the priority is given to the local variable table when procedure_flag
     is on.

FILES
     procedure.c
     getsym.h

WARNING
     The following variables are declared as extern variables:

          extern  TOKEN   tok;    
          extern  FILE    *infile;
          extern  FILE    *outfile;
          extern  struct  list    *Table;
          extern  int     procedure_flag;

     These variables should be declared somewhere before explicitly used.
     Here, these variables were declared in main.c.

SEE ALSO
     statement, code_generator, table.

AUTHOR
     Chakma Junan <jchakma@yahoo.com> 
     Information and Computer Sciences
     Toyohashi University of Technology.
     (It was originially implemented by: ohno@edu.tut.ac.jp)

     Last Updated: Mon Feb 14 21:02:59 JST 2000

