CS335- Compiler Design Project(GROUP 8)
-------------------------------

To run :
	make
	./oberon2 filename [Parameter]

for example: 
 	./oberon2 test_cases/code_generation/code1.m 

PARAMETER (OPTIONAL)
--------------> to check for typeChecking cases: --typeCheck
--------------> to print the intermediate code:  --printIC
--------------> to show the code after optimization: --showOpt
-------------> to print the leaders of the flow graph: --printLeaders

* Sample intermediate code given in the folder.


=====================	
Organization of Code
=====================
  * Lexer - oberon.l
  * Parser - oberon.y
  * Classes and functions related to types - type.h type.cpp
  * Scope class and related functions - scope.h
  * Classes for intermediate code instruction - ic.h, ic.cpp, icgen.h, icgen.cpp
  * Classes for register handler: reg.h, reg.cpp
  * Classes for final code generation: codegen.h, codegen.cpp
  * Classes for debugging symbols : debug.h, debug.cpp

==============================================
  Phase $ : Mips32 Code Generation
==============================================
Features mentioned in the Project report attached. Test cases for code generation can be found in code_generation folder in test_cases.

==============================================
  Phase 3 : Intermediate Code Generation
==============================================

  **NOTE: We designed our own grammar for backpatching using synthesized attributes which was efficient as compared to that given in Aho, Ullman and Sethi. The grammar takes constant time during backpatching as compared to O(n) taken by the latter, where n is the size of list to be backpatched.

  Features implemented:
  1) Basic Expression code implemented.
  2) Constant Expressions handled at compile time.
  3) If-ElseIF-Else implemented. 
  2) While loop implmented
  3) Repeat-Until loop implemented.
  3) Multidimensional Arrays implemented.
  4) Feature of passing any complex expression as argument to array implemented. 
     for eg: a[2,b[5],m+1][3][4]

  Feature not implemented:
  1) We are providing the feature of functions able to return array as well as 
     functions. IC for function call not done although the complete type checking 
     is being carried out. This will be handled along with the next phase.
  2) IC for record is not implemented as they will require the fixing of width 
     variables which will be carried out in code generation part.
  

==============================================
  Phase 2 : Type Checking and Scoping System
==============================================

  Features implemented:

  1) Declaration of variables, types and procedures
  2) Type checking on expressions, procedure calls, procedure return, and loops.
  3) Change of Scope
  4) Nested Procedure Declarations, Multiple Argument Procedures
  5) A simple but gracious error system. Multiple errors recognizable
     (ERROR type has been used to avoid repetitive errors due to one mistake.)
  
  Features not implemented-
  1) Type checking for ARRAY types
     (This would be done at run-time since we are providing with the feature of   
      using expressions as arguments of the array. For example: a[2,b[5],m*3]; )


================
  TEST CASES
================

Intermediate Code:
	Basic Expressions			ic1.m
	IF-ELSE 				ic2.m, ic5.m
	NESTED IF-ELSE				ic3.m
 	IF ELSEIF 				ic4.m

	WHILE LOOP				ic6.m
	REPEAT UNTIL 				ic7.m
	
	NESTED ARRAY(imp feature)		arr0.m, arr4.m
	Simple ARRAY				arr1.m
	Expressions inside array		arr2.m, arr3.m
	
-----------------------------------------------------------------	

Type Checking:
	General type checking: 			test1, test1_1
	Type checking in assignment : 		test2
	Type Conversion:			test3, test4

While Loop, Operators:				test5
RECORD TYPE TESTING:				test6

Type Expansion:					test7
PROCEDURE CALL, PROCEDURE SYNTAX TESTING: 	test8
USE OF ERROR TYPE: 				test10

SCOPE TESTING, ACCESSING PARENT VARIABLES: 	test9, test14

Imp Feature-->NESTED PROCEDURE TESTING: 	test11, test12
Multiple Argument Procedure:			test13
