From 97268c272edc7f6f2f22488158d1f465a243d43a Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 24 Jun 2024 13:54:37 -0400 Subject: [PATCH] Use rust-style type parameter syntax --- dust-lang/src/parser/mod.rs | 8 ++++---- dust-lang/src/parser/tests.rs | 8 ++++---- dust-lang/tests/functions.rs | 2 +- std/json.ds | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dust-lang/src/parser/mod.rs b/dust-lang/src/parser/mod.rs index 011945e..c341bef 100644 --- a/dust-lang/src/parser/mod.rs +++ b/dust-lang/src/parser/mod.rs @@ -82,8 +82,8 @@ pub fn parser<'src>( .at_least(1) .collect() .delimited_by( - just(Token::Symbol(Symbol::Pipe)), - just(Token::Symbol(Symbol::Pipe)), + just(Token::Symbol(Symbol::Less)), + just(Token::Symbol(Symbol::Greater)), ) .or_not(), ) @@ -281,8 +281,8 @@ pub fn parser<'src>( .allow_trailing() .collect() .delimited_by( - just(Token::Symbol(Symbol::Pipe)), - just(Token::Symbol(Symbol::Pipe)), + just(Token::Symbol(Symbol::Less)), + just(Token::Symbol(Symbol::Greater)), ) .or_not(), ) diff --git a/dust-lang/src/parser/tests.rs b/dust-lang/src/parser/tests.rs index 35065b9..93dfb23 100644 --- a/dust-lang/src/parser/tests.rs +++ b/dust-lang/src/parser/tests.rs @@ -467,7 +467,7 @@ fn list_of_type() { #[test] fn function_type() { assert_eq!( - parse(&lex("type Foo = fn |T| (x: int)").unwrap()).unwrap()[0], + parse(&lex("type Foo = fn (x: int)").unwrap()).unwrap()[0], Statement::TypeAlias( TypeAlias::new( Identifier::new("Foo").with_position((5, 8)), @@ -493,7 +493,7 @@ fn function_type() { #[test] fn function_type_with_return() { assert_eq!( - parse(&lex("type Foo = fn |T| (x: int) -> T").unwrap()).unwrap()[0], + parse(&lex("type Foo = fn (x: int) -> T").unwrap()).unwrap()[0], Statement::TypeAlias( TypeAlias::new( Identifier::new("Foo").with_position((5, 8)), @@ -537,7 +537,7 @@ fn function_call() { } #[test] -fn function_call_with_type_arguments() { +fn function_call_with_arguments() { assert_eq!( parse(&lex("foobar::('hi')").unwrap()).unwrap()[0], Statement::Expression(Expression::FunctionCall( @@ -610,7 +610,7 @@ fn function() { #[test] fn function_with_type_arguments() { assert_eq!( - parse(&lex("fn |T, U| (x: T, y: U) -> T { x }").unwrap()).unwrap()[0], + parse(&lex("fn (x: T, y: U) -> T { x }").unwrap()).unwrap()[0], Statement::Expression(Expression::Value( ValueNode::function( Some(vec![Identifier::new("T"), Identifier::new("U"),]), diff --git a/dust-lang/tests/functions.rs b/dust-lang/tests/functions.rs index c6f35c1..0dfa6e0 100644 --- a/dust-lang/tests/functions.rs +++ b/dust-lang/tests/functions.rs @@ -6,7 +6,7 @@ fn function_call_with_type_argument() { interpret( "test", " - foobar = fn |T| (x: T) -> T { x } + foobar = fn (x: T) -> T { x } foobar::(42) ", ), diff --git a/std/json.ds b/std/json.ds index 6f244a3..ab1454a 100644 --- a/std/json.ds +++ b/std/json.ds @@ -1,5 +1,5 @@ json = { - parse = fn |T| (input: str) -> T { + parse = fn (input: str) -> T { __JSON_PARSE__::(input) } }