aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2017-08-25 17:16:01 +0200
committerPierre-Marie Pédrot2017-08-25 17:51:16 +0200
commit6875b016b0a502b03296e5f97f26cf0f6699a7aa (patch)
tree2802ed43b0a74af079acd05fd694a38938f94317 /src
parent47eb0278a3cdf93129b1742e314681d65bd6475a (diff)
Do not return STRING scopes in the tuple produced by "seq" scopes.
Diffstat (limited to 'src')
-rw-r--r--src/tac2core.ml13
-rw-r--r--src/tac2quote.ml7
-rw-r--r--src/tac2quote.mli2
3 files changed, 16 insertions, 6 deletions
diff --git a/src/tac2core.ml b/src/tac2core.ml
index 8d0f640209..7a8f3ceb44 100644
--- a/src/tac2core.ml
+++ b/src/tac2core.ml
@@ -963,13 +963,12 @@ let rec generalize_symbol :
type _ converter =
| CvNil : (Loc.t -> raw_tacexpr) converter
-| CvCns : 'act converter * ('a -> raw_tacexpr) -> ('a -> 'act) converter
+| CvCns : 'act converter * ('a -> raw_tacexpr) option -> ('a -> 'act) converter
let rec apply : type a. a converter -> raw_tacexpr list -> a = function
-| CvNil -> fun accu loc ->
- let cst = CTacCst (loc, AbsKn (Tuple (List.length accu))) in
- CTacApp (loc, cst, accu)
-| CvCns (c, f) -> fun accu x -> apply c (f x :: accu)
+| CvNil -> fun accu loc -> Tac2quote.of_tuple ~loc accu
+| CvCns (c, None) -> fun accu x -> apply c accu
+| CvCns (c, Some f) -> fun accu x -> apply c (f x :: accu)
type seqrule =
| Seqrule : ('act, Loc.t -> raw_tacexpr) norec_rule * 'act converter -> seqrule
@@ -983,6 +982,10 @@ let rec make_seq_rule = function
let scope = generalize_symbol scope in
let Seqrule (r, c) = make_seq_rule rem in
let r = { norec_rule = Next (r.norec_rule, scope.any_symbol) } in
+ let f = match tok with
+ | SexprStr _ -> None (** Leave out mere strings *)
+ | _ -> Some f
+ in
Seqrule (r, CvCns (c, f))
let () = add_scope "seq" begin fun toks ->
diff --git a/src/tac2quote.ml b/src/tac2quote.ml
index 9778bd18ae..dbd2fd0529 100644
--- a/src/tac2quote.ml
+++ b/src/tac2quote.ml
@@ -46,7 +46,12 @@ let of_pair f g (loc, (e1, e2)) =
let loc = Option.default dummy_loc loc in
CTacApp (loc, CTacCst (loc, AbsKn (Tuple 2)), [f e1; g e2])
-let of_tuple ?loc el =
+let of_tuple ?loc el = match el with
+| [] ->
+ let loc = Option.default dummy_loc loc in
+ CTacCst (loc, AbsKn (Tuple 0))
+| [e] -> e
+| el ->
let loc = Option.default dummy_loc loc in
let len = List.length el in
CTacApp (loc, CTacCst (loc, AbsKn (Tuple len)), el)
diff --git a/src/tac2quote.mli b/src/tac2quote.mli
index bd2303ac98..7f3d9dce6e 100644
--- a/src/tac2quote.mli
+++ b/src/tac2quote.mli
@@ -24,6 +24,8 @@ val of_int : int located -> raw_tacexpr
val of_pair : ('a -> raw_tacexpr) -> ('b -> raw_tacexpr) -> ('a * 'b) located -> raw_tacexpr
+val of_tuple : ?loc:Loc.t -> raw_tacexpr list -> raw_tacexpr
+
val of_variable : Id.t located -> raw_tacexpr
val of_ident : Id.t located -> raw_tacexpr