Skip to content

Ppx: allow apostrophe in lident (fix #1183) #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ppx/ppx_deriving_json/lib/ppx_deriving_json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ let parse_lid s =
match i, c with
| 0, ('a' .. 'z' | '_') -> ()
| 0, _ -> assert false
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9') -> ()
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '\'' | '0' .. '9') -> ()
| _ -> assert false)
in
let assert_uid =
String.iteri ~f:(fun i c ->
match i, c with
| 0, 'A' .. 'Z' -> ()
| 0, _ -> assert false
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9') -> ()
| _, ('a' .. 'z' | 'A' .. 'Z' | '_' | '\'' | '0' .. '9') -> ()
| _ -> assert false)
in
let rec check = function
Expand Down
24 changes: 24 additions & 0 deletions ppx/ppx_deriving_json/tests/gen.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -695,3 +695,27 @@ let t s =
(Deriving_Json_lexer.init_lexer (Lexing.from_string s));;
val t : string -> t * t = <fun>
|}]

;;
type id' = int [@@deriving json]
[%%expect {|

type id' = int[@@deriving json]
include
struct
let _ = fun (_ : id') -> ()
let rec (id'_of_json : Deriving_Json_lexer.lexbuf -> id') =
fun buf -> Deriving_Json.Json_int.read buf
let _ = id'_of_json
let rec (id'_to_json : Buffer.t -> id' -> unit) =
fun buf -> fun a -> Deriving_Json.Json_int.write buf a
let _ = id'_to_json
let (id'_json : id' Deriving_Json.t) =
Deriving_Json.make id'_to_json id'_of_json
let _ = id'_json
end[@@ocaml.doc "@inline"][@@merlin.hide ];;
type id' = int
val id'_of_json : Deriving_Json_lexer.lexbuf -> id' = <fun>
val id'_to_json : Buffer.t -> id' -> unit = <fun>
val id'_json : id' Deriving_Json.t = <abstr>
|}]