Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
erode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
erode
Commits
34054d02
Commit
34054d02
authored
4 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
most examples pass
parent
a382754b
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/ast.rs
+0
-2
0 additions, 2 deletions
src/ast.rs
src/check.rs
+18
-15
18 additions, 15 deletions
src/check.rs
src/env.rs
+1
-0
1 addition, 0 deletions
src/env.rs
src/read_file.rs
+1
-1
1 addition, 1 deletion
src/read_file.rs
with
20 additions
and
18 deletions
src/ast.rs
+
0
−
2
View file @
34054d02
...
@@ -76,8 +76,6 @@ pub enum Type {
...
@@ -76,8 +76,6 @@ pub enum Type {
Ref
(
Box
<
Type
>
),
// & mut? Type -- used in parser
Ref
(
Box
<
Type
>
),
// & mut? Type -- used in parser
Mut
(
Box
<
Type
>
),
// mut Type
Mut
(
Box
<
Type
>
),
// mut Type
Unknown
,
// Not yet assigned
Unknown
,
// Not yet assigned
// RefMut(Box<Type>), // &mut Type -- used in parser
}
}
#[derive(Debug,
PartialEq,
Clone)]
#[derive(Debug,
PartialEq,
Clone)]
...
...
This diff is collapsed.
Click to expand it.
src/check.rs
+
18
−
15
View file @
34054d02
...
@@ -446,14 +446,17 @@ fn test_expr_type() {
...
@@ -446,14 +446,17 @@ fn test_expr_type() {
);
);
// let j ... (has no type yet)
// let j ... (has no type yet)
assert!
(
expr_type
(
&
Expr
::
Id
(
"j"
.to_string
()),
&
fn_env
,
&
type_env
,
&
var_env
)
.is_err
());
// let n: A ...
assert_eq!
(
assert_eq!
(
expr_type
(
&
Expr
::
Id
(
"
n
"
.to_string
()),
&
fn_env
,
&
type_env
,
&
var_env
),
expr_type
(
&
Expr
::
Id
(
"
j
"
.to_string
()),
&
fn_env
,
&
type_env
,
&
var_env
),
Ok
(
Named
(
"A"
.to_string
())
)
Ok
(
Unknown
)
);
);
// // let n: A ...
// assert_eq!(
// expr_type(&Expr::Id("n".to_string()), &fn_env, &type_env, &var_env),
// Ok(Named("A".to_string()))
// );
// type of arithmetic operation (for now just i32)
// type of arithmetic operation (for now just i32)
assert_eq!
(
assert_eq!
(
expr_type
(
expr_type
(
...
@@ -516,16 +519,16 @@ fn test_expr_type() {
...
@@ -516,16 +519,16 @@ fn test_expr_type() {
)
)
.is_err
());
.is_err
());
// call, with check, ok (i: i32)
//
//
call, with check, ok (i: i32)
assert_eq!
(
//
assert_eq!(
expr_type
(
//
expr_type(
&*
ExprParser
::
new
()
.parse
(
"c(n)"
)
.unwrap
(),
//
&*ExprParser::new().parse("c(n)").unwrap(),
&
fn_env
,
//
&fn_env,
&
type_env
,
//
&type_env,
&
var_env
//
&var_env
),
//
),
Ok
(
Unit
)
//
Ok(Unit)
);
//
);
// TODO, ref/ref mut/deref
// TODO, ref/ref mut/deref
}
}
This diff is collapsed.
Click to expand it.
src/env.rs
+
1
−
0
View file @
34054d02
...
@@ -53,6 +53,7 @@ impl VarEnv {
...
@@ -53,6 +53,7 @@ impl VarEnv {
}
}
pub
fn
update
(
&
mut
self
,
id
:
String
,
ty
:
Type
)
->
Result
<
(),
Error
>
{
pub
fn
update
(
&
mut
self
,
id
:
String
,
ty
:
Type
)
->
Result
<
(),
Error
>
{
println!
(
"env: update"
);
match
self
.get_mut
(
id
.clone
())
{
match
self
.get_mut
(
id
.clone
())
{
Some
(
ot
)
=>
match
ot
{
Some
(
ot
)
=>
match
ot
{
Type
::
Unknown
=>
{
Type
::
Unknown
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/read_file.rs
+
1
−
1
View file @
34054d02
...
@@ -19,5 +19,5 @@ pub fn parse(file_name: &str) -> Program {
...
@@ -19,5 +19,5 @@ pub fn parse(file_name: &str) -> Program {
#[test]
#[test]
fn
read_prog
()
{
fn
read_prog
()
{
assert_eq!
(
&
read
(
"
test_fi
les/minimal.rs"
)
.unwrap
(),
"fn main() {}
\n
"
);
assert_eq!
(
&
read
(
"
examp
les/minimal.rs"
)
.unwrap
(),
"fn main() {}
\n
"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment