diff options
author | pacien | 2018-04-29 23:48:06 +0200 |
---|---|---|
committer | pacien | 2018-04-29 23:48:06 +0200 |
commit | 281aca58971995261e713db03a39676639d700cd (patch) | |
tree | 04b244f680a0cab058df235f9aff19f95a78c1fb | |
parent | 97a5d3600a06e2edbd6bb6faa6fa0728add0d5d3 (diff) | |
download | urm-281aca58971995261e713db03a39676639d700cd.tar.gz |
Implement compile_preprocess
-rw-r--r-- | src/eurm.ml | 21 |
1 files changed, 20 insertions, 1 deletions
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 @@ | |||
5 | 5 | ||
6 | open Common | 6 | open Common |
7 | 7 | ||
8 | let compile_preprocess eurmcmds = eurmcmds | 8 | let compile_preprocess = |
9 | let rec label_table = Hashtbl.create 100 | ||
10 | and id_from_name name = match Hashtbl.find_opt label_table name with | ||
11 | | Some(id) -> id | ||
12 | | None -> let new_id = string_of_int (Hashtbl.length label_table) | ||
13 | in Hashtbl.add label_table name new_id; new_id | ||
14 | and aux = function | ||
15 | | [] -> [] | ||
16 | | Comment(_) :: tail -> 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 | ||
19 | | GEqPredicate(i, j, name) :: tail -> GEqPredicate(i, j, id_from_name name) :: aux tail | ||
20 | | GTPredicate(i, j, name) :: tail -> GTPredicate(i, j, id_from_name name) :: aux tail | ||
21 | | LEqPredicate(i, j, name) :: tail -> LEqPredicate(i, j, id_from_name name) :: aux tail | ||
22 | | LTPredicate(i, j, name) :: tail -> LTPredicate(i, j, id_from_name name) :: aux tail | ||
23 | | ZeroPredicate(i, name) :: tail -> ZeroPredicate(i, id_from_name name) :: aux tail | ||
24 | | Goto(name) :: tail -> Goto(id_from_name name) :: aux tail | ||
25 | | any :: tail -> any :: aux tail | ||
26 | in aux | ||
27 | |||
9 | let compile_stage1 eurmcmds state = eurmcmds, state | 28 | let compile_stage1 eurmcmds state = eurmcmds, state |
10 | let compile_stage2 eurmcmds state = eurmcmds, state | 29 | let compile_stage2 eurmcmds state = eurmcmds, state |
11 | let compile_stage3 eurmcmds state = eurmcmds, state | 30 | let compile_stage3 eurmcmds state = eurmcmds, state |