Move the structs into the token module.
This commit is contained in:
		
							parent
							
								
									8211e1043f
								
							
						
					
					
						commit
						2def475337
					
				| @ -1,5 +1,3 @@ | ||||
| use crate::parser::parser_with_context::parser_with_context; | ||||
| 
 | ||||
| use super::combinator::context_many_till; | ||||
| use super::error::CustomError; | ||||
| use super::error::MyError; | ||||
| @ -9,11 +7,12 @@ use super::parser_context::ContextElement; | ||||
| use super::parser_context::ExitMatcherNode; | ||||
| use super::text::symbol; | ||||
| use super::text::text_element; | ||||
| use super::text::Bold; | ||||
| use super::text::TextElement; | ||||
| use super::token::Bold; | ||||
| use super::token::TextElement; | ||||
| use super::token::Token; | ||||
| use super::util::in_section; | ||||
| use super::Context; | ||||
| use crate::parser::parser_with_context::parser_with_context; | ||||
| use nom::branch::alt; | ||||
| use nom::bytes::complete::tag; | ||||
| use nom::combinator::map; | ||||
|  | ||||
| @ -2,9 +2,8 @@ | ||||
| use super::combinator::context_many1; | ||||
| use super::error::Res; | ||||
| use super::paragraph::paragraph; | ||||
| use super::parser_context::ContextElement; | ||||
| use super::parser_context::ContextTree; | ||||
| use super::text::Paragraph; | ||||
| use super::token::Paragraph; | ||||
| use super::token::Token; | ||||
| use super::Context; | ||||
| use nom::IResult; | ||||
|  | ||||
| @ -9,8 +9,8 @@ use super::parser_context::ContextElement; | ||||
| use super::parser_context::ExitMatcherNode; | ||||
| use super::text::symbol; | ||||
| use super::text::text_element; | ||||
| use super::text::Link; | ||||
| use super::text::TextElement; | ||||
| use super::token::Link; | ||||
| use super::token::TextElement; | ||||
| use super::util::in_section; | ||||
| use super::Context; | ||||
| use nom::combinator::map; | ||||
|  | ||||
| @ -6,8 +6,8 @@ use super::parser_context::ExitMatcherNode; | ||||
| use super::text::blank_line; | ||||
| use super::text::line_break; | ||||
| use super::text::text_element; | ||||
| use super::text::Paragraph; | ||||
| use super::text::TextElement; | ||||
| use super::token::Paragraph; | ||||
| use super::token::TextElement; | ||||
| use super::token::Token; | ||||
| use super::Context; | ||||
| use nom::branch::alt; | ||||
|  | ||||
| @ -12,64 +12,14 @@ use super::bold::bold; | ||||
| use super::error::Res; | ||||
| use super::link::link; | ||||
| use super::parser_with_context::parser_with_context; | ||||
| use super::token::BlankLine; | ||||
| use super::token::LineBreak; | ||||
| use super::token::Space; | ||||
| use super::token::Span; | ||||
| use super::token::Symbol; | ||||
| use super::token::TextElement; | ||||
| use super::Context; | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub enum TextElement<'a> { | ||||
|     Span(Span<'a>), | ||||
|     Space(Space<'a>), | ||||
|     LineBreak(LineBreak<'a>), | ||||
|     Symbol(Symbol<'a>), | ||||
|     Bold(Bold<'a>), | ||||
|     Link(Link<'a>), | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Span<'a> { | ||||
|     contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Space<'a> { | ||||
|     contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct LineBreak<'a> { | ||||
|     contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Symbol<'a> { | ||||
|     contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct BlankLine<'a> { | ||||
|     contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Sequence<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Bold<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Link<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Paragraph<'a> { | ||||
|     pub contents: Vec<TextElement<'a>>, | ||||
|     pub paragraph_end: &'a str, | ||||
| } | ||||
| 
 | ||||
| pub fn line_break(input: &str) -> Res<&str, LineBreak> { | ||||
|     map(line_ending, |s: &str| LineBreak { contents: s })(input) | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,3 @@ | ||||
| use super::text::Paragraph; | ||||
| use super::text::TextElement; | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub enum Token<'a> { | ||||
|     TextElement(TextElement<'a>), | ||||
| @ -18,3 +15,59 @@ impl<'a> Into<Token<'a>> for Paragraph<'a> { | ||||
|         Token::Paragraph(self) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub enum TextElement<'a> { | ||||
|     Span(Span<'a>), | ||||
|     Space(Space<'a>), | ||||
|     LineBreak(LineBreak<'a>), | ||||
|     Symbol(Symbol<'a>), | ||||
|     Bold(Bold<'a>), | ||||
|     Link(Link<'a>), | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Span<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Space<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct LineBreak<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Symbol<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct BlankLine<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Sequence<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Bold<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Link<'a> { | ||||
|     pub contents: &'a str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Paragraph<'a> { | ||||
|     pub contents: Vec<TextElement<'a>>, | ||||
|     pub paragraph_end: &'a str, | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander