X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=documentation;fp=documentation;h=f46afb702549b5b0a7a530b699a49ea20fb2c5d1;hp=c3ac4e08ba815c574432d3e2f0905cf120a460e1;hb=bb79f91257da50013a4175c7c57973a6570eb3a1;hpb=cdcd3b92ee3145e646634d428b02118238d47f33 diff --git a/documentation b/documentation index c3ac4e0..f46afb7 100644 --- a/documentation +++ b/documentation @@ -1,110 +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''' +Additions which comes from the extension: - => 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''