aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2019-06-06 16:57:39 +0200
committerVincent Laporte2019-07-29 14:18:01 +0000
commitbc9b33cfa70fd52fd9391e238cf30f3b3fe8a454 (patch)
treea8a56ed11c1fdd499060bd96337954145f49c4b7
parent55400b02a70c540d6c6e8152affe1eae99760b91 (diff)
Fix #10088: Incompatibility with ssreflect's ampersand syntactic sugar.
-rw-r--r--user-contrib/Ltac2/g_ltac2.mlg28
1 files changed, 17 insertions, 11 deletions
diff --git a/user-contrib/Ltac2/g_ltac2.mlg b/user-contrib/Ltac2/g_ltac2.mlg
index e0e660b984..8e5aae4900 100644
--- a/user-contrib/Ltac2/g_ltac2.mlg
+++ b/user-contrib/Ltac2/g_ltac2.mlg
@@ -23,31 +23,31 @@ open Ltac_plugin
let err () = raise Stream.Failure
-type lookahead = int -> Tok.t Stream.t -> int option
+type lookahead = Gramlib.Plexing.location_function -> int -> Tok.t Stream.t -> int option
let entry_of_lookahead s (lk : lookahead) =
- let run _ strm = match lk 0 strm with None -> err () | Some _ -> () in
+ let run tok strm = match lk tok 0 strm with None -> err () | Some _ -> () in
Pcoq.Entry.of_parser s run
-let (>>) (lk1 : lookahead) lk2 n strm = match lk1 n strm with
+let (>>) (lk1 : lookahead) lk2 tok n strm = match lk1 tok n strm with
| None -> None
-| Some n -> lk2 n strm
+| Some n -> lk2 tok n strm
-let (<+>) (lk1 : lookahead) lk2 n strm = match lk1 n strm with
-| None -> lk2 n strm
+let (<+>) (lk1 : lookahead) lk2 tok n strm = match lk1 tok n strm with
+| None -> lk2 tok n strm
| Some n -> Some n
-let lk_empty n strm = Some n
+let lk_empty tok n strm = Some n
-let lk_kw kw n strm = match stream_nth n strm with
+let lk_kw kw tok n strm = match stream_nth n strm with
| KEYWORD kw' | IDENT kw' -> if String.equal kw kw' then Some (n + 1) else None
| _ -> None
-let lk_ident n strm = match stream_nth n strm with
+let lk_ident tok n strm = match stream_nth n strm with
| IDENT _ -> Some (n + 1)
| _ -> None
-let lk_int n strm = match stream_nth n strm with
+let lk_int tok n strm = match stream_nth n strm with
| NUMERAL { NumTok.int = _; frac = ""; exp = "" } -> Some (n + 1)
| _ -> None
@@ -80,9 +80,15 @@ let test_lpar_id_rpar =
lk_kw "(" >> lk_ident >> lk_kw ")"
end
+let check_no_space tok m strm =
+ let n = Stream.count strm in
+ let (_, ep) = Loc.unloc (tok n) in
+ let (bp, _) = Loc.unloc (tok (n + 1)) in
+ if Int.equal ep bp then Some m else None
+
let test_ampersand_ident =
entry_of_lookahead "test_ampersand_ident" begin
- lk_kw "&" >> lk_ident
+ lk_kw "&" >> lk_ident >> check_no_space
end
let test_dollar_ident =