X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=documentation;h=c3ac4e08ba815c574432d3e2f0905cf120a460e1;hb=cdcd3b92ee3145e646634d428b02118238d47f33;hp=269e93139c744f83508a076206088f76e7634b81;hpb=fd2a569443cdb0813529071e77b999ea53397e43;p=proglang.git diff --git a/documentation b/documentation index 269e931..c3ac4e0 100644 --- a/documentation +++ b/documentation @@ -13,74 +13,98 @@ typing rules ++++++++++++ -(t is little tau, T is large tau, E is 'in', and + is that other symbol) +(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] -[Eq, Neq] + => <= => => v is the result of using operator o on v1 and v2 -e:bool <= e1:t & e2:t -where e is e1 Eq e2. +[Assignment] -[Plus, Minus, Times, Div] + => c'[i -> v] <= => -e:int <= e1:int & e2:int -where e is e1 Plus e2. +Assign the value v to i in the first scope i is found in. +[ENeg] -[Lt, ELt, Gt, EGt] + => <-v,c'> <= => -e:bool <= e1:int & e2:int -where e is e1 Lt e2. +[ENot] -[Assignment] + => <= => -T+ i := e:t <= i:t E T & T+ e:t -where the assignment is identifier i = expression e. +[EVar] + => -[ExpT] +[EInt] -u,e:t <= e:t & u:t -where the expression is type u expression e. + => +[EBool] -[ENeg] + => -e:int <= e:int +[EReadI,EReadB] + => <= => -[ENot] +[EPost] + + => v']> <= c(i) => v, v±1 => v' -e:bool <= e:bool +Look up the variable, add/subtract 1 from the value then return the old value and context with modified value +[SExp] -[SExp, SBlock] + => c' <= => -S:NoType <= e:t +[SBlock] + => c''' <= push(c) => c' => c'' pop(c'') => c''' + +Push a new scope onto the context, execute the statements in this context and the pop the scope from the context + +[SEQ] + + => c'' <= => c' => c'' [SIf] -T+ if e then s1 else s2 <= T+ e:bool & T+ s1 & T+ s2 + => pop(c''') <= => push(c') => c''' + + => pop(c''') <= => push(c') => c''' [SWhile] -T+ while e do s <= T+ e:bool & T+ s + => c' => => + + => pop(c''') => => push(c') => c'' => c''' [SDecl] -T+ i:t => T', i:t <= i!ET & e:t & u:t + => c'[i->v] <= => + +Adds i with value v to the current scope in the context -(Type u Ident i = Exp e) +[SDeclD] + => c[i->0] + => c[i->false] +Adds i with default value in the current scope +[SNoop] + => c +SNoops does nothing so the same context is returned +[SPrint] + => c'' <= => => c''