Commit 55b651b1 authored by POTTIER Francois's avatar POTTIER Francois

Cleanup. Replaced [shift_precedence] with [prec_annotation] everywhere.

parent 9edfa5e2
...@@ -222,7 +222,7 @@ production_group: ...@@ -222,7 +222,7 @@ production_group:
{ {
pr_producers; pr_producers;
pr_action; pr_action;
pr_branch_shift_precedence = ParserAux.override pos oprec1 oprec2; pr_branch_prec_annotation = ParserAux.override pos oprec1 oprec2;
pr_branch_reduce_precedence = rprec; pr_branch_reduce_precedence = rprec;
pr_branch_position = pos pr_branch_position = pos
}) })
......
...@@ -560,15 +560,12 @@ module Production = struct ...@@ -560,15 +560,12 @@ module Production = struct
let (_ : int) = StringMap.fold (fun nonterminal { branches = branches } k -> let (_ : int) = StringMap.fold (fun nonterminal { branches = branches } k ->
let nt = Nonterminal.lookup nonterminal in let nt = Nonterminal.lookup nonterminal in
let k' = List.fold_left (fun k branch -> let k' = List.fold_left (fun k branch ->
let action = branch.action
and sprec = branch.branch_shift_precedence
and rprec = branch.branch_reduce_precedence in
let symbols = Array.of_list branch.producers in let symbols = Array.of_list branch.producers in
table.(k) <- (nt, Array.map (fun (v, _) -> Symbol.lookup v) symbols); table.(k) <- (nt, Array.map (fun (v, _) -> Symbol.lookup v) symbols);
identifiers.(k) <- Array.map snd symbols; identifiers.(k) <- Array.map snd symbols;
actions.(k) <- Some action; actions.(k) <- Some branch.action;
reduce_precedence.(k) <- rprec; reduce_precedence.(k) <- branch.branch_reduce_precedence;
prec_decl.(k) <- sprec; prec_decl.(k) <- branch.branch_prec_annotation;
positions.(k) <- [ branch.branch_position ]; positions.(k) <- [ branch.branch_position ];
k+1 k+1
) k branches in ) k branches in
...@@ -740,7 +737,7 @@ module Production = struct ...@@ -740,7 +737,7 @@ module Production = struct
let combine e1 e2 = let combine e1 e2 =
lazy (Lazy.force e1; Lazy.force e2) lazy (Lazy.force e1; Lazy.force e2)
let shift_precedence prod = let precedence prod =
let fact1, prec_decl = consult_prec_decl prod in let fact1, prec_decl = consult_prec_decl prod in
let oterminal = let oterminal =
match prec_decl with match prec_decl with
...@@ -1461,7 +1458,7 @@ module Precedence = struct ...@@ -1461,7 +1458,7 @@ module Precedence = struct
let shift_reduce tok prod = let shift_reduce tok prod =
let fact1, tokp = Terminal.precedence_level tok let fact1, tokp = Terminal.precedence_level tok
and fact2, prodp = Production.shift_precedence prod in and fact2, prodp = Production.precedence prod in
match precedence_order tokp prodp with match precedence_order tokp prodp with
(* Our information is inconclusive. Drop [fact1] and [fact2], (* Our information is inconclusive. Drop [fact1] and [fact2],
......
...@@ -557,7 +557,7 @@ let expand p_grammar = ...@@ -557,7 +557,7 @@ let expand p_grammar =
branch_position = pbranch.pr_branch_position; branch_position = pbranch.pr_branch_position;
producers = new_producers; producers = new_producers;
action = pbranch.pr_action; action = pbranch.pr_action;
branch_shift_precedence = pbranch.pr_branch_shift_precedence; branch_prec_annotation = pbranch.pr_branch_prec_annotation;
branch_reduce_precedence = pbranch.pr_branch_reduce_precedence; branch_reduce_precedence = pbranch.pr_branch_reduce_precedence;
} }
......
...@@ -650,9 +650,9 @@ let check_parameterized_grammar_is_well_defined grammar = ...@@ -650,9 +650,9 @@ let check_parameterized_grammar_is_well_defined grammar =
(* Check each branch. *) (* Check each branch. *)
(fun { pr_producers = producers; (fun { pr_producers = producers;
pr_branch_shift_precedence = sprec; pr_branch_prec_annotation;
pr_action = action pr_action = action
} -> ignore (List.fold_left } -> ignore (List.fold_left
(* Check the producers. *) (* Check the producers. *)
(fun already_seen (id, p) -> (fun already_seen (id, p) ->
...@@ -686,7 +686,7 @@ let check_parameterized_grammar_is_well_defined grammar = ...@@ -686,7 +686,7 @@ let check_parameterized_grammar_is_well_defined grammar =
check_keywords producers action; check_keywords producers action;
match sprec with match pr_branch_prec_annotation with
| None -> () | None -> ()
......
...@@ -85,7 +85,10 @@ type declaration = ...@@ -85,7 +85,10 @@ type declaration =
| DType of Stretch.ocamltype * parameter | DType of Stretch.ocamltype * parameter
type branch_shift_precedence = (* A [%prec] annotation is optional. A production can carry at most one.
If there is one, it is a symbol name. *)
type branch_prec_annotation =
symbol Positions.located option symbol Positions.located option
type branch_reduce_precedence = type branch_reduce_precedence =
...@@ -99,7 +102,7 @@ type parameterized_branch = ...@@ -99,7 +102,7 @@ type parameterized_branch =
pr_branch_position : Positions.t; pr_branch_position : Positions.t;
pr_producers : producer list; pr_producers : producer list;
pr_action : action; pr_action : action;
pr_branch_shift_precedence : branch_shift_precedence; pr_branch_prec_annotation : branch_prec_annotation;
pr_branch_reduce_precedence : branch_reduce_precedence pr_branch_reduce_precedence : branch_reduce_precedence
} }
......
...@@ -131,7 +131,7 @@ let string_of_producer mode (symbol, ido) = ...@@ -131,7 +131,7 @@ let string_of_producer mode (symbol, ido) =
let print_branch mode f branch = let print_branch mode f branch =
Printf.fprintf f "%s%s\n {" Printf.fprintf f "%s%s\n {"
(String.concat " " (List.map (string_of_producer mode) branch.producers)) (String.concat " " (List.map (string_of_producer mode) branch.producers))
(Misc.o2s branch.branch_shift_precedence (fun x -> " %prec "^x.value)); (Misc.o2s branch.branch_prec_annotation (fun x -> " %prec "^x.value));
begin match mode with begin match mode with
| PrintNormal -> | PrintNormal ->
Action.print f branch.action Action.print f branch.action
......
...@@ -21,7 +21,7 @@ type branch = ...@@ -21,7 +21,7 @@ type branch =
producers : (symbol * identifier) list; (* TEMPORARY convention renversée producers : (symbol * identifier) list; (* TEMPORARY convention renversée
par rapport à syntax.mli; faire un type record au lieu d'une paire? *) par rapport à syntax.mli; faire un type record au lieu d'une paire? *)
action : action; action : action;
branch_shift_precedence : branch_shift_precedence; branch_prec_annotation : branch_prec_annotation;
branch_reduce_precedence : branch_reduce_precedence branch_reduce_precedence : branch_reduce_precedence
} }
......
...@@ -276,7 +276,7 @@ production_group: ...@@ -276,7 +276,7 @@ production_group:
{ {
pr_producers; pr_producers;
pr_action; pr_action;
pr_branch_shift_precedence = ParserAux.override pos oprec1 oprec2; pr_branch_prec_annotation = ParserAux.override pos oprec1 oprec2;
pr_branch_reduce_precedence = rprec; pr_branch_reduce_precedence = rprec;
pr_branch_position = pos pr_branch_position = pos
}) })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment