Permalink
Browse files

Refactor alt2rules to alts_of_rhs

  • Loading branch information...
1 parent 49eeb01 commit b97ce9b5f98a170edd9e264fd4d90d86d2ce6dac @tjim tjim committed Jun 21, 2011
Showing with 17 additions and 17 deletions.
  1. +5 −5 src/analyze.ml
  2. +2 −2 src/fsm.ml
  3. +1 −1 src/gil.ml
  4. +2 −2 src/gil_gen.ml
  5. +1 −1 src/gul.ml
  6. +2 −2 src/lift.ml
  7. +3 −3 src/replay.ml
  8. +1 −1 src/wrap.ml
View
@@ -482,7 +482,7 @@ let prec_dependency_graph ptbl tokmap ds =
(fun g_result -> function
RuleDef(n,r, _)->
let g = Tgraph.add_node g_result n in
- let rs = alt2rules r in
+ let rs = alts_of_rhs r in
List.fold_left (fun g r_b ->
(* TODO: refine further so that a dependency is not drawn for calls when they are not to the left/right of relevant nonterminal.
@@ -506,7 +506,7 @@ let build_prec_sets gr =
| _ -> true in
let is_primary = function
| RuleDef (n, r, _) ->
- let rules = alt2rules r in
+ let rules = alts_of_rhs r in
if List.exists has_prec rules then Some n else None
| _ -> None in
let primary = List.fold_left (fun s x -> Stringset.add x s)
@@ -633,7 +633,7 @@ let prec_rewrite_complex gr =
if Stringset.mem n relevant then begin
a.Attr.input_attributes <- (prec_var, prec_type)::(pos_var, pos_type)::a.Attr.input_attributes;
- let rs = alt2rules r in
+ let rs = alts_of_rhs r in
List.iter (fun r_b ->
match get_prec ptbl tokmap r_b with
| None -> instantiate_attrs_copy r_b
@@ -752,7 +752,7 @@ let build_prec_sets_simple gr =
| _ -> true in
let is_primary = function
| RuleDef (n, r, _) ->
- let rules = alt2rules r in
+ let rules = alts_of_rhs r in
if List.exists has_prec rules then Some n else None
| _ -> None in
let primary = List.fold_left (fun s x -> Stringset.add x s)
@@ -839,7 +839,7 @@ let prec_rewrite_simple gr =
if Stringset.mem n primary then begin
(* a.Attr.output_attributes <- (prec_var, prec_type)::a.Attr.output_attributes; *)
a.Attr.early_rettype <- Some prec_type;
- let rs = alt2rules r in
+ let rs = alts_of_rhs r in
List.iter (fun r_b ->
match get_prec ptbl tokmap r_b with
| None
View
@@ -316,7 +316,7 @@ let rec thompson = function
(s2,f3)
| Alt _ as r ->
let (s,f) = fresh2() in
- let rules = alt2rules r in
+ let rules = alts_of_rhs r in
let n = List.length rules in
let w = INV_PROB n in
List.iter begin fun r0 ->
@@ -418,7 +418,7 @@ let rec merge = function
(s,f,e)
| Alt _ as r ->
let (s,f,e) = fresh3() in
- let rules = alt2rules(r) in
+ let rules = alts_of_rhs(r) in
let n = List.length(rules) in
let w = INV_PROB(n) in
for i = 0 to n-1 do (* inefficient *)
View
@@ -51,7 +51,7 @@ let charrange2alt low high =
loop (low + 1) (CharRange(low,low))
(** Convert binary Alt representation to list of alternatives *)
-let alt2rules r =
+let alts_of_rhs r =
let rec loop l = function
| Alt(r2,r3) -> loop (loop l r3) r2
| r -> r::l in
View
@@ -526,7 +526,7 @@ let pr_gil_lex f use_refs r0 first_map follow_map n tokmap =
else regular_alt ()
and handle_alts cur_fls r =
- let rs = Gil.alt2rules r in
+ let rs = Gil.alts_of_rhs r in
if not !Compileopt.lookahead then begin
bprintf f "(nalt [|";
List.iter (fun r_i ->
@@ -817,7 +817,7 @@ let pr_gil f liberal use_refs use_arrays r0 =
bprintf f "|])"
| Gil.Alt _ when use_arrays ->
bprintf f "(alt [|";
- let rs = Gil.alt2rules r in
+ let rs = Gil.alts_of_rhs r in
List.iter (fun r_i ->
bprintf f " ";
loop r_i;
View
@@ -308,7 +308,7 @@ module Curried_constructors = struct
end
(* Convert binary Alt representation to list of alternatives *)
-let alt2rules =
+let alts_of_rhs =
let rec loop l r = match r.r with
| Alt(r2,r3) -> loop (loop l r3) r2
| _ -> r::l in
View
@@ -169,14 +169,14 @@ let transform gr =
loop r2
| Opt _
| Alt _ ->
- let alt2rules = (* differs from bnf.ml b/c need to desugar Opt *)
+ let alts_of_rhs = (* differs from bnf.ml b/c need to desugar Opt *)
let rec loop l r = match r.r with
| Alt(r1,r2) -> loop (loop l r2) r1
| Opt(r1) ->
r.r <- (mkALT[r1;mkLIT ""]).r; loop l r
| _ -> r::l in
loop [] in
- let alts = alt2rules r in
+ let alts = alts_of_rhs r in
let lift_p = List.map (fun r -> loop r) alts in
let early_all_true = List.for_all (fun (x,_) -> x) lift_p in
let early_all_false = List.for_all (fun (x,_) -> not x) lift_p in
View
@@ -130,7 +130,7 @@ let replay gr hproj =
| Opt r1 ->
loop r1
| Alt _ ->
- let alts = alt2rules r in
+ let alts = alts_of_rhs r in
pr "(match _n() with";
List.iter
(fun r1 ->
@@ -223,7 +223,7 @@ let reverse gr hproj =
| Opt r1 ->
loop r1
| Alt _ ->
- let alts = alt2rules r in
+ let alts = alts_of_rhs r in
pr "(match _n() with";
List.iter
(fun r1 ->
@@ -336,7 +336,7 @@ let _replay_%s ykinput h =
| Opt r1 ->
loop r1
| Alt _ ->
- let alts = alt2rules r in
+ let alts = alts_of_rhs r in
List.iter
(fun r ->
let l = r.a.pre in
View
@@ -189,7 +189,7 @@ let wrap gr =
add_to_prologue gr (Buffer.contents b);
()
-let alt2rules = (* differs from bnf.ml b/c need to desugar Opt *) (*TODO: make default in Gul*)
+let alts_of_rhs = (* differs from bnf.ml b/c need to desugar Opt *) (*TODO: make default in Gul*)
let rec loop l r = match r.r with
| Alt(r1,r2) -> loop (loop l r2) r1
| Opt(r1) ->

0 comments on commit b97ce9b

Please sign in to comment.