FIX: Remove more unused code

This commit is contained in:
Nicolás Hatcher
2024-02-14 09:53:05 +01:00
parent e1bdabed2a
commit 1ee5c6a151
3 changed files with 4 additions and 37 deletions

View File

@@ -42,6 +42,8 @@
//! assert!(matches!(lexer.next_token(), TokenType::Reference { .. }));
//! ```
use std::mem;
use serde::{Deserialize, Serialize};
use crate::expressions::token::{OpCompare, OpProduct, OpSum};
@@ -49,7 +51,7 @@ use crate::expressions::token::{OpCompare, OpProduct, OpSum};
use crate::language::Language;
use crate::locale::Locale;
use super::token::{index, Error, TokenType};
use super::token::{Error, TokenType};
use super::types::*;
use super::utils;
@@ -139,7 +141,7 @@ impl Lexer {
/// Returns an error if the token is not the expected one.
pub fn expect(&mut self, tk: TokenType) -> Result<()> {
let nt = self.next_token();
if index(&nt) != index(&tk) {
if mem::discriminant(&nt) != mem::discriminant(&tk) {
return Err(self.set_error(&format!("Error, expected {:?}", tk), self.position));
}
Ok(())

View File

@@ -1,5 +1,3 @@
use std::fmt;
use serde::{Deserialize, Serialize};
use crate::expressions::token;
@@ -79,4 +77,3 @@ pub fn get_tokens(formula: &str) -> Vec<MarkedToken> {
}
tokens
}

View File

@@ -259,35 +259,3 @@ pub enum TokenType {
table_reference: Option<TableReference>,
},
}
pub fn index(token: &TokenType) -> u32 {
use self::TokenType::*;
match token {
Illegal(..) => 1,
EOF => 2,
Ident(..) => 3,
String(..) => 4,
Number(..) => 6,
Boolean(..) => 7,
Error(..) => 8,
Addition(..) => 9,
Product(..) => 10,
Power => 14,
LeftParenthesis => 15,
RightParenthesis => 16,
Colon => 17,
Semicolon => 18,
LeftBracket => 19,
RightBracket => 20,
LeftBrace => 21,
RightBrace => 22,
Comma => 23,
Bang => 24,
Percent => 30,
And => 31,
Reference { .. } => 34,
Range { .. } => 35,
Compare(..) => 37,
StructuredReference { .. } => 40,
}
}