From 4c8c773c84a48963e892c72f38f37bcb99b6eb74 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 3 Jan 2017 10:01:16 +0100 Subject: Rename askama_codegen to askama_derive This appears to be best practice for crates using macros 1.1. --- askama_codegen/src/parser.rs | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 askama_codegen/src/parser.rs (limited to 'askama_codegen/src/parser.rs') diff --git a/askama_codegen/src/parser.rs b/askama_codegen/src/parser.rs deleted file mode 100644 index 5f3f8c5..0000000 --- a/askama_codegen/src/parser.rs +++ /dev/null @@ -1,43 +0,0 @@ -use nom::{self, IResult}; - -pub enum Expr<'a> { - Var(&'a [u8]), -} - -pub enum Node<'a> { - Lit(&'a [u8]), - Expr(Expr<'a>), -} - -fn take_content(i: &[u8]) -> IResult<&[u8], Node> { - if i.len() < 1 || i[0] == b'{' { - return IResult::Error(error_position!(nom::ErrorKind::TakeUntil, i)); - } - for (j, c) in i.iter().enumerate() { - if *c == b'{' { - if i.len() < j + 2 { - return IResult::Done(&i[..0], Node::Lit(&i[..])); - } else if i[j + 1] == '{' as u8 { - return IResult::Done(&i[j..], Node::Lit(&i[..j])); - } else if i[j + 1] == '%' as u8 { - return IResult::Done(&i[j..], Node::Lit(&i[..j])); - } - } - } - IResult::Done(&i[..0], Node::Lit(&i[..])) -} - -named!(expr_var, map!(ws!(nom::alphanumeric), Expr::Var)); - -named!(any_expr, delimited!(tag!("{{"), expr_var, tag!("}}"))); - -named!(expr_node, map!(any_expr, Node::Expr)); - -named!(parse_template< Vec >, many1!(alt!(take_content | expr_node))); - -pub fn parse<'a>(src: &'a str) -> Vec { - match parse_template(src.as_bytes()) { - IResult::Done(_, res) => res, - _ => panic!("problems parsing template source"), - } -} -- cgit