]> ruin.nu Git - proglang.git/blobdiff - documentation
updating documentation
[proglang.git] / documentation
index 70bd0c818b7f8c298ca3658a67729c6413db122b..f46afb702549b5b0a7a530b699a49ea20fb2c5d1 100644 (file)
@@ -1,97 +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, post increase/decrease expressions (++, --) are supported. Assignments are allowed in expressions, but they are only allowed on the right side of arithmetic/comparision operators if they are put inside parenthesis
+./CompInt [-c] [file]
 
+-c : Compile [file], interprets if it isn't specified
 
-data types:
-integers and booleans.
+if no arguments are specified then the file is interpreted
 
-comments:
-// and /* */ comments are allowed.
+Files:
+Interpret.hs: Handles the interpretation of a program
 
-(For compilation to work the Bool type in Abssyntax has to be removed so the internal haskell type is used)
+Compile.hs: Compiles the program into a c program
 
-shift/reduce conflicts:
+Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions.
 
-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.
+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 little tau, T is large tau, E is 'in', and + is that other symbol)
+(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
 
-[Eq, Neq]
+[SReturn]
 
-e:bool  <=  e1:t  &  e2:t
-where e is e1 Eq e2.
+T+ return e <= e:t & ret(t) in T
 
+return typechecks if e returns the same type as the current context
 
-[Plus, Minus, Times, Div]
+[Func]
 
-e:int  <=  e1:int  &  e2:int
-where e is e1 Plus e2.
-
-
-[Lt, ELt, Gt, EGt]
-
-e:bool  <=  e1:int  &  e2:int
-where e is e1 Lt e2.
-
-
-[Assignment]
-
-T+ i := e:t  <=  i:t E T  &  T+ e:t
-where the assignment is identifier i = expression e.
-
-
-[ExpT]
-
-u,e:t  <=  e:t  &  u:t
-where the expression is type u expression e.
-
-
-[ENeg]
-
-e:int  <=  e:int
-
-
-[ENot]
-
-e:bool  <=  e:bool
-
-
-[SExp, SBlock]
-
-S:NoType  <=  e:t
-
-
-[SIf]
-
-T+ if e then s1 else s2  <=  T+ e:bool  &  T+ s1  &  T+ s2
-
-
-[SWhile]
-
-T+ while e do s  <=  T+ e:bool  &  T+ s
-
-
-[SDecl]
-
-T+ i:t => T', i:t  <=  i!ET  &  e:t  &  u:t
-
-(Type u Ident i = Exp e)
+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)