Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
b7e5116a
Commit
b7e5116a
authored
Jan 02, 2015
by
POTTIER Francois
Browse files
Printer improvements.
The closing delimiter in records and arrays is now correctly indented.
parent
3f0f8bf4
Changes
1
Show whitespace changes
Inline
Side-by-side
src/printer.ml
View file @
b7e5116a
...
...
@@ -78,8 +78,11 @@ let space f =
let
comma
f
=
output_string
f
", "
let
semi
f
=
output_char
f
'
;
'
let
seminl
f
=
output_char
f
'
;
'
;
semi
f
;
nl
f
let
times
f
=
...
...
@@ -378,9 +381,9 @@ and exprk k f e =
|
ERecordAccess
(
e
,
field
)
->
fprintf
f
"%a.%s"
atom
e
field
|
ERecord
fs
->
fprintf
f
"{%a}"
(
indent
2
(
list
field
n
othing
))
fs
fprintf
f
"{%a
%t
}"
(
indent
2
(
sep
list
field
n
l
))
fs
nl
|
EArray
fs
->
fprintf
f
"[|%a|]"
(
indent
2
(
list
array_field
n
othing
))
fs
fprintf
f
"[|%a
%t
|]"
(
indent
2
(
sep
list
array_field
n
l
))
fs
nl
|
EArrayAccess
(
e
,
i
)
->
fprintf
f
"%a.(%a)"
atom
e
expr
i
else
...
...
@@ -411,19 +414,13 @@ and branch k f br =
fprintf
f
"%a ->%a"
pat
br
.
branchpat
(
indent
4
(
exprk
k
))
br
.
branchbody
and
field
f
(
label
,
e
)
=
fprintf
f
"%s = %a%t"
label
app
e
seminl
and
fpats
f
fps
=
list
fpat
nothing
f
fps
fprintf
f
"%s = %a%t"
label
app
e
semi
and
fpat
f
=
function
|
(
_
,
PWildcard
)
->
()
(* in a record pattern, fields can be omitted *)
|
(
label
,
p
)
->
fprintf
f
"%s = %a%t"
label
pat
p
seminl
and
fpat
f
(
label
,
p
)
=
fprintf
f
"%s = %a%t"
label
pat
p
semi
and
array_field
f
e
=
fprintf
f
"%a%t"
app
e
semi
nl
fprintf
f
"%a%t"
app
e
semi
and
pat0
f
=
function
|
PUnit
->
...
...
@@ -443,7 +440,9 @@ and pat0 f = function
|
PAnnot
(
p
,
t
)
->
fprintf
f
"(%a : %a)"
pat
p
typ
t
|
PRecord
fps
->
fprintf
f
"{%a}"
(
indent
2
fpats
)
fps
(* In a record pattern, fields can be omitted. *)
let
fps
=
List
.
filter
(
function
(
_
,
PWildcard
)
->
false
|
_
->
true
)
fps
in
fprintf
f
"{%a%t}"
(
indent
2
(
seplist
fpat
nl
))
fps
nl
|
p
->
fprintf
f
"(%a)"
pat
p
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment