]> ruin.nu Git - proglang.git/blobdiff - documentation
more generic type declaration and evaluates input directly
[proglang.git] / documentation
index d649bbaedbe29fe03f586ac9699b30c70b0f4348..9127c08827fa09ed2efd4644569d43d8c73e3bfc 100644 (file)
@@ -1,85 +1,89 @@
 ####### DOCUMENTATIATOIAITAT ION ########
 
-
-Files:
-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.
-
-
-typing rules
-++++++++++++
+Functions has been added, with c style syntax.
 
 
-(t is little tau, T is large tau, E is 'in', and + is that other symbol)
+Usage:
 
+./CompInt [-c] [file]
 
-[Eq, Neq]
+-c : Compile [file], interprets if it isn't specified
 
-e:bool  <=  e1:t  &  e2:t
-where e is e1 Eq e2.
+if no arguments are specified then the file is interpreted
 
+Files:
+Interpret.hs: Handles the interpretation of a program
 
-[Plus, Minus, Times, Div]
+Compile.hs: Compiles the program into a c program
 
-e:int  <=  e1:int  &  e2:int
-where e is e1 Plus e2.
+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.
 
-[Lt, ELt, Gt, EGt]
+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.
 
-e:bool  <=  e1:int  &  e2:int
-where e is e1 Lt e2.
 
+Additions which comes from the extension:
 
-[Assignment]
+typing rules
+++++++++++++
 
-T+ i := e:t  <=  i:t E T  &  T+ e:t
-where the assignment is identifier i = expression e.
+(t is used for types, T is the context, and + is used for in)
 
+[EFunc]
 
-[ExpT]
+T+ i (es) : t <= i(ts):t in T & T+ es:ts 
 
-u,e:t  <=  e:t  &  u:t
-where the expression is type u expression e.
+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]
 
-[ENeg]
+T+ return e <= e:t & ret(t) in T
 
-e:int  <=  e:int
+return typechecks if e returns the same type as the current context
 
+[Func]
 
-[ENot]
+T+ t i (ds) => T' <= ds:ts & T,i(ts):t => T'
 
-e:bool  <=  e:bool
+Adds the function with parameter types and returntype to the context
 
+T+ t i (ds) ss <= T,novariables,ret(t),ds => T' & T'+ss & last(ss) => return:t
 
-[SExp, SBlock]
+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
 
-S:NoType  <=  e:t
+[Program]
 
+T+ fs ss <= T+,fs => T' && T'+ fs && T'+ ss
 
-[SIf]
+The program typechecks if all the functions and all the statements typechecks in the context with all functions added to it.
 
-T+ if e then s1 else s2  <=  T+ e:bool  &  T+ s1  &  T+ s2
+semantic rules
+++++++++++++
 
+(v is used for values, e for expressions, s for statements, c is the context)
 
-[SWhile]
+[EFunc]
 
-T+ while e do s  <=  T+ e:bool  &  T+ s
+<i (es), c> => <o'''(ret),o'>  <= <es,c> => <vs,c'>, c(i) => <ds,ss>, c'[clearVars,ds->vs] => c'' <ss,o''> => o'''
 
+Evaluate the arguments in order, find function definition, remove the old variables and add values from the arguments to the parameters. execute the body until retun. Return the value from the return state and the state from the argument expressions.
 
-[SDecl]
 
-T+ i:t => T', i:t  <=  i!ET  &  e:t  &  u:t
+[SReturn]
 
-(Type u Ident i = Exp e)
+<return e,c> <= <e,c> => <v,c'>, c'[ret->v], STOP
 
+Evaluate the expression, add the value as return value to the state and stop the execution of the state
 
+[Func]
 
+<t i (ds) ss, c> => c[i-><ds,ss>]
 
+Adds the function i with parameters ds and body ss to the context
 
+[Program]
 
+<fs ss, c> => c'' <= c[fs] => c', <ss,c'> => c''
 
+Add all the function to the context and execute the statements in this context