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
f7a63894
Commit
f7a63894
authored
Apr 30, 2014
by
Julien Lopez
Browse files
[TESTS][LAMBDA] Add special variable "_"
parent
d28447e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/lambda/src/compute.ml
View file @
f7a63894
...
...
@@ -51,14 +51,18 @@ let rec _to_typed env l expr =
env
,
l
,
{
exp_loc
=
loc
;
exp_typ
=
type_of_string
"Int"
;
exp_descr
=
Op
(
op
,
0
,
[
e1
;
e2
])
}
|
Var
(
origloc
,
vname
)
->
let
line
=
Loc
.
start_line
origloc
in
let
cbegin
=
Loc
.
start_off
origloc
-
Loc
.
start_bol
origloc
in
let
cend
=
Loc
.
stop_off
origloc
-
Loc
.
start_bol
origloc
in
if
vname
=
"`nil"
then
let
nil_atom
=
Atoms
.
V
.
mk_ascii
"nil"
in
env
,
l
,
{
exp_loc
=
loc
;
exp_typ
=
(
Types
.
atom
(
Atoms
.
atom
nil_atom
));
exp_descr
=
(
Cst
(
Types
.
Atom
nil_atom
))
}
else
if
vname
=
"_"
then
(
Printf
.
eprintf
"File %s, line %d, characters %d-%d:
\n
Error: Invalid reference to special variable %s
\n
"
(
Loc
.
file_name
origloc
)
line
cbegin
cend
vname
;
raise
Error
)
else
let
line
=
Loc
.
start_line
origloc
in
let
cbegin
=
Loc
.
start_off
origloc
-
Loc
.
start_bol
origloc
in
let
cend
=
Loc
.
stop_off
origloc
-
Loc
.
start_bol
origloc
in
let
index
,
vtype
=
try
Locals
.
find
vname
l
with
Not_found
->
Printf
.
eprintf
...
...
@@ -221,6 +225,8 @@ and parse_match_value env l list toptype = function
let
nil_atom
=
Atoms
.
V
.
mk_ascii
"nil"
in
let
t
=
Types
.
atom
(
Atoms
.
atom
nil_atom
)
in
(
t
,
Patterns
.
Constr
(
t
)
,
list
,
l
,
true
)
else
if
mname
=
"_"
then
(
Types
.
any
,
Patterns
.
Constr
(
Types
.
any
)
,
list
,
l
,
true
)
else
let
lsize
=
Locals
.
cardinal
l
in
let
l
=
Locals
.
add
mname
(
lsize
,
type_of_ptype
mtype
)
l
in
...
...
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