Skip to content

Commit

Permalink
Fix type parsing bug and bump version to 0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
P-bibs committed Sep 6, 2021
1 parent f6cad7a commit 6a0b62c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -6,7 +6,7 @@ documentation = "https://github.com/P-bibs/skiff"
repository = "https://github.com/P-bibs/skiff"
readme = "README.md"
license = "MIT"
version = "0.4.4"
version = "0.4.5"
authors = ["Paul Biberstein <biberstein.paul@gmail.com>"]
edition = "2018"
keywords = ["interpreters", "wasm", "programming-language", "cli"]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.wasm.toml
Expand Up @@ -6,7 +6,7 @@ documentation = "https://github.com/P-bibs/skiff"
repository = "https://github.com/P-bibs/skiff"
readme = "README.md"
license = "MIT"
version = "0.4.4"
version = "0.4.5"
authors = ["Paul Biberstein <biberstein.paul@gmail.com>"]
edition = "2018"
keywords = ["interpreters", "wasm", "programming-language", "cli"]
Expand Down
2 changes: 1 addition & 1 deletion src/parser/types/parse.rs
Expand Up @@ -56,7 +56,7 @@ fn parse_type_args(
args.push_back(parse_type(tokens)?.0);
match tokens.pop() {
Some((Token::Comma, _)) => continue,
Some((Token::Gt, span_end)) => return Ok((args, span_end.end)),
Some((Token::RParen, span_end)) => return Ok((args, span_end.end)),
Some((t, span)) => {
return Err(ParseError(
format!("Unexpected token in type args {:?}", t).to_string(),
Expand Down
20 changes: 11 additions & 9 deletions tests/files/success/language_tour.boat
@@ -1,22 +1,22 @@
# We can define ADTs with the `data` keyword.
# We can define ADTs with the \`data\` keyword.
data Option:
| some(v)
| none()
end

# A simple linked list with a first item and a rest.
data List:
| link(f,r)
| link(f, r)
| empty()
end

# A binary tree node
# A binary tree node with optional type annotations
data Tree:
| node(v,l,r)
| node(v: Number, l: Tree, r: Tree)
| leaf()
end

# Higher order functions are supported, so we can define a `map` function that
# Higher order functions are supported, so we can define a \`map\` function that
# takes a function and a list and applies the function to each element of the list
def map(func, l):
match l:
Expand All @@ -25,8 +25,9 @@ def map(func, l):
end
end

# We define `filter` similar to `map` by using pattern matching and recursion.
def filter(func, l):
# We define \`filter\` similar to \`map\` by using pattern matching and recursion.
# We can also supply optional type annotations.
def filter(func: Number -> Boolean, l: List) -> List:
match l:
| link(f,r) => if func(f):
link(f, filter(func, r))
Expand All @@ -44,10 +45,11 @@ def fold(func, l, default):
end
end

let list = link(1, link(2, link(3, link(4, empty()))))
# type annotation could be omitted
let list: List = link(1, link(2, link(3, link(4, empty()))))

map(lambda(x): x + 1 end, list)

filter(lambda(x): x == 2 end, list)

fold(lambda(n,a): n + a end, list, 0)
fold(lambda(n,a): n + a end, list, 0)

0 comments on commit 6a0b62c

Please sign in to comment.