Removed various bits of unused code
This commit is contained in:
parent
16151bd326
commit
ecc8f2ec8b
2 changed files with 2 additions and 30 deletions
|
@ -2,11 +2,10 @@ use std::{cell::RefCell, collections::HashMap, fmt::Display, rc::Rc};
|
|||
|
||||
use crate::{
|
||||
errors::{ErrorKind, SloxError, SloxResult},
|
||||
interpreter::EnvironmentRef,
|
||||
tokens::{Token, TokenType},
|
||||
tokens::Token,
|
||||
};
|
||||
|
||||
use super::{functions::Function, Callable, Environment, InterpreterState, Value};
|
||||
use super::{functions::Function, Callable, InterpreterState, Value};
|
||||
|
||||
/// A Lox class.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -25,13 +24,6 @@ pub struct Instance {
|
|||
fields: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
/// A method bound to an instance.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BoundMethod {
|
||||
instance: Value,
|
||||
method: String,
|
||||
}
|
||||
|
||||
/* -------------------- *
|
||||
* Class implementation *
|
||||
* -------------------- */
|
||||
|
|
|
@ -58,28 +58,8 @@ pub struct Token {
|
|||
}
|
||||
|
||||
impl Token {
|
||||
/// Check whether a token corresponds to a litteral value.
|
||||
pub fn is_litteral(&self) -> bool {
|
||||
matches!(
|
||||
self.token_type,
|
||||
TokenType::True
|
||||
| TokenType::False
|
||||
| TokenType::Nil
|
||||
| TokenType::String(_)
|
||||
| TokenType::Number(_)
|
||||
)
|
||||
}
|
||||
|
||||
/// Check whether a token is an identifier.
|
||||
pub fn is_identifier(&self) -> bool {
|
||||
matches!(self.token_type, TokenType::Identifier(_))
|
||||
}
|
||||
|
||||
/// Get the name from an identifier token, returning an error otherwise.
|
||||
pub fn as_identifier(&self) -> Result<&str, &'static str> {
|
||||
match &self.token_type {
|
||||
TokenType::Identifier(name) => Ok(name),
|
||||
_ => Err("token is not an identifier"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue