mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Rename Func to CallByName
This commit is contained in:
parent
41ddfc149b
commit
c85f246988
5 changed files with 19 additions and 19 deletions
|
@ -32,7 +32,7 @@ For example, parsing will transalte this string:
|
|||
|
||||
...into this `Expr`:
|
||||
|
||||
Func("not", vec!["foo", "bar"])
|
||||
CallByName("not", vec!["foo", "bar"])
|
||||
|
||||
Now we may know that `not` takes a `Bool` and returns another `Bool`, but the parser doesn't know that.
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ pub fn scoped_eval(expr: Expr, vars: &Scope) -> Evaluated {
|
|||
scoped_eval(*in_expr, vars)
|
||||
},
|
||||
|
||||
Func(name, args) => {
|
||||
CallByName(name, args) => {
|
||||
let func_expr = match vars.get(&name) {
|
||||
Some(resolved) => {
|
||||
let Evaluated(ref evaluated_expr) = **resolved;
|
||||
|
|
|
@ -16,7 +16,7 @@ pub enum Expr {
|
|||
Assign(Pattern, Box<Expr>, Box<Expr>),
|
||||
|
||||
// Functions
|
||||
Func(Ident, Vec<Expr>),
|
||||
CallByName(Ident, Vec<Expr>),
|
||||
Apply(Box<Expr>, Vec<Expr>),
|
||||
Operator(Box<Expr>, Operator, Box<Expr>),
|
||||
Closure(SmallVec<[Pattern; 2]>, Box<Expr>),
|
||||
|
|
|
@ -352,7 +352,7 @@ where I: Stream<Item = char, Position = IndentablePosition>,
|
|||
// allocating a Vec in the common case where this is a var
|
||||
match opt_args {
|
||||
None => Expr::Var(name),
|
||||
Some(args) => Expr::Func(name, args)
|
||||
Some(args) => Expr::CallByName(name, args)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -404,14 +404,14 @@ mod test_parse {
|
|||
|
||||
expect_parsed_apply(
|
||||
"(x 5) y",
|
||||
Func("x".to_string(), vec![Int(5)]),
|
||||
CallByName("x".to_string(), vec![Int(5)]),
|
||||
Var("y".to_string())
|
||||
);
|
||||
|
||||
expect_parsed_apply(
|
||||
"(x 5) (y 6)",
|
||||
Func("x".to_string(), vec![Int(5)]),
|
||||
Func("y".to_string(), vec![Int(6)]),
|
||||
CallByName("x".to_string(), vec![Int(5)]),
|
||||
CallByName("y".to_string(), vec![Int(6)]),
|
||||
);
|
||||
|
||||
expect_parsed_apply(
|
||||
|
@ -435,7 +435,7 @@ mod test_parse {
|
|||
|
||||
fn expect_parsed_func<'a>(parse_str: &'a str, func_str: &'a str, args: Vec<Expr>) {
|
||||
assert_eq!(
|
||||
Ok((Func(func_str.to_string(), args), "")),
|
||||
Ok((CallByName(func_str.to_string(), args), "")),
|
||||
parse_standalone(parse_str)
|
||||
);
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ mod test_parse {
|
|||
(
|
||||
Operator(
|
||||
Box::new(
|
||||
Func("f".to_string(),
|
||||
CallByName("f".to_string(),
|
||||
vec![Int(5)],
|
||||
)
|
||||
),
|
||||
|
@ -504,7 +504,7 @@ mod test_parse {
|
|||
(
|
||||
Operator(
|
||||
Box::new(
|
||||
Func("f".to_string(),
|
||||
CallByName("f".to_string(),
|
||||
vec![Int(1), Int(2), Int(3)],
|
||||
)
|
||||
),
|
||||
|
@ -638,8 +638,8 @@ mod test_parse {
|
|||
Case(
|
||||
Box::new(Int(0)),
|
||||
smallvec![
|
||||
( Integer(2), Box::new(Func("foo".to_string(), vec![Int(9)])) ),
|
||||
( Integer(1), Box::new(Func("bar".to_string(), vec![Int(8)])) ),
|
||||
( Integer(2), Box::new(CallByName("foo".to_string(), vec![Int(9)])) ),
|
||||
( Integer(1), Box::new(CallByName("bar".to_string(), vec![Int(8)])) ),
|
||||
]
|
||||
),
|
||||
""
|
||||
|
@ -784,18 +784,18 @@ mod test_parse {
|
|||
fn complex_expressions() {
|
||||
expect_parsed_apply(
|
||||
"(x 5) (y + (f 6))",
|
||||
Func("x".to_string(), vec![Int(5)]),
|
||||
CallByName("x".to_string(), vec![Int(5)]),
|
||||
Operator(
|
||||
Box::new(Var("y".to_string())),
|
||||
Plus,
|
||||
Box::new(Func("f".to_string(), vec![Int(6)])),
|
||||
Box::new(CallByName("f".to_string(), vec![Int(6)])),
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
parse_standalone("(x 5)"),
|
||||
Ok((
|
||||
Func("x".to_string(), vec![Int(5)]),
|
||||
CallByName("x".to_string(), vec![Int(5)]),
|
||||
"")
|
||||
)
|
||||
);
|
||||
|
@ -856,7 +856,7 @@ mod test_parse {
|
|||
parse_standalone("(x 5) + 123"),
|
||||
Ok((
|
||||
Operator(
|
||||
Box::new(Func("x".to_string(), vec![Int(5)])),
|
||||
Box::new(CallByName("x".to_string(), vec![Int(5)])),
|
||||
Plus,
|
||||
Box::new(Int(123))
|
||||
),
|
||||
|
@ -868,7 +868,7 @@ mod test_parse {
|
|||
parse_standalone("(x 5) + (2 * y)"),
|
||||
Ok((
|
||||
Operator(
|
||||
Box::new(Func("x".to_string(), vec![Int(5)])),
|
||||
Box::new(CallByName("x".to_string(), vec![Int(5)])),
|
||||
Plus,
|
||||
Box::new(
|
||||
Operator(
|
||||
|
@ -894,7 +894,7 @@ mod test_parse {
|
|||
Identifier(
|
||||
"abc".to_string()
|
||||
),
|
||||
Box::new(Func(
|
||||
Box::new(CallByName(
|
||||
"y".to_string(),
|
||||
vec![
|
||||
Int(
|
||||
|
@ -1046,7 +1046,7 @@ mod test_parse {
|
|||
Identifier("f".to_string()),
|
||||
Box::new(Closure(
|
||||
smallvec![Identifier("x".to_string())],
|
||||
Box::new(Func("c".to_string(), vec![Int(1)]))
|
||||
Box::new(CallByName("c".to_string(), vec![Int(1)]))
|
||||
)),
|
||||
Box::new(Var("f".to_string()))
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue