remove token_type from Identifier

This commit is contained in:
Victor Timofei 2023-09-11 00:51:35 +03:00
parent b9d9f5b87e
commit 4b32a4fd27
Signed by: vtimofei
GPG Key ID: B790DCEBE281403A
2 changed files with 0 additions and 31 deletions

View File

@ -201,7 +201,6 @@ impl Statement for ExpressionStatement {}
#[derive(Debug, PartialEq, Eq)]
pub struct Identifier {
pub token_type: TokenType,
pub value: String,
}

View File

@ -134,7 +134,6 @@ impl Parser {
let value = self.expect_peek_ident()?;
let name = Identifier {
token_type: TokenType::Let,
value,
};
@ -200,7 +199,6 @@ impl Parser {
fn parse_identifier(&mut self, value: String) -> Rc<dyn Expression> {
Rc::new(Identifier {
token_type: TokenType::Ident,
value,
})
}
@ -448,21 +446,18 @@ mod tests {
statements: vec![
Rc::new(Let {
name: Identifier {
token_type: TokenType::Let,
value: "x".into()
},
value: Rc::new(IntegerLiteral { value: 5 })
}),
Rc::new(Let {
name: Identifier {
token_type: TokenType::Let,
value: "y".into()
},
value: Rc::new(IntegerLiteral { value: 10 })
}),
Rc::new(Let {
name: Identifier {
token_type: TokenType::Let,
value: "foobar".into()
},
value: Rc::new(IntegerLiteral { value: 838383 })
@ -521,7 +516,6 @@ mod tests {
Program {
statements: vec![Rc::new(ExpressionStatement {
expression: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "foobar".into()
})
})]
@ -724,11 +718,9 @@ mod tests {
operator: PrefixOperator::Minus,
right: Rc::new(Identifier {
value: "a".into(),
token_type: TokenType::Ident,
}),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
}),
@ -740,7 +732,6 @@ mod tests {
right: Rc::new(Prefix {
operator: PrefixOperator::Minus,
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
}),
@ -753,16 +744,13 @@ mod tests {
left: Rc::new(Infix {
operator: InfixOperator::Plus,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "c".into(),
}),
}),
@ -774,16 +762,13 @@ mod tests {
left: Rc::new(Infix {
operator: InfixOperator::Plus,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "c".into(),
}),
}),
@ -795,16 +780,13 @@ mod tests {
left: Rc::new(Infix {
operator: InfixOperator::Asterisk,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "c".into(),
}),
}),
@ -816,16 +798,13 @@ mod tests {
left: Rc::new(Infix {
operator: InfixOperator::Asterisk,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "c".into(),
}),
}),
@ -835,17 +814,14 @@ mod tests {
expression: Rc::new(Infix {
operator: InfixOperator::Plus,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
right: Rc::new(Infix {
operator: InfixOperator::Slash,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "c".into(),
}),
}),
@ -860,17 +836,14 @@ mod tests {
left: Rc::new(Infix {
operator: InfixOperator::Plus,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "a".into(),
}),
right: Rc::new(Infix {
operator: InfixOperator::Asterisk,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "b".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "c".into(),
}),
}),
@ -878,17 +851,14 @@ mod tests {
right: Rc::new(Infix {
operator: InfixOperator::Slash,
left: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "d".into(),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "e".into(),
}),
}),
}),
right: Rc::new(Identifier {
token_type: TokenType::Ident,
value: "f".into(),
}),
}),