equal
deleted
inserted
replaced
1 (* ID: $Id$ |
1 (* ID: $Id$ |
2 Author: Florian Haftmann, TU Muenchen |
2 Author: Florian Haftmann, TU Muenchen |
3 *) |
3 *) |
4 |
4 |
5 header {* Test and Examples for Code Generator *} |
5 header {* Test and Examples for code generator *} |
6 |
6 |
7 theory Codegenerator |
7 theory Codegenerator |
8 imports Main |
8 imports Main |
9 begin |
9 begin |
10 |
10 |
44 appl :: "('a \<Rightarrow> 'b) * 'a \<Rightarrow> 'b" |
44 appl :: "('a \<Rightarrow> 'b) * 'a \<Rightarrow> 'b" |
45 "appl p = (let (f, x) = p in f x)" |
45 "appl p = (let (f, x) = p in f x)" |
46 |
46 |
47 code_generate (ml, haskell) Pair fst snd Let split swap swapp appl |
47 code_generate (ml, haskell) Pair fst snd Let split swap swapp appl |
48 |
48 |
|
49 subsection {* integers *} |
|
50 |
49 definition |
51 definition |
50 k :: "int" |
52 k :: "int" |
51 "k = 42" |
53 "k = 42" |
52 |
54 |
53 consts |
55 consts |
62 "op - :: int \<Rightarrow> int \<Rightarrow> int" |
64 "op - :: int \<Rightarrow> int \<Rightarrow> int" |
63 "op * :: int \<Rightarrow> int \<Rightarrow> int" |
65 "op * :: int \<Rightarrow> int \<Rightarrow> int" |
64 "op < :: int \<Rightarrow> int \<Rightarrow> bool" |
66 "op < :: int \<Rightarrow> int \<Rightarrow> bool" |
65 "op <= :: int \<Rightarrow> int \<Rightarrow> bool" |
67 "op <= :: int \<Rightarrow> int \<Rightarrow> bool" |
66 fac |
68 fac |
|
69 "op div :: int \<Rightarrow> int \<Rightarrow> int" |
|
70 "op mod :: int \<Rightarrow> int \<Rightarrow> int" |
67 |
71 |
68 subsection {* sums *} |
72 subsection {* sums *} |
69 |
73 |
70 code_generate (ml, haskell) Inl Inr |
74 code_generate (ml, haskell) Inl Inr |
71 |
75 |