69 |
fun markExp (_, e as PT.E_Mark _) = e |
fun markExp (_, e as PT.E_Mark _) = e |
70 |
| markExp (sp, tr) = mark PT.E_Mark (sp, tr) |
| markExp (sp, tr) = mark PT.E_Mark (sp, tr) |
71 |
|
|
72 |
|
(* build an application for an infix binary operator *) |
73 |
|
fun mkBinApp (e1, rator, e2) = PT.E_BinOp(e1, rator, e2) |
74 |
|
|
75 |
|
(* construct application expressions for left-associative binary operators *) |
76 |
|
fun mkLBinExp (e, []) = e |
77 |
|
| mkLBinExp (e, (id, e')::r) = mkLBinExp (mkBinApp(e, id, e'), r) |
78 |
|
|
79 |
|
(* construct application expressions for right-associative binary operators *) |
80 |
|
fun mkRBinExp (e, []) = e |
81 |
|
| mkRBinExp (e, [(id, e')]) = mkBinApp(e, id, e') |
82 |
|
| mkRBinExp (e, (id, e')::r) = mkBinApp(e, id, mkRBinExp(e', r)) |
83 |
|
|
84 |
fun flatten NONE = [] |
fun flatten NONE = [] |
85 |
| flatten (SOME l) = l |
| flatten (SOME l) = l |
86 |
); |
); |