[erl-frontend] Parse typed record fields

Summary: Previously the JSON parser only accepted record fields if they appeared directly under the record. With this change it is possible to have record fields wrapped into typed record fields.

Reviewed By: mmarescotti

Differential Revision: D30132727

fbshipit-source-id: eb9e928b2
master
Akos Hajdu 3 years ago committed by Facebook GitHub Bot
parent e41babb7fd
commit 01d670299f

@ -479,12 +479,14 @@ let to_function json : Ast.function_ option =
unknown "function" json unknown "function" json
let to_record_field json : Ast.record_field option = let rec to_record_field json : Ast.record_field option =
match json with match json with
| `List [`String "record_field"; _; `List [`String "atom"; _; `String field_name]; expr] -> | `List [`String "record_field"; _; `List [`String "atom"; _; `String field_name]; expr] ->
Some {Ast.field_name; initializer_= to_expression expr} Some {Ast.field_name; initializer_= to_expression expr}
| `List [`String "record_field"; _; `List [`String "atom"; _; `String field_name]] -> | `List [`String "record_field"; _; `List [`String "atom"; _; `String field_name]] ->
Some {Ast.field_name; initializer_= None} Some {Ast.field_name; initializer_= None}
| `List [`String "typed_record_field"; inner_record_field; _] ->
to_record_field inner_record_field
| _ -> | _ ->
unknown "record_field" json unknown "record_field" json

Loading…
Cancel
Save