Removed various bits of unused code

This commit is contained in:
Emmanuel BENOîT 2023-01-11 07:20:29 +01:00
parent 16151bd326
commit ecc8f2ec8b
2 changed files with 2 additions and 30 deletions

View file

@ -2,11 +2,10 @@ use std::{cell::RefCell, collections::HashMap, fmt::Display, rc::Rc};
use crate::{ use crate::{
errors::{ErrorKind, SloxError, SloxResult}, errors::{ErrorKind, SloxError, SloxResult},
interpreter::EnvironmentRef, tokens::Token,
tokens::{Token, TokenType},
}; };
use super::{functions::Function, Callable, Environment, InterpreterState, Value}; use super::{functions::Function, Callable, InterpreterState, Value};
/// A Lox class. /// A Lox class.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -25,13 +24,6 @@ pub struct Instance {
fields: HashMap<String, Value>, fields: HashMap<String, Value>,
} }
/// A method bound to an instance.
#[derive(Debug, Clone)]
pub struct BoundMethod {
instance: Value,
method: String,
}
/* -------------------- * /* -------------------- *
* Class implementation * * Class implementation *
* -------------------- */ * -------------------- */

View file

@ -58,28 +58,8 @@ pub struct Token {
} }
impl 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. /// Check whether a token is an identifier.
pub fn is_identifier(&self) -> bool { pub fn is_identifier(&self) -> bool {
matches!(self.token_type, TokenType::Identifier(_)) 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"),
}
}
} }