####### DOCUMENTATIATOIAITAT ION ########
+Usage:
+./CompInt [-c] [file]
+-c : Compile [file], interprets if it isn't specified
-a simple c-like language with support for if/else-statements, while-loops and the standard arithmetic (+, -, /, *) and comparison expressions (<, >, <=, >=, ==, !=). also, increase/decrease expressions (++, --) are supported.
+if no arguments are specified then the file is interpreted
-data types:
-integers and booleans.
+Files:
+Interpret.hs: Handles the interpretation of a program
-comments:
-// and /* */ comments are allowed.
+Compile.hs: Compiles the program into a c program
+Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
+Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process.
+Abssyntax.hs, Parsyntax.y, Lexsyntax.x,ErrM.hs,Printsyntax.hs,Skelsyntax.hs: The files generated by bnfc, only modification is the removal of the Bool type in Abssyntx.hs so haskell's internal type can be used.
+Additions which comes from the extension:
+typing rules
+++++++++++++
+[EFunc]
+(t is used for types, T is the context, and + is used for in)
+T+ i (es) : t <= i(ts):t in T & T+ es:ts
+The functioncall of i returns t if i is in the context with returntype t and the types of the argument expressions matches those in the parameter list
+[SReturn]
+T+ return e <= e:t & ret(t) in T
-examples:
+return typechecks if e returns the same type as the current context
-fib
----
-int n1 = 0;
-int n2 = 1;
-int n = readInt;
+[Func]
-while(n-- > 0){
- int temp = n1+n2;
- n1 = n2;
- n2 = temp;
-}
-print n2;
+T+ t i (ds) ss <= T,novariables,ret(t),ds => T' & T'+ss & last(ss) => return:t
+the function i typechecks if the body typechecks in the context where all other variables has been removed and the return type and paramters has been added and that the last statement is a return with the right type
-tests while, decr and assignment.
+semantic rules
+++++++++++++
+(v is used for values, e for expressions, s for statements, c is the context)
-if
---
-if (readBool) {
- if (readInt < 0)
- print true;
- else
- print false;
-}
-tests if and if/else.
-
-
-
-sum
----
-int n;
-int sum = 0;
-while ((n = readInt) != -1) sum = sum + n;
-print sum;
-
-
-
-
-var
----
-int a = 3;
-int b = a - 5;
-int c = a + b*7;
-bool d = a == b;
-
-tests simple variable operations.
\ No newline at end of file