윤용호
가입: 2008년 9월 23일 올린 글: 257
|
올려짐: 2014년3월17일 11:35 주제: 숙제1이 나왔습니다. |
|
|
강의 페이지에서 확인하실 수 있습니다.
http://ropas.snu.ac.kr/~kwang/4541.664A/14/hw1.pdf
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 *)
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
|
_________________ TA |
|