From 80bf09d807ee027d5e184776080f47836a097e64 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 20 Aug 2024 15:55:35 -0400 Subject: [PATCH] Clean up --- dust-lang/src/parser.rs | 7 +------ examples/fizzbuzz.ds | 8 ++++---- examples/guessing_game.ds | 10 +++++----- examples/hello_world.ds | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/dust-lang/src/parser.rs b/dust-lang/src/parser.rs index af637a1..22eb7ea 100644 --- a/dust-lang/src/parser.rs +++ b/dust-lang/src/parser.rs @@ -157,13 +157,8 @@ impl<'src> Parser<'src> { end } else { - return Err(ParseError::ExpectedToken { - expected: TokenKind::Semicolon, - actual: self.current_token.to_owned(), - position: self.current_position, - }); + value.position().1 }; - let r#let = if is_mutable { LetStatement::LetMut { identifier, value } } else { diff --git a/examples/fizzbuzz.ds b/examples/fizzbuzz.ds index eb9bd42..041e9b7 100644 --- a/examples/fizzbuzz.ds +++ b/examples/fizzbuzz.ds @@ -1,8 +1,8 @@ -let mut count = 1; +let mut count = 1 while count <= 15 { - let divides_by_3 = count % 3 == 0; - let divides_by_5 = count % 5 == 0; + let divides_by_3 = count % 3 == 0 + let divides_by_5 = count % 5 == 0 let output = if divides_by_3 && divides_by_5 { "fizzbuzz" @@ -12,7 +12,7 @@ while count <= 15 { "buzz" } else { count.to_string() - }; + } write_line(output) diff --git a/examples/guessing_game.ds b/examples/guessing_game.ds index d99fa77..ae31ed1 100644 --- a/examples/guessing_game.ds +++ b/examples/guessing_game.ds @@ -1,12 +1,12 @@ -io.write_line("Guess the number.") +write_line("Guess the number.") -secret_number = int.random_range(0..100) +let secret_number = random(0..100); loop { - io.write_line("Input your guess.") + write_line("Input your guess.") - input = io.read_line() - guess = int.parse(input) + let input = io.read_line(); + let guess = int.parse(input); if guess < secret_number { io.write_line("Too low!") diff --git a/examples/hello_world.ds b/examples/hello_world.ds index d6bbd05..613cb0b 100644 --- a/examples/hello_world.ds +++ b/examples/hello_world.ds @@ -1,6 +1,6 @@ write_line("Hello, world!") write_line("Enter your name...") -let name = read_line(); +let name = read_line() write_line("Hello " + name + "!")