]> ruin.nu Git - proglang.git/blobdiff - documentation
updating documentation
[proglang.git] / documentation
index 2d3fcac33546a4e9ed73608a54d47478f0c34ac7..f46afb702549b5b0a7a530b699a49ea20fb2c5d1 100644 (file)
@@ -1,31 +1,55 @@
 ####### DOCUMENTATIATOIAITAT ION ########
 
+Usage:
 
-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.
+./CompInt [-c] [file]
 
-data types:
-integers and booleans.
+-c : Compile [file], interprets if it isn't specified
 
-comments:
-// and /* */ comments are allowed.
+if no arguments are specified then the file is interpreted
 
-shift/reduce conflicts:
+Files:
+Interpret.hs: Handles the interpretation of a program
 
-30 conflicts in total.
+Compile.hs: Compiles the program into a c program
 
-1) Exp1 followed by (<,<=,>,>=,==,!=,+,-) 8 conflicts:
-In these cases the Exp1 could've been reduced to Exp, but happy does the correct thing and shifts the operator token onto the stack, since Exp followed by these operators doesn't match any rules.
+Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
 
-2) Exp2 followed by (*,/) 6 conflicts:
-In two cases the Exp2 expression could be reduced to Exp1, but this wouldn't match the rules for these operators, so shifting is the correct action.
+Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process.
 
-In four other cases the Exp2 in front of these operators can be reduced to addition and subtraction expressions, which would destroy operator priority, so shifting is correct here.
+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
+
+return typechecks if e returns the same type as the current context
+
+[Func]
+
+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
+
+semantic rules
+++++++++++++
+
+
+(v is used for values, e for expressions, s for statements, c is the context)
 
-3) Exp1 followed by (+,-) 12 conflicts:
-In all these cases Exp1 could be reduced together with another Exp1 and a comparative operator to an Exp, but just as in the above case this would be very bad for operator priority, so shifting is right here.
 
-4) if with else: 1 conflict
-An if statement before the else could be reduced to an if statement lacking the else, but the correct thing is to shift it onto the stack.
 
-5) if/ifelse/while followed by (;): 3 conflicts
-Here we have redundant semicolons, these could all be reduced to individual statements without the ';'. Such a reduction wouldn't cause any harm, but neither does the shifting, it's an ok choice.