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
25cf1919
Commit
25cf1919
authored
Mar 28, 2014
by
Julien Lopez
Browse files
[TESTS][EVAL] Add the left part of a match to the environment of the right part
parent
7fb71a7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/eval/TODO
View file @
25cf1919
Syntax:
- "_" as a keyword (?)
E
xtern
al
s
:
-
Compil
e the e
xternals to the parser
E
v
al:
-
Solv
e the e
valuation problems
Tests:
- Update tests to check the evaluation of CDuce (depends on
externals
)
- Update tests to check the evaluation of CDuce (depends on
Eval above
)
tests/eval/src/compile.ml
View file @
25cf1919
...
...
@@ -77,9 +77,18 @@ let parse_to_lambda expr =
fail_code
=
0
;
expected_type
=
""
}
in
let
rec
aux
env
brs
rhs
uid
=
match
brs
with
(* match
?
with | m & t -> e | ... *)
(* match
orig
with | m & t -> e | ... *)
|
(
m
,
t
,
e
)
::
rest
->
let
e
=
_parse_to_lambda
env
e
in
let
rec
env_match_value
map
m
nbr
=
match
m
with
|
MVar
(
vname
)
->
Hashtbl
.
add
map
vname
nbr
;
map
,
(
nbr
+
1
)
|
MInt
(
_
)
|
MString
(
_
)
->
map
,
nbr
|
MPair
(
m1
,
m2
)
->
let
map
,
nbr
=
env_match_value
map
m1
nbr
in
env_match_value
map
m2
nbr
in
let
map
,
nbvars
=
env_match_value
(
Hashtbl
.
create
page_size
)
m
0
in
let
new_env
=
mk_env
~
parent
:
(
Some
env
)
~
max_size
:
env
.
max_size
~
map
:
map
nbvars
(
env
.
global_size
+
nbvars
)
in
let
e
=
_parse_to_lambda
new_env
e
in
aux
env
rest
(
Array
.
append
rhs
[
|
Auto_pat
.
Match
(
uid
,
e
)
|
])
(
uid
+
1
)
|
[]
->
dummy_state
,
rhs
in
...
...
tests/eval/src/main.ml
View file @
25cf1919
...
...
@@ -31,7 +31,7 @@ let rec print_value v = match v with
let
str
=
if
Array
.
length
Sys
.
argv
>
1
then
load_file
Sys
.
argv
.
(
1
)
else
(*"let z = 3 in fun firsts x y -> match x,y with
| (a,_),(b,_) -> a,b (* This (* is (* a nested *) *) comment *)
| _ -> x . z (* That doesn't make any sense *)"*)
"match x with |
_
-> x"
in
| _ -> x . z (* That doesn't make any sense *)"*)
"
let x = 2 in
match x with |
x
-> x"
in
let
expr
=
ExprParser
.
of_string
str
in
(*printf "Original: %s\nExpr: " str;
print_expr expr;
...
...
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