to_json for locations
This commit is contained in:
parent
ca2ec3d795
commit
2a9ef440db
@ -33,7 +33,7 @@ module M = struct
|
||||
packed_internal_operation = (fun _visitor NoState _op -> `String "Operation(...bytes)") ;
|
||||
expression_variable = (fun _visitor NoState ev -> `Assoc ["exp-var", `String (asprintf "%a" Var.pp ev.wrap_content)] ) ;
|
||||
constructor' = (fun _visitor NoState (Constructor c) -> `Assoc ["constructor", `String c] ) ;
|
||||
location = (fun _visitor NoState loc -> `String (asprintf "%a" Location.pp loc) ) ; (*TODO*)
|
||||
location = (fun _visitor NoState loc -> Location.pp_json loc) ;
|
||||
label = (fun _visitor NoState (Label lbl) -> `Assoc ["label" , `String lbl] ) ;
|
||||
ast_core_type_expression = (fun _visitor NoState te -> `String (asprintf "%a" (Ast_core.PP.type_expression) te) ) ; (*TODO*)
|
||||
constructor_map = (fun _visitor continue NoState cmap ->
|
||||
|
12
vendors/ligo-utils/simple-utils/location.ml
vendored
12
vendors/ligo-utils/simple-utils/location.ml
vendored
@ -17,6 +17,18 @@ let pp = fun ppf t ->
|
||||
| Virtual _s -> Format.fprintf ppf ""
|
||||
| File f -> Format.fprintf ppf "%s" (f#to_string `Point)
|
||||
|
||||
let pp_json = fun t ->
|
||||
match t with
|
||||
| Virtual s -> `Assoc ["virtual" , `String s]
|
||||
| File f ->
|
||||
`Assoc [
|
||||
("file", `String f#file) ;
|
||||
("from_row", `Int f#start#line) ;
|
||||
("from_col", `Int (f#start#column `Point)) ;
|
||||
("to_row", `Int f#stop#line) ;
|
||||
("to_col", `Int (f#stop#column `Point)) ;
|
||||
]
|
||||
|
||||
let compare a b = match a,b with
|
||||
| (File a, File b) -> Region.compare a b
|
||||
| (File _, Virtual _) -> -1
|
||||
|
Loading…
Reference in New Issue
Block a user