diff options
-rw-r--r-- | crates/rebel-parse/src/ast.rs | 9 | ||||
-rw-r--r-- | crates/rebel-parse/src/grammar/recipe.rs | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/crates/rebel-parse/src/ast.rs b/crates/rebel-parse/src/ast.rs index c7ddb7a..f9943d4 100644 --- a/crates/rebel-parse/src/ast.rs +++ b/crates/rebel-parse/src/ast.rs @@ -135,7 +135,7 @@ pub enum Literal<'a> { Unit, Boolean(bool), Integer(u64), - String(&'a str), + String(Vec<StringPiece<'a>>), Tuple(Vec<Expr<'a>>), Array(Vec<Expr<'a>>), Map(Vec<MapEntry<'a>>), @@ -158,6 +158,13 @@ impl<'a> Literal<'a> { } } +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum StringPiece<'a> { + Chars(&'a str), + Escape(char), + Interp(Expr<'a>), +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct MapEntry<'a> { pub key: &'a str, diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index 633b021..6bd96bb 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -98,7 +98,8 @@ peg::parser! { ast::Literal::number(content) } / [Token::String(String { content, .. })] { - ast::Literal::String(content) + let ast_pieces = vec![ast::StringPiece::Chars(content)]; + ast::Literal::String(ast_pieces) } / p('(') p(')') { ast::Literal::Unit } / p('(') elements:(expr() ** p(',')) p(',')? p(')') { |