Rename Token::Integer to Token::Number
This commit is contained in:
parent
5d7122aefa
commit
1607db20f9
@ -99,7 +99,7 @@ impl<'a> Lexer<'a> {
|
||||
|
||||
let integer = self.input[start_pos..self.position].parse::<i64>()?;
|
||||
|
||||
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)),
|
||||
])
|
||||
);
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ pub enum Token {
|
||||
Eof,
|
||||
Equal,
|
||||
Identifier(Identifier),
|
||||
Integer(i64),
|
||||
Number(i64),
|
||||
Plus,
|
||||
Star,
|
||||
LeftParenthesis,
|
||||
|
Loading…
Reference in New Issue
Block a user