Skip to content

Commit 04cd9f4

Browse files
authored
Merge pull request math-comp#113 from ejgallego/no_camlp4_compat
[camplX] Remove camlp4 support.
2 parents 286cf5c + 4623e7e commit 04cd9f4

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

mathcomp/ssreflect/plugin/trunk/ssreflect.ml4

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let () = Mltop.add_known_plugin (fun () ->
1616

1717
(* Defining grammar rules with "xx" in it automatically declares keywords too,
1818
* we thus save the lexer to restore it at the end of the file *)
19-
let frozen_lexer = CLexer.freeze () ;;
19+
let frozen_lexer = CLexer.get_keyword_state () ;;
2020

2121
(*i camlp4use: "pa_extend.cmo" i*)
2222
(*i camlp4deps: "grammar/grammar.cma" i*)
@@ -70,7 +70,6 @@ open Notation_ops
7070
open Locus
7171
open Locusops
7272

73-
open Compat
7473
open Tok
7574

7675
open Ssrmatching_plugin
@@ -514,18 +513,18 @@ let _ =
514513
(** Primitive parsing to avoid syntax conflicts with basic tactics. *)
515514

516515
let accept_before_syms syms strm =
517-
match Compat.get_tok (stream_nth 1 strm) with
516+
match stream_nth 1 strm with
518517
| Tok.KEYWORD sym when List.mem sym syms -> ()
519518
| _ -> raise Stream.Failure
520519

521520
let accept_before_syms_or_any_id syms strm =
522-
match Compat.get_tok (stream_nth 1 strm) with
521+
match stream_nth 1 strm with
523522
| Tok.KEYWORD sym when List.mem sym syms -> ()
524523
| Tok.IDENT _ -> ()
525524
| _ -> raise Stream.Failure
526525

527526
let accept_before_syms_or_ids syms ids strm =
528-
match Compat.get_tok (stream_nth 1 strm) with
527+
match stream_nth 1 strm with
529528
| Tok.KEYWORD sym when List.mem sym syms -> ()
530529
| Tok.IDENT id when List.mem id ids -> ()
531530
| _ -> raise Stream.Failure
@@ -660,7 +659,7 @@ let ssr_id_of_string loc s =
660659

661660
let ssr_null_entry = Gram.Entry.of_parser "ssr_null" (fun _ -> ())
662661

663-
let (!@) = Compat.to_coqloc
662+
let (!@) = Pcoq.to_coqloc
664663

665664
GEXTEND Gram
666665
GLOBAL: Prim.ident;
@@ -1853,7 +1852,7 @@ END
18531852

18541853
type ssrtermkind = char (* print flag *)
18551854

1856-
let input_ssrtermkind strm = match Compat.get_tok (stream_nth 0 strm) with
1855+
let input_ssrtermkind strm = match stream_nth 0 strm with
18571856
| Tok.KEYWORD "(" -> '('
18581857
| Tok.KEYWORD "@" -> '@'
18591858
| _ -> ' '
@@ -2664,9 +2663,9 @@ ARGUMENT EXTEND ssriorpat TYPED AS ssripat list PRINTED BY pr_ssriorpat
26642663
END
26652664

26662665
let reject_ssrhid strm =
2667-
match Compat.get_tok (stream_nth 0 strm) with
2666+
match stream_nth 0 strm with
26682667
| Tok.KEYWORD "[" ->
2669-
(match Compat.get_tok (stream_nth 1 strm) with
2668+
(match stream_nth 1 strm with
26702669
| Tok.KEYWORD ":" -> raise Stream.Failure
26712670
| _ -> ())
26722671
| _ -> ()
@@ -2786,7 +2785,7 @@ let equality_inj l b id c gl =
27862785
let msg = ref "" in
27872786
try Proofview.V82.of_tactic (Equality.inj l b None c) gl
27882787
with
2789-
| Compat.Exc_located(_,CErrors.UserError (_,s))
2788+
| Ploc.Exc(_,CErrors.UserError (_,s))
27902789
| CErrors.UserError (_,s)
27912790
when msg := Pp.string_of_ppcmds s;
27922791
!msg = "Not a projectable equality but a discriminable one." ||
@@ -3091,8 +3090,8 @@ let tclDO n tac =
30913090
let _, info = CErrors.push e in
30923091
let e' = CErrors.UserError (l, prefix i ++ s) in
30933092
Util.iraise (e', info)
3094-
| Compat.Exc_located(loc, CErrors.UserError (l, s)) ->
3095-
raise (Compat.Exc_located(loc, CErrors.UserError (l, prefix i ++ s))) in
3093+
| Ploc.Exc(loc, CErrors.UserError (l, s)) ->
3094+
raise (Ploc.Exc(loc, CErrors.UserError (l, prefix i ++ s))) in
30963095
let rec loop i gl =
30973096
if i = n then tac_err_at i gl else
30983097
(tclTHEN (tac_err_at i) (loop (i + 1))) gl in
@@ -3177,7 +3176,7 @@ let sq_brace_tacnames =
31773176
["first"; "solve"; "do"; "rewrite"; "have"; "suffices"; "wlog"]
31783177
(* "by" is a keyword *)
31793178
let accept_ssrseqvar strm =
3180-
match Compat.get_tok (stream_nth 0 strm) with
3179+
match stream_nth 0 strm with
31813180
| Tok.IDENT id when not (List.mem id sq_brace_tacnames) ->
31823181
accept_before_syms_or_ids ["["] ["first";"last"] strm
31833182
| _ -> raise Stream.Failure
@@ -3611,7 +3610,7 @@ ARGUMENT EXTEND ssreqid TYPED AS ssripatrep option PRINTED BY pr_ssreqid
36113610
END
36123611

36133612
let accept_ssreqid strm =
3614-
match Compat.get_tok (Util.stream_nth 0 strm) with
3613+
match Util.stream_nth 0 strm with
36153614
| Tok.IDENT _ -> accept_before_syms [":"] strm
36163615
| Tok.KEYWORD ":" -> ()
36173616
| Tok.KEYWORD pat when List.mem pat ["_"; "?"; "->"; "<-"] ->
@@ -5183,7 +5182,7 @@ let test_ssr_rw_syntax =
51835182
let test strm =
51845183
if not !ssr_rw_syntax then raise Stream.Failure else
51855184
if is_ssr_loaded () then () else
5186-
match Compat.get_tok (Util.stream_nth 0 strm) with
5185+
match Util.stream_nth 0 strm with
51875186
| Tok.KEYWORD key when List.mem key.[0] ['{'; '['; '/'] -> ()
51885187
| _ -> raise Stream.Failure in
51895188
Gram.Entry.of_parser "test_ssr_rw_syntax" test
@@ -5259,7 +5258,7 @@ ARGUMENT EXTEND ssrfwdid TYPED AS ident PRINTED BY pr_ssrfwdid
52595258
END
52605259

52615260
let accept_ssrfwdid strm =
5262-
match Compat.get_tok (stream_nth 0 strm) with
5261+
match stream_nth 0 strm with
52635262
| Tok.IDENT id -> accept_before_syms_or_any_id [":"; ":="; "("] strm
52645263
| _ -> raise Stream.Failure
52655264

@@ -6151,7 +6150,7 @@ ARGUMENT EXTEND ssr_idcomma TYPED AS ident option option PRINTED BY pr_idcomma
61516150
END
61526151

61536152
let accept_idcomma strm =
6154-
match Compat.get_tok (stream_nth 0 strm) with
6153+
match stream_nth 0 strm with
61556154
| Tok.IDENT _ | Tok.KEYWORD "_" -> accept_before_syms [","] strm
61566155
| _ -> raise Stream.Failure
61576156

@@ -6244,6 +6243,6 @@ END
62446243
(* The user is supposed to Require Import ssreflect or Require ssreflect *)
62456244
(* and Import ssreflect.SsrSyntax to obtain these keywords and as a *)
62466245
(* consequence the extended ssreflect grammar. *)
6247-
let () = CLexer.unfreeze frozen_lexer ;;
6246+
let () = CLexer.set_keyword_state frozen_lexer ;;
62486247

62496248
(* vim: set filetype=ocaml foldmethod=marker: *)

0 commit comments

Comments
 (0)