diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-07-01 16:00:06 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-07-31 10:27:15 +0200 |
commit | e40e93796f45d34d038c6a20c4b034eb3b384b12 (patch) | |
tree | ff717ff9781c943f87715d7c8385a9af01fde3a9 /askama_derive/src/parser/node.rs | |
parent | bdb6c0b89df5099fe6cf2e79e04e0efd21f64aa8 (diff) | |
download | askama-e40e93796f45d34d038c6a20c4b034eb3b384b12.tar.gz askama-e40e93796f45d34d038c6a20c4b034eb3b384b12.tar.bz2 askama-e40e93796f45d34d038c6a20c4b034eb3b384b12.zip |
Extract askama_parser crate
Diffstat (limited to '')
-rw-r--r-- | askama_parser/src/node.rs (renamed from askama_derive/src/parser/node.rs) | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/askama_derive/src/parser/node.rs b/askama_parser/src/node.rs index ce303bc..8719d38 100644 --- a/askama_derive/src/parser/node.rs +++ b/askama_parser/src/node.rs @@ -16,7 +16,7 @@ use super::{ }; #[derive(Debug, PartialEq)] -pub(crate) enum Node<'a> { +pub enum Node<'a> { Lit(&'a str, &'a str, &'a str), Comment(Ws), Expr(Ws, Expr<'a>), @@ -37,7 +37,7 @@ pub(crate) enum Node<'a> { } #[derive(Debug, PartialEq)] -pub(crate) enum Target<'a> { +pub enum Target<'a> { Name(&'a str), Tuple(Vec<&'a str>, Vec<Target<'a>>), Struct(Vec<&'a str>, Vec<(&'a str, Target<'a>)>), @@ -49,46 +49,46 @@ pub(crate) enum Target<'a> { } #[derive(Clone, Copy, Debug, PartialEq)] -pub(crate) enum Whitespace { +pub enum Whitespace { Preserve, Suppress, Minimize, } #[derive(Debug, PartialEq)] -pub(crate) struct Loop<'a> { - pub(crate) ws1: Ws, - pub(crate) var: Target<'a>, - pub(crate) iter: Expr<'a>, - pub(crate) cond: Option<Expr<'a>>, - pub(crate) body: Vec<Node<'a>>, - pub(crate) ws2: Ws, - pub(crate) else_block: Vec<Node<'a>>, - pub(crate) ws3: Ws, +pub struct Loop<'a> { + pub ws1: Ws, + pub var: Target<'a>, + pub iter: Expr<'a>, + pub cond: Option<Expr<'a>>, + pub body: Vec<Node<'a>>, + pub ws2: Ws, + pub else_block: Vec<Node<'a>>, + pub ws3: Ws, } -pub(crate) type When<'a> = (Ws, Target<'a>, Vec<Node<'a>>); +pub type When<'a> = (Ws, Target<'a>, Vec<Node<'a>>); #[derive(Debug, PartialEq)] -pub(crate) struct Macro<'a> { - pub(crate) ws1: Ws, - pub(crate) args: Vec<&'a str>, - pub(crate) nodes: Vec<Node<'a>>, - pub(crate) ws2: Ws, +pub struct Macro<'a> { + pub ws1: Ws, + pub args: Vec<&'a str>, + pub nodes: Vec<Node<'a>>, + pub ws2: Ws, } /// First field is "minus/plus sign was used on the left part of the item". /// /// Second field is "minus/plus sign was used on the right part of the item". #[derive(Clone, Copy, Debug, PartialEq)] -pub(crate) struct Ws(pub(crate) Option<Whitespace>, pub(crate) Option<Whitespace>); +pub struct Ws(pub Option<Whitespace>, pub Option<Whitespace>); -pub(crate) type Cond<'a> = (Ws, Option<CondTest<'a>>, Vec<Node<'a>>); +pub type Cond<'a> = (Ws, Option<CondTest<'a>>, Vec<Node<'a>>); #[derive(Debug, PartialEq)] -pub(crate) struct CondTest<'a> { - pub(crate) target: Option<Target<'a>>, - pub(crate) expr: Expr<'a>, +pub struct CondTest<'a> { + pub target: Option<Target<'a>>, + pub expr: Expr<'a>, } impl Node<'_> { |