aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askama_derive/Cargo.toml3
-rw-r--r--askama_derive/src/generator.rs8
-rw-r--r--askama_derive/src/lib.rs6
-rw-r--r--askama_shared/Cargo.toml3
-rw-r--r--askama_shared/src/lib.rs1
-rw-r--r--askama_shared/src/parser.rs (renamed from askama_derive/src/parser.rs)6
6 files changed, 11 insertions, 16 deletions
diff --git a/askama_derive/Cargo.toml b/askama_derive/Cargo.toml
index 799f989..8b77d12 100644
--- a/askama_derive/Cargo.toml
+++ b/askama_derive/Cargo.toml
@@ -21,9 +21,6 @@ warp = []
[dependencies]
askama_shared = { version = "0.9", path = "../askama_shared" }
-# default for features for nom don't work result in linker errors:
-# https://github.com/rust-lang/rust/issues/62146
-nom = { version = "5", default-features = false, features = ["std"] }
proc-macro2 = "1"
quote = "1"
syn = "1"
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index ab1a012..4f5b495 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -1,9 +1,9 @@
use super::{get_template_source, Context, Heritage};
use crate::input::{Source, TemplateInput};
-use crate::parser::{
- Cond, Expr, MatchParameter, MatchParameters, MatchVariant, Node, Target, When, WS,
-};
use askama_shared::filters;
+use askama_shared::parser::{
+ parse, Cond, Expr, MatchParameter, MatchParameters, MatchVariant, Node, Target, When, WS,
+};
use proc_macro2::Span;
@@ -15,8 +15,6 @@ use std::{cmp, hash, mem, str};
use syn;
-use crate::parser::parse;
-
pub(crate) fn generate(
input: &TemplateInput,
contexts: &HashMap<&PathBuf, Context>,
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index 97228fd..2189458 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -1,19 +1,15 @@
extern crate proc_macro;
#[macro_use]
-extern crate nom;
-#[macro_use]
extern crate quote;
mod generator;
mod input;
-mod parser;
use crate::input::{Print, Source, TemplateInput};
-use crate::parser::{Expr, Macro, Node};
+use askama_shared::parser::{parse, Expr, Macro, Node};
use askama_shared::{read_config_file, Config};
use proc_macro::TokenStream;
-use crate::parser::parse;
use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
diff --git a/askama_shared/Cargo.toml b/askama_shared/Cargo.toml
index aefe539..19d3274 100644
--- a/askama_shared/Cargo.toml
+++ b/askama_shared/Cargo.toml
@@ -18,6 +18,9 @@ yaml = ["serde", "serde_yaml"]
[dependencies]
askama_escape = { version = "0.3.0", path = "../askama_escape" }
humansize = { version = "1.1.0", optional = true }
+# default for features for nom don't work result in linker errors:
+# https://github.com/rust-lang/rust/issues/62146
+nom = { version = "5", default-features = false, features = ["std"] }
num-traits = { version = "0.2.6", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
serde_derive = { version = "1.0", optional = true }
diff --git a/askama_shared/src/lib.rs b/askama_shared/src/lib.rs
index 8a64c22..b2f1271 100644
--- a/askama_shared/src/lib.rs
+++ b/askama_shared/src/lib.rs
@@ -16,6 +16,7 @@ mod error;
pub use crate::error::{Error, Result};
pub mod filters;
pub mod helpers;
+pub mod parser;
#[derive(Debug)]
pub struct Config<'a> {
diff --git a/askama_derive/src/parser.rs b/askama_shared/src/parser.rs
index 910815a..9c3358e 100644
--- a/askama_derive/src/parser.rs
+++ b/askama_shared/src/parser.rs
@@ -5,10 +5,10 @@ use nom::combinator::{complete, map, opt};
use nom::error::ParseError;
use nom::multi::{many0, many1, separated_list, separated_nonempty_list};
use nom::sequence::{delimited, pair, tuple};
-use nom::{self, Compare, IResult, InputTake};
+use nom::{self, error_position, Compare, IResult, InputTake};
use std::str;
-use askama_shared::Syntax;
+use crate::Syntax;
#[derive(Debug)]
pub enum Expr<'a> {
@@ -1042,7 +1042,7 @@ pub fn parse<'a>(src: &'a str, syntax: &'a Syntax<'a>) -> Vec<Node<'a>> {
#[cfg(test)]
mod tests {
- use askama_shared::Syntax;
+ use crate::Syntax;
fn check_ws_split(s: &str, res: &(&str, &str, &str)) {
let node = super::split_ws_parts(s.as_bytes());