From 281aca58971995261e713db03a39676639d700cd Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 29 Apr 2018 23:48:06 +0200 Subject: Implement compile_preprocess --- src/eurm.ml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/eurm.ml b/src/eurm.ml index 7d6c2c6..6985f06 100644 --- a/src/eurm.ml +++ b/src/eurm.ml @@ -5,7 +5,26 @@ open Common -let compile_preprocess eurmcmds = eurmcmds +let compile_preprocess = + let rec label_table = Hashtbl.create 100 + and id_from_name name = match Hashtbl.find_opt label_table name with + | Some(id) -> id + | None -> let new_id = string_of_int (Hashtbl.length label_table) + in Hashtbl.add label_table name new_id; new_id + and aux = function + | [] -> [] + | Comment(_) :: tail -> aux tail + | Label(name) :: tail -> Label(id_from_name name) :: aux tail + | EqPredicate(i, j, name) :: tail -> EqPredicate(i, j, id_from_name name) :: aux tail + | GEqPredicate(i, j, name) :: tail -> GEqPredicate(i, j, id_from_name name) :: aux tail + | GTPredicate(i, j, name) :: tail -> GTPredicate(i, j, id_from_name name) :: aux tail + | LEqPredicate(i, j, name) :: tail -> LEqPredicate(i, j, id_from_name name) :: aux tail + | LTPredicate(i, j, name) :: tail -> LTPredicate(i, j, id_from_name name) :: aux tail + | ZeroPredicate(i, name) :: tail -> ZeroPredicate(i, id_from_name name) :: aux tail + | Goto(name) :: tail -> Goto(id_from_name name) :: aux tail + | any :: tail -> any :: aux tail + in aux + let compile_stage1 eurmcmds state = eurmcmds, state let compile_stage2 eurmcmds state = eurmcmds, state let compile_stage3 eurmcmds state = eurmcmds, state -- cgit v1.2.3