COSC4307                      Program-6		Due: 12/3/2009.
			        Quadruple Generator(1)
		
	Consider the following Block-structured CFG:

	Program -->	Start Block finish
	Block --->	BEGIN Body END
	Body --->	Body ; S
	Body --->	S
	S --->		Block
	S --->		PRINT Elist
	S --->		READ Vlist
	S --->		IF E THEN S FI
	S --->		IF E THEN S ELSE S FI
	S --->		V = E
	S --->		INTEGER Ilist
	S --->		REAL Ilist
	Ilist --->	Ilist , Id
	Ilist --->	Id
	Ilist --->	Id (Clist )
	Ilist --->	Ilist , Id (Clist)
	Clist --->	Clist , C
	Clist --->	C
	Elist --->	Elist , E
	Elist --->	E
	Vlist --->	Vlist , V
	Vlist --->	V
	V --->		Id
	V --->  	Id ( Elist )
	E --->		E + T
	E --->		E - T
	E --->		T
	T --->		T * F
	T --->		F
	T --->		- F
	F --->		C
	F --->		V
	F --->		( E )

	NOTE: "Id" Stands for an identifier which is a letter followed
	      by zero or more letters and/or digits, and "C" an unsigned
	      integer constant.

	Task:
	
	Write a quadruple generator that does:

	1. Read production rules of a grammar and echo print them.
	2. Read a source program (which is a sequence of tokens) 
	   and echo print it.
	3. Generate and output a sequence of quadruples of the form:

		+    A    B    RESULT
		-    A    B    RESULT
		*    A    B    RESULT
		/    A    B    RESULT
		BR             TARGET	/* Unconditional branch
		BEQ  A    B    TARGET	/* Branch if A and B are equal
		BNEQ A    B    TARGET	/* Branch if A and B are not equal
		BGT  A    B    TARGET   /* Branch if A is greater than B
		BLS  A    B    Target   /* Branch if A is less than B
		READ           VAR	/* Read into a variable
		PRINT          ADDRESS	/* Print the value of a memory address
		=    A         RESULT	/* Assignment. i.e., RESULT = A
		NEG  A         RESULT	/* RESULT = -(A)
		INC  A	       RESULT	/* RESULT = A+1
	
	4. Assume that the only statements are:

		IF-statement
		Assignment statement
		READ statement
		PRINT statement
		INTEGER statement
		REAL statement and
		Blocks of these statements, and that arrays are not yet in. 

	Input source program:
	        // Note the source program is case-insensitive.//

		Start
		BEGIN
		  REAL X123, Y1234, ABC123;
		  INTEGER LongVARIAB, ABC, ABCDEF;
		  READ  X123, Y1234, ABCDEF;
		  READ  LongVariab, ABC, ABC123;
		  IF ABC123-X123 THEN ABC123=ABC123+100  FI;
		  X123 = -ABC + X123 * ABC123 + X;
		  Begin
	 	    Integer X1234, Y123;
		    READ Y123, X1234, LongVariab ;
	 	    X1234 = X1234 + Y123 * LongVariab
		    End;
		  PRINT X1234*X1234, LongVariab-Y1234
		    End 
		  Finish