Derive Debug and Clone for tokens and parser state
This commit is contained in:
parent
312901ddf6
commit
8d204503a8
12 changed files with 18 additions and 13 deletions
|
|
@ -134,17 +134,19 @@ fn lex(text: &str, map: LexMap, config: &Config) -> Vec<Token> {
|
||||||
tokens
|
tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
context: Context,
|
context: Context,
|
||||||
dom_ids: HashMap<String, Vec<String>>,
|
dom_ids: HashMap<String, Vec<String>>,
|
||||||
buffers: Buffers,
|
buffers: Buffers,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
struct Buffers {
|
struct Buffers {
|
||||||
anchor: AnchorBuffer,
|
anchor: AnchorBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct AnchorBuffer {
|
struct AnchorBuffer {
|
||||||
candidate: Anchor,
|
candidate: Anchor,
|
||||||
text: String,
|
text: String,
|
||||||
|
|
@ -169,7 +171,7 @@ impl State {
|
||||||
dom_ids: HashMap::new(),
|
dom_ids: HashMap::new(),
|
||||||
buffers: Buffers {
|
buffers: Buffers {
|
||||||
anchor: AnchorBuffer {
|
anchor: AnchorBuffer {
|
||||||
candidate: Anchor::empty(),
|
candidate: Anchor::default(),
|
||||||
text: String::new(),
|
text: String::new(),
|
||||||
destination: String::new(),
|
destination: String::new(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,13 @@ use crate::syntax::content::parser::{
|
||||||
|
|
||||||
pub mod anchor;
|
pub mod anchor;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
pub block: Block,
|
pub block: Block,
|
||||||
pub inline: Inline,
|
pub inline: Inline,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub enum Block {
|
pub enum Block {
|
||||||
Paragraph,
|
Paragraph,
|
||||||
Header(u8),
|
Header(u8),
|
||||||
|
|
@ -17,6 +19,7 @@ pub enum Block {
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub enum Inline {
|
pub enum Inline {
|
||||||
Anchor,
|
Anchor,
|
||||||
Code,
|
Code,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ pub mod preformat;
|
||||||
pub mod code;
|
pub mod code;
|
||||||
pub mod oblique;
|
pub mod oblique;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
pub enum Token {
|
pub enum Token {
|
||||||
Anchor(anchor::Anchor),
|
Anchor(anchor::Anchor),
|
||||||
Code(code::Code),
|
Code(code::Code),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq, Default)]
|
||||||
pub struct Anchor {
|
pub struct Anchor {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub destination: Option<String>,
|
pub destination: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
syntax::content::{Parseable, Lexeme},
|
syntax::content::{Parseable, Lexeme},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Code {
|
pub struct Code {
|
||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
open: Option<bool>,
|
open: Option<bool>,
|
||||||
level: Level,
|
level: Level,
|
||||||
|
|
@ -112,7 +112,7 @@ impl Parseable for Header {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub enum Level {
|
pub enum Level {
|
||||||
One,
|
One,
|
||||||
Two,
|
Two,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
syntax::content::{Parseable, parser::lexeme::Lexeme},
|
syntax::content::{Parseable, parser::lexeme::Lexeme},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct LineBreak {}
|
pub struct LineBreak {}
|
||||||
|
|
||||||
impl Parseable for LineBreak {
|
impl Parseable for LineBreak {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Literal {
|
pub struct Literal {
|
||||||
text: String,
|
text: String,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
syntax::content::{Parseable, Lexeme},
|
syntax::content::{Parseable, Lexeme},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Oblique {
|
pub struct Oblique {
|
||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Paragraph {
|
pub struct Paragraph {
|
||||||
open: Option<bool>,
|
open: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
syntax::content::{Parseable, Lexeme},
|
syntax::content::{Parseable, Lexeme},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct PreFormat {
|
pub struct PreFormat {
|
||||||
open: Option<bool>,
|
open: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
open: Option<bool>,
|
open: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue