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
b7893873
Commit
b7893873
authored
Apr 14, 2014
by
Julien Lopez
Browse files
[TESTS][LAMBDA] Fix string type; add dummy type variables
parent
fccd98da
Changes
5
Hide whitespace changes
Inline
Side-by-side
tests/lambda/GRAMMAR
View file @
b7893873
...
...
@@ -27,6 +27,7 @@ id = [a-z_][A-Za-z0-9_]*
(* TODO: Add union and polymorphic types *)
type_id = [A-Z][A-Za-z0-9_]*
| (complex_type_id)
| "'"[A-Z][A-Za-z0-9_]*
complex_type_id = [A-Z][A-Za-z0-9_]*
| complex_type_id * complex_type_id
...
...
tests/lambda/src/compute.ml
View file @
b7893873
...
...
@@ -13,12 +13,13 @@ exception Error
let
type_of_string
s
=
match
s
with
|
"Int"
->
interval
[
Intervals
.
Any
]
|
"String"
->
char
Chars
.
any
(* TODO: This type is char, find
string
*)
|
"String"
->
Sequence
.
string
|
"Char"
->
char
Chars
.
any
|
_
->
empty
let
rec
type_of_ptype
arg
=
match
arg
with
|
Type
(
t
)
->
type_of_string
t
|
PType
(
t
)
->
any
(* TODO: Check this solution *)
|
TPair
(
t1
,
t2
)
->
times
(
cons
(
type_of_ptype
t1
))
(
cons
(
type_of_ptype
t2
))
|
TArrow
(
t1
,
t2
)
->
arrow
(
cons
(
type_of_ptype
t1
))
(
cons
(
type_of_ptype
t2
))
...
...
tests/lambda/src/main.ml
View file @
b7893873
...
...
@@ -27,7 +27,7 @@ let tests = "CDuce runtime tests" >:::
(
run_test
"fun f x : Int : Int -> 2"
);
(* TODO: Fix this test. See compute.ml in type_of_string function *)
assert_equal
~
msg
:
"Test CDuce.runtime.abstr.medium failed"
~
printer
:
(
fun
x
->
x
)
"Abstraction((Int, Char ->
(
Int
,
Char
)
))"
~
printer
:
(
fun
x
->
x
)
"Abstraction((Int,
[
Char
* ]
->
[
Int
Char
* ]
))"
(
run_test
"fun f x : Int y : String : (Int*String) -> x,y"
);
);
...
...
tests/lambda/src/parse.ml
View file @
b7893873
...
...
@@ -19,6 +19,7 @@ and match_value =
|
MString
of
Loc
.
t
*
string
and
ptype
=
|
Type
of
string
|
PType
of
string
|
TPair
of
ptype
*
ptype
|
TArrow
of
ptype
*
ptype
...
...
@@ -62,7 +63,8 @@ module ExprParser = struct
];
type_id
:
[
"atom_type"
[
t
=
UIDENT
->
Type
(
t
)
]
|
[
"("
;
t
=
complex_type_id
;
")"
->
t
]];
|
[
"("
;
t
=
complex_type_id
;
")"
->
t
]
|
[
"'"
;
t
=
UIDENT
->
PType
(
t
)
]
];
complex_type_id
:
[
"complex_type"
LEFTA
[
t
=
UIDENT
->
Type
(
t
)
|
"("
;
t
=
SELF
;
")"
->
t
]
...
...
tests/lambda/src/parse.mli
View file @
b7893873
...
...
@@ -18,6 +18,7 @@ and match_value =
|
MString
of
Loc
.
t
*
string
and
ptype
=
|
Type
of
string
|
PType
of
string
|
TPair
of
ptype
*
ptype
|
TArrow
of
ptype
*
ptype
...
...
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