Skip to content

Commit

Permalink
fix serde not compiling for struct with lifetime (#70)
Browse files Browse the repository at this point in the history
* fix serde not compiling for struct with lifetime

* remove serde from them lexer reader compiler classes

* Update src/compiling/lexing/lexer.rs

Co-authored-by: Phoenix Himself <[email protected]>

---------

Co-authored-by: Phoenix Himself <[email protected]>
  • Loading branch information
b1ek and Ph0enixKM authored Nov 20, 2024
1 parent e9e6d99 commit c71397d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/compiling/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 2 additions & 7 deletions src/compiling/lexing/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Token>,
region_handler: RegionHandler,
compound_handler: CompoundHandler,
Expand Down
17 changes: 6 additions & 11 deletions src/compiling/lexing/reader.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<Self::Item> {
Expand Down

0 comments on commit c71397d

Please sign in to comment.