Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
032c4286
Commit
032c4286
authored
Sep 19, 2014
by
Pietro Abate
Browse files
Fix few parsing problems
All problems related to the introduction of the new syntax for constructed types
parent
3f21e819
Changes
2
Show whitespace changes
Inline
Side-by-side
parser/parser.ml
View file @
032c4286
...
...
@@ -94,19 +94,12 @@ let is_fun_decl =
(
fun
strm
->
match
Stream
.
npeek
3
strm
with
|
[
KEYWORD
"fun"
,
_
;
IDENT
_
,
_
;
KEYWORD
"("
,
_
]
|
[
KEYWORD
"fun"
,
_
;
IDENTPAR
_
,
_
;
_
]
|
[
IDENTPAR
_
,
_
;
_
;
_
]
|
[
IDENT
_
,
_
;
KEYWORD
"("
,
_
;
_
]
->
()
|
_
->
raise
Stream
.
Failure
)
let
is_capture
=
Gram
.
Entry
.
of_parser
"[is_capture]"
(
fun
strm
->
match
Stream
.
npeek
2
strm
with
|
[
IDENT
_
,
_
;
KEYWORD
"::"
,
_
;
_
]
->
()
|
_
->
raise
Stream
.
Failure
)
let
if_then_else
cond
e1
e2
=
Match
(
cond
,
[(
mk
(
0
,
0
)
(
Cst
(
Atom
(
ident
"true"
))))
,
e1
;
(
mk
(
0
,
0
)
(
Cst
(
Atom
(
ident
"false"
))))
,
e2
])
...
...
@@ -270,14 +263,10 @@ EXTEND Gram
(
match
n
with
|
`Prefix
(
name
,
ns
)
->
exp
_loc
(
NamespaceIn
(
name
,
ns
,
e2
))
|
`Keep
f
->
exp
_loc
(
KeepNsIn
(
f
,
e2
)))
|
e
=
expr
;
":"
;
p
=
pat
->
exp
_loc
(
Forget
(
e
,
p
))
|
e
=
expr
;
":"
;
"?"
;
p
=
pat
->
exp
_loc
(
Check
(
e
,
p
))
|
e1
=
expr
;
";"
;
e2
=
expr
->
exp
_loc
(
seq
e1
e2
)
|
"ref"
;
p
=
pat
;
e
=
expr
->
exp
_loc
(
Ref
(
e
,
p
))
|
e
=
expr
;
":"
;
p
=
pat
->
exp
_loc
(
Forget
(
e
,
p
))
|
e
=
expr
;
":"
;
"?"
;
p
=
pat
->
exp
_loc
(
Check
(
e
,
p
))
|
e1
=
expr
;
";"
;
e2
=
expr
->
exp
_loc
(
seq
e1
e2
)
|
"ref"
;
p
=
pat
;
e
=
expr
->
exp
_loc
(
Ref
(
e
,
p
))
|
"not"
;
e
=
expr
->
exp
_loc
(
logical_not
e
)
]
|
[
e1
=
expr
;
":="
;
e2
=
expr
->
exp
_loc
(
set_ref
e1
e2
)
]
...
...
@@ -291,8 +280,7 @@ EXTEND Gram
]
|
[
e1
=
expr
;
op
=
[
"+"
|
"-"
|
"@"
];
e2
=
expr
->
apply_op2
_loc
op
e1
e2
|
e1
=
expr
;
[
"||"
|
"or"
];
e2
=
expr
->
exp
_loc
(
logical_or
e1
e2
)
|
e
=
expr
;
"
\\
"
;
l
=
ident_or_keyword
->
exp
_loc
(
RemoveField
(
e
,
label
l
))
|
e
=
expr
;
"
\\
"
;
l
=
ident_or_keyword
->
exp
_loc
(
RemoveField
(
e
,
label
l
))
]
|
[
e1
=
expr
;
op
=
[
"*"
];
e2
=
expr
->
apply_op2
_loc
op
e1
e2
|
e1
=
expr
;
"&&"
;
e2
=
expr
->
exp
_loc
(
logical_and
e1
e2
)
...
...
@@ -349,7 +337,11 @@ EXTEND Gram
exp
_loc
body
]
|
[
e1
=
SELF
;
IDENT
"div"
;
e2
=
expr
->
apply_op2
_loc
"/"
e1
e2
a
=
IDENTPAR
;
l
=
LIST1
expr
SEP
","
;
")"
->
let
e1
=
exp
_loc
(
Var
(
ident
a
))
in
let
e2
=
exp
_loc
(
tuple
l
)
in
exp
_loc
(
Apply
(
e1
,
e2
))
|
e1
=
SELF
;
IDENT
"div"
;
e2
=
expr
->
apply_op2
_loc
"/"
e1
e2
|
e1
=
SELF
;
IDENT
"mod"
;
e2
=
expr
->
apply_op2
_loc
"mod"
e1
e2
|
e1
=
SELF
;
e2
=
expr
->
exp
_loc
(
Apply
(
e1
,
e2
))
]
...
...
types/var.ml
View file @
032c4286
...
...
@@ -29,7 +29,7 @@ module V = struct
end
let
pp
ppf
x
=
Format
.
fprintf
ppf
"'%a"
Ident
.
U
.
print
x
.
id
let
pp
ppf
x
=
dump
ppf
x
(*
let pp ppf x = dump ppf x
*)
end
include
V
...
...
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