method var =
fun f ->
function
| "" -> pp f "$lid:\"\"$"
| "[]" -> pp f "[]"
| "()" -> pp f "()"
| " True" -> pp f "True"
| " False" -> pp f "False"
| v ->
(match (var_conversion, v) with
| (true, "val") -> pp f "contents"
| (true, "True") -> pp f "true"
| (true, "False") -> pp f "false"
| _ ->
(match lex_string v with
| LIDENT s | UIDENT s | ESCAPED_IDENT s when
is_keyword s -> pp f "%s__" s
| LIDENT s | ESCAPED_IDENT s when
List.mem s infix_lidents -> pp f "( %s )" s
| SYMBOL s -> pp f "( %s )" s
| LIDENT s | UIDENT s | ESCAPED_IDENT s ->
pp_print_string f s
| tok ->
failwith
(sprintf
"Bad token used as an identifier: %s"
(Token.to_string tok))))