Skip to content

Commit e22aee8

Browse files
committed
Ppx: allow apostrophe in lident (fix #1183)
1 parent c980123 commit e22aee8

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

ppx/ppx_deriving_json/lib/ppx_deriving_json.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ let parse_lid s =
4848
match i, c with
4949
| 0, ('a' .. 'z' | '_') -> ()
5050
| 0, _ -> assert false
51-
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9') -> ()
51+
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '\'' | '0' .. '9') -> ()
5252
| _ -> assert false)
5353
in
5454
let assert_uid =
5555
String.iteri ~f:(fun i c ->
5656
match i, c with
5757
| 0, 'A' .. 'Z' -> ()
5858
| 0, _ -> assert false
59-
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9') -> ()
59+
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '\'' | '0' .. '9') -> ()
6060
| _ -> assert false)
6161
in
6262
let rec check = function

ppx/ppx_deriving_json/tests/gen.mlt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,3 +695,27 @@ let t s =
695695
(Deriving_Json_lexer.init_lexer (Lexing.from_string s));;
696696
val t : string -> t * t = <fun>
697697
|}]
698+
699+
;;
700+
type id' = int [@@deriving json]
701+
[%%expect {|
702+
703+
type id' = int[@@deriving json]
704+
include
705+
struct
706+
let _ = fun (_ : id') -> ()
707+
let rec (id'_of_json : Deriving_Json_lexer.lexbuf -> id') =
708+
fun buf -> Deriving_Json.Json_int.read buf
709+
let _ = id'_of_json
710+
let rec (id'_to_json : Buffer.t -> id' -> unit) =
711+
fun buf -> fun a -> Deriving_Json.Json_int.write buf a
712+
let _ = id'_to_json
713+
let (id'_json : id' Deriving_Json.t) =
714+
Deriving_Json.make id'_to_json id'_of_json
715+
let _ = id'_json
716+
end[@@ocaml.doc "@inline"][@@merlin.hide ];;
717+
type id' = int
718+
val id'_of_json : Deriving_Json_lexer.lexbuf -> id' = <fun>
719+
val id'_to_json : Buffer.t -> id' -> unit = <fun>
720+
val id'_json : id' Deriving_Json.t = <abstr>
721+
|}]

0 commit comments

Comments
 (0)