]> ruin.nu Git - proglang.git/blobdiff - documentation
more generic type declaration and evaluates input directly
[proglang.git] / documentation
index 47008eefba987fb88613cf46094072b64c289764..9127c08827fa09ed2efd4644569d43d8c73e3bfc 100644 (file)
@@ -1,5 +1,8 @@
 ####### DOCUMENTATIATOIAITAT ION ########
 
+Functions has been added, with c style syntax.
+
+
 Usage:
 
 ./CompInt [-c] [file]
@@ -20,102 +23,67 @@ Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar an
 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.
 
 
-semantic rules
-++++++++++++
-
-
-(v is used for values, e for expressions, s for statements, c is the context)
-
-
-[Eq, NEq, Plus, Minus, Times, Div, Lt, ELt, Gt, EGt]
-
-<e1 o e2,c> => <v,c''> <= <e1,c> => <v1,c'>  <e2,c'> => <v2,c''> v is the result of using operator o on v1 and v2
-
-
-[Assignment]
-
-<i := e,c> => c'[i -> v] <= <e,c> => <v,c'>
-
-Assign the value v to i in the first scope i is found in.
-
-[ENeg]
+Additions which comes from the extension:
 
-<e,c> => <-v,c'> <= <e,c> => <v,c'>
-
-
-[ENot]
-
-<e,c> => <not v,c'> <= <e,c> => <v,c'>
-
-[EVar]
-
-<i,c> => <c(i),c>
-
-[EInt]
-
-<n,c> => <n,c>
-
-[EBool]
-
-<b,c> => <b,c>
-
-[EReadI,EReadB]
+typing rules
+++++++++++++
 
-<c> => <v,c'> <= <IO,c> => <v,c'>
+(t is used for types, T is the context, and + is used for in)
 
-[EPost]
+[EFunc]
 
-<i,c> => <v,c[i->v']> <= c(i) => v, v±1 => v'
+T+ i (es) : t <= i(ts):t in T & T+ es:ts 
 
-Look up the variable, add/subtract 1 from the value then return the old value and context with modified value
+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
 
-[SExp]
+[SReturn]
 
-<e,c> => c' <= <e,c> => <v,c'>
+T+ return e <= e:t & ret(t) in T
 
-[SBlock]
+return typechecks if e returns the same type as the current context
 
-<SBlock s,c> => c'''  <= push(c) => c' <s,c'> => c'' pop(c'') => c'''
+[Func]
 
-Push a new scope onto the context, execute the statements in this context and the pop the scope from the context
+T+ t i (ds) => T' <= ds:ts & T,i(ts):t => T'
 
-[SEQ]
+Adds the function with parameter types and returntype to the context
 
-<s1;s2,c> => c'' <= <s1,c> => c' <s2,c'> => c''
+T+ t i (ds) ss <= T,novariables,ret(t),ds => T' & T'+ss & last(ss) => return:t
 
-[SIf]
+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
 
-<if e s1 s2,c> => pop(c''') <= <e,c> => <true,c'> push(c') <s1,c''> => c'''
+[Program]
 
-<if e s1 s2,c> => pop(c''') <= <e,c> => <false,c'> push(c') <s2,c''> => c'''
+T+ fs ss <= T+,fs => T' && T'+ fs && T'+ ss
 
+The program typechecks if all the functions and all the statements typechecks in the context with all functions added to it.
 
-[SWhile]
+semantic rules
+++++++++++++
 
-<while e s,c> => c' => <e,c> => <false,c'>
+(v is used for values, e for expressions, s for statements, c is the context)
 
-<while e s,c> => pop(c''') => <e,c> => <true,c'> push(c') => c'' <s,c''> => c'''
+[EFunc]
 
+<i (es), c> => <o'''(ret),o'>  <= <es,c> => <vs,c'>, c(i) => <ds,ss>, c'[clearVars,ds->vs] => c'' <ss,o''> => o'''
 
-[SDecl]
+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.
 
-<i := e,c> => c'[i->v] <= <e,c> => <v,c'>
 
-Adds i with value v to the current scope in the context
+[SReturn]
 
-[SDeclD]
+<return e,c> <= <e,c> => <v,c'>, c'[ret->v], STOP
 
-<int i,c> => c[i->0]
-<bool i,c> => c[i->false]
+Evaluate the expression, add the value as return value to the state and stop the execution of the state
 
-Adds i with default value in the current scope
+[Func]
 
-[SNoop]
+<t i (ds) ss, c> => c[i-><ds,ss>]
 
-<SNoop,c> => c
+Adds the function i with parameters ds and body ss to the context
 
-SNoops does nothing so the same context is returned
+[Program]
 
-[SPrint]
+<fs ss, c> => c'' <= c[fs] => c', <ss,c'> => c''
 
-<e,c> => c'' <= <e,c> => <v,c'> <IO v,c'>  => c''
+Add all the function to the context and execute the statements in this context