Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix serde not compiling for struct with lifetime #70

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Ph0enixKM marked this conversation as resolved.
Show resolved Hide resolved
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
Loading