]> ruin.nu Git - proglang.git/commitdiff
semantics and some more typing rules
authorMichael Andreen <harv@ruin.nu>
Tue, 14 Mar 2006 22:07:53 +0000 (22:07 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 14 Mar 2006 22:07:53 +0000 (22:07 +0000)
documentation

index f46afb702549b5b0a7a530b699a49ea20fb2c5d1..9127c08827fa09ed2efd4644569d43d8c73e3bfc 100644 (file)
@@ -1,5 +1,8 @@
 ####### DOCUMENTATIATOIAITAT ION ########
 
+Functions has been added, with c style syntax.
+
+
 Usage:
 
 ./CompInt [-c] [file]
@@ -25,10 +28,10 @@ Additions which comes from the extension:
 typing rules
 ++++++++++++
 
-[EFunc]
-
 (t is used for types, T is the context, and + is used for in)
 
+[EFunc]
+
 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
@@ -41,15 +44,46 @@ return typechecks if e returns the same type as the current context
 
 [Func]
 
+T+ t i (ds) => T' <= ds:ts & T,i(ts):t => T'
+
+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
 
 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
 
+[Program]
+
+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.
+
 semantic rules
 ++++++++++++
 
-
 (v is used for values, e for expressions, s for statements, c is the context)
 
+[EFunc]
+
+<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.
+
+
+[SReturn]
+
+<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