From 1607db20f9677c2bcab046211f8efa00e44c8b4e Mon Sep 17 00:00:00 2001 From: Jeff Date: Sun, 4 Aug 2024 19:28:28 -0400 Subject: [PATCH] Rename Token::Integer to Token::Number --- dust-lang/src/lex.rs | 22 +++++++++++----------- dust-lang/src/parse.rs | 2 +- dust-lang/src/token.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dust-lang/src/lex.rs b/dust-lang/src/lex.rs index e2664c5..0a1c65c 100644 --- a/dust-lang/src/lex.rs +++ b/dust-lang/src/lex.rs @@ -99,7 +99,7 @@ impl<'a> Lexer<'a> { let integer = self.input[start_pos..self.position].parse::()?; - Ok((Token::Integer(integer), (start_pos, self.position))) + Ok((Token::Number(integer), (start_pos, self.position))) } fn lex_identifier(&mut self) -> Result<(Token, Span), LexError> { @@ -142,9 +142,9 @@ mod tests { assert_eq!( lex(input), Ok(vec![ - (Token::Integer(1), (0, 1)), + (Token::Number(1), (0, 1)), (Token::Plus, (2, 3)), - (Token::Integer(2), (4, 5)), + (Token::Number(2), (4, 5)), (Token::Eof, (5, 5)), ]) ) @@ -157,9 +157,9 @@ mod tests { assert_eq!( lex(input), Ok(vec![ - (Token::Integer(1), (0, 1)), + (Token::Number(1), (0, 1)), (Token::Star, (2, 3)), - (Token::Integer(2), (4, 5)), + (Token::Number(2), (4, 5)), (Token::Eof, (5, 5)), ]) ) @@ -172,11 +172,11 @@ mod tests { assert_eq!( lex(input), Ok(vec![ - (Token::Integer(1), (0, 1)), + (Token::Number(1), (0, 1)), (Token::Plus, (2, 3)), - (Token::Integer(2), (4, 5)), + (Token::Number(2), (4, 5)), (Token::Star, (6, 7)), - (Token::Integer(3), (8, 9)), + (Token::Number(3), (8, 9)), (Token::Eof, (9, 9)), ]) ); @@ -191,11 +191,11 @@ mod tests { Ok(vec![ (Token::Identifier(Identifier::new("a")), (0, 1)), (Token::Equal, (2, 3)), - (Token::Integer(1), (4, 5)), + (Token::Number(1), (4, 5)), (Token::Plus, (6, 7)), - (Token::Integer(2), (8, 9)), + (Token::Number(2), (8, 9)), (Token::Star, (10, 11)), - (Token::Integer(3), (12, 13)), + (Token::Number(3), (12, 13)), (Token::Eof, (13, 13)), ]) ); diff --git a/dust-lang/src/parse.rs b/dust-lang/src/parse.rs index 0f91674..360b2ed 100644 --- a/dust-lang/src/parse.rs +++ b/dust-lang/src/parse.rs @@ -96,7 +96,7 @@ impl<'src> Parser<'src> { fn parse_primary(&mut self) -> Result<(Instruction, Span), ParseError> { match self.current.clone() { - (Token::Integer(int), span) => { + (Token::Number(int), span) => { self.next_token()?; Ok((Instruction::Constant(Value::integer(int)), span)) } diff --git a/dust-lang/src/token.rs b/dust-lang/src/token.rs index 42615aa..4c18804 100644 --- a/dust-lang/src/token.rs +++ b/dust-lang/src/token.rs @@ -5,7 +5,7 @@ pub enum Token { Eof, Equal, Identifier(Identifier), - Integer(i64), + Number(i64), Plus, Star, LeftParenthesis,