PascaLIGO fixes.

This commit is contained in:
Sander Spies 2020-06-08 15:00:10 +02:00
parent aee524ffc4
commit d7b4a97731
2 changed files with 18 additions and 6 deletions

View File

@ -186,8 +186,13 @@ let preprocess syntax source =
let pretty_print_pascaligo source =
let%bind ast = Parser.Pascaligo.parse_file source in
let () = ignore ast in (* TODO *)
let buffer = Buffer.create 131
let doc = Parser_pascaligo.Pretty.print ast in
let buffer = Buffer.create 131 in
let width =
match Terminal_size.get_columns () with
None -> 60
| Some c -> c in
let () = PPrint.ToBuffer.pretty 1.0 width buffer doc
in Trace.ok buffer
let pretty_print_cameligo source =

View File

@ -254,7 +254,14 @@ and pp_cond_expr {value; _} =
and pp_conditional {value; _} =
let {test; ifso; ifnot; _} : conditional = value in
let test = string "if " ^^ group (nest 3 (pp_expr test))
and ifso = string "then" ^^ group (nest 2 (break 1 ^^ pp_if_clause ifso))
and ifso = match ifso with
ClauseInstr _ | ClauseBlock LongBlock _ ->
string "then"
^^ group (nest 2 (break 1 ^^ pp_if_clause ifso))
| ClauseBlock ShortBlock _ ->
string "then {"
^^ group (nest 2 (hardline ^^ pp_if_clause ifso))
^^ hardline ^^ string "}"
and ifnot = match ifnot with
ClauseInstr _ | ClauseBlock LongBlock _ ->
string "else"
@ -401,8 +408,8 @@ and pp_logic_expr = function
| CompExpr e -> pp_comp_expr e
and pp_bool_expr = function
Or e -> pp_bin_op "||" e
| And e -> pp_bin_op "&&" e
Or e -> pp_bin_op "or" e
| And e -> pp_bin_op "and" e
| Not e -> pp_un_op "not" e
| True _ -> string "true"
| False _ -> string "false"
@ -421,7 +428,7 @@ and pp_comp_expr = function
| Gt e -> pp_bin_op ">" e
| Geq e -> pp_bin_op ">=" e
| Equal e -> pp_bin_op "=" e
| Neq e -> pp_bin_op "<>" e
| Neq e -> pp_bin_op "=/=" e
and pp_arith_expr = function
Add e -> pp_bin_op "+" e