From: Michael Andreen Date: Tue, 14 Mar 2006 20:54:11 +0000 (+0000) Subject: updating documentation X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=commitdiff_plain;h=bb79f91257da50013a4175c7c57973a6570eb3a1 updating documentation --- bb79f91257da50013a4175c7c57973a6570eb3a1 diff --cc documentation index c3ac4e0,47008ee..f46afb7 --- a/documentation +++ b/documentation @@@ -1,110 -1,121 +1,55 @@@ ####### DOCUMENTATIATOIAITAT ION ######## + Usage: - 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 - ++++++++++++ - - - (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] - - => <= => => v is the result of using operator o on v1 and v2 - - - [Assignment] - - => c'[i -> v] <= => - - Assign the value v to i in the first scope i is found in. - - [ENeg] - - => <-v,c'> <= => + ./CompInt [-c] [file] + -c : Compile [file], interprets if it isn't specified - [ENot] + if no arguments are specified then the file is interpreted - => <= => - - [EVar] - - => - - [EInt] - - => - - [EBool] - - => - - [EReadI,EReadB] - - => <= => - - [EPost] - - => v']> <= c(i) => v, v±1 => v' - - Look up the variable, add/subtract 1 from the value then return the old value and context with modified value - - [SExp] - - => c' <= => - - [SBlock] + Files: + Interpret.hs: Handles the interpretation of a program - => c''' <= push(c) => c' => c'' pop(c'') => c''' + Compile.hs: Compiles the program into a c program - Push a new scope onto the context, execute the statements in this context and the pop the scope from the context + Typechecker.hs: Simple modification of the bnfc-generated Testsyntax which calls the type-checking functions. - [SEQ] + Typecheck.hs: Contains the type-checking functions typeCheckExp, typeCheckVar and typeCheckStm and some utility functions, responsible for the entire type-checking process. - => c'' <= => c' => c'' + 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. - [SIf] - => pop(c''') <= => push(c') => c''' -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] - - => <= => => v is the result of using operator o on v1 and v2 - - -[Assignment] - - => c'[i -> v] <= => - -Assign the value v to i in the first scope i is found in. - -[ENeg] - - => <-v,c'> <= => - - -[ENot] - - => <= => - -[EVar] - - => - -[EInt] - - => ++Additions which comes from the extension: -[EBool] - - => - -[EReadI,EReadB] - - => <= => - -[EPost] - - => v']> <= c(i) => v, v±1 => v' - -Look up the variable, add/subtract 1 from the value then return the old value and context with modified value - -[SExp] - - => c' <= => - -[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] - - => pop(c''') <= => push(c') => c''' - -- => pop(c''') <= => push(c') => c''' ++typing rules ++++++++++++++ ++[EFunc] --[SWhile] ++(t is used for types, T is the context, and + is used for in) -- => c' => => ++T+ i (es) : t <= i(ts):t in T & T+ es:ts -- => pop(c''') => => push(c') => c'' => c''' ++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] --[SDecl] ++T+ return e <= e:t & ret(t) in T -- => c'[i->v] <= => ++return typechecks if e returns the same type as the current context --Adds i with value v to the current scope in the context ++[Func] --[SDeclD] ++T+ t i (ds) ss <= T,novariables,ret(t),ds => T' & T'+ss & last(ss) => return:t -- => c[i->0] -- => c[i->false] ++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 --Adds i with default value in the current scope ++semantic rules ++++++++++++++ --[SNoop] -- => c ++(v is used for values, e for expressions, s for statements, c is the context) --SNoops does nothing so the same context is returned --[SPrint] -- => c'' <= => => c''