diff --git a/src/compiling/compiler.rs b/src/compiling/compiler.rs index 806d9dd..4fd2592 100644 --- a/src/compiling/compiler.rs +++ b/src/compiling/compiler.rs @@ -67,7 +67,6 @@ pub enum ScopingMode { /// # } /// ``` #[derive(Debug, Clone, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Compiler { /// Name of your language pub name: String, diff --git a/src/compiling/lexing/lexer.rs b/src/compiling/lexing/lexer.rs index 8836ef9..8425e33 100644 --- a/src/compiling/lexing/lexer.rs +++ b/src/compiling/lexing/lexer.rs @@ -14,12 +14,8 @@ use super::{ LexerError, LexerErrorType, }; -#[cfg(feature = "serde")] -use serde::{Serialize, Deserialize}; - /// Lexer #[derive(Debug, Clone, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Lexer { rules: Rules, /// Path to the lexed file @@ -32,14 +28,13 @@ pub struct Lexer { pub scoping_mode: ScopingMode, } -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -struct LexState<'a> { +struct LexState { word: String, is_indenting: bool, is_escaped: bool, token_start_index: usize, position: (usize, usize), - reader: Reader<'a>, + reader: Reader, lexem: Vec, region_handler: RegionHandler, compound_handler: CompoundHandler, diff --git a/src/compiling/lexing/reader.rs b/src/compiling/lexing/reader.rs index 438fae9..ae7c20b 100644 --- a/src/compiling/lexing/reader.rs +++ b/src/compiling/lexing/reader.rs @@ -1,27 +1,22 @@ -#[cfg(feature = "serde")] -use serde::{Serialize, Deserialize}; - const BEGINNING: (usize, usize) = (0, 1); -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum ReadMode { History, Future } -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct Reader<'a> { - pub code: &'a String, +pub struct Reader { + pub code: String, pub row: usize, pub col: usize, pub index: usize, pub new_line: bool } -impl<'a> Reader<'a> { - pub fn new(code: &'a String) -> Self { +impl Reader { + pub fn new(code: &String) -> Self { Reader { - code, + code: code.clone(), row: BEGINNING.0, col: BEGINNING.1, index: 0, @@ -116,7 +111,7 @@ impl<'a> Reader<'a> { } } -impl<'a> Iterator for Reader<'a> { +impl Iterator for Reader { type Item = char; fn next(&mut self) -> Option {