윤용호
가입: 2008년 9월 23일 올린 글: 257
|
올려짐: 2011년3월25일 16:50 주제: 숙제2 Exercise 7의 뼈대입니다 |
|
|
뼈대의 functor인 TRANS에서 semantics 함수를 구현하시면 됩니다.
코드: |
module type KMINUS =
sig
exception Error of string
type id = string
type exp =
| NUM of int
| VAR of id
| ADD of exp * exp
| MINUS of exp
type cmd =
| SKIP
| SEQ of cmd * cmd (* sequence *)
| IF of exp * cmd * cmd (* if-then-else *)
| ASSIGN of id * exp (* assign to variable *)
| WHILE of exp * cmd (* while loop *)
type program = cmd
type memory
type value
val emptyMemory : memory
val run : memory * program -> value
end
module type SEM =
sig
type id = string
type exp =
| VAR of id
| NUM of int
| LAM of id * exp (* continuous function *)
| APP of exp * exp (* function application *)
| IF of exp * exp * exp (* if-then-else operator *)
| FIX of exp (* fix operator *)
| NOTEQZ of exp (* not-equal-zero operator *)
| ADD of exp * exp (* binary + operator *)
| MINUS of exp (* unary - operator *)
| UPDATE of exp * id * exp (* function update operator *)
end
module TRANS (K:KMINUS) (S:SEM) =
struct
exception Error of string
let semantics : K.cmd -> S.exp = fun c ->
raise (Error "TODO : implement this function 'semantics'")
end
|
|
|