aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2018-04-30 21:08:47 +0200
committerpacien2018-04-30 21:08:47 +0200
commita9c97df3133684f4f7ba0674b486ae77c20ab3c1 (patch)
tree33450c371ef15279e41df36088dfcd3a1dc8c483
parent651e72602de2bdaeda933934de7f2a9be01aff09 (diff)
downloadurm-a9c97df3133684f4f7ba0674b486ae77c20ab3c1.tar.gz
Use another strategy to quit the program
-rw-r--r--src/eurm.ml6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/eurm.ml b/src/eurm.ml
index 1e6d7d2..2b5def9 100644
--- a/src/eurm.ml
+++ b/src/eurm.ml
@@ -12,7 +12,7 @@ let compile_preprocess =
12 | None -> let new_id = string_of_int (Hashtbl.length label_table) 12 | None -> let new_id = string_of_int (Hashtbl.length label_table)
13 in Hashtbl.add label_table name new_id; new_id 13 in Hashtbl.add label_table name new_id; new_id
14 and aux = function 14 and aux = function
15 | [] -> [] 15 | [] -> [ Label("end") ]
16 | Comment(_) :: tail -> aux tail 16 | Comment(_) :: tail -> aux tail
17 | Label(name) :: tail -> Label(id_from_name name) :: aux tail 17 | Label(name) :: tail -> Label(id_from_name name) :: aux tail
18 | EqPredicate(i, j, name) :: tail -> EqPredicate(i, j, id_from_name name) :: aux tail 18 | EqPredicate(i, j, name) :: tail -> EqPredicate(i, j, id_from_name name) :: aux tail
@@ -109,6 +109,7 @@ let compile_stage2 eurmcmds state =
109 Label(error_label); Quit; Label(end_label); Copy(r1, diff_reg) ], 109 Label(error_label); Quit; Label(end_label); Copy(r1, diff_reg) ],
110 add_reg_label state 3 3 110 add_reg_label state 3 3
111 111
112 | Quit -> [ Goto("end") ], state
112 | any -> [ any ], state 113 | any -> [ any ], state
113 114
114 in apply_transform (transform) state eurmcmds 115 in apply_transform (transform) state eurmcmds
@@ -135,9 +136,6 @@ let compile_stage4 eurmcmds state =
135 | Label(_) -> 136 | Label(_) ->
136 let dummy_reg = state.max_reg + 1 137 let dummy_reg = state.max_reg + 1
137 in [ URMZero(dummy_reg) ], add_reg_label state 1 0 138 in [ URMZero(dummy_reg) ], add_reg_label state 1 0
138 | Quit ->
139 let dummy_reg = state.max_reg + 1
140 in [ URMZero(dummy_reg); URMJump(dummy_reg, dummy_reg, -1) ], add_reg_label state 1 0
141 | _ -> failwith "Invalid_argument" 139 | _ -> failwith "Invalid_argument"
142 in build_label_table eurmcmds; apply_transform (transform) state eurmcmds 140 in build_label_table eurmcmds; apply_transform (transform) state eurmcmds
143 141