diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rebel-parse/src/ast.rs | 7 | ||||
-rw-r--r-- | crates/rebel-parse/src/grammar/recipe.rs | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/crates/rebel-parse/src/ast.rs b/crates/rebel-parse/src/ast.rs index 648a79e..389523e 100644 --- a/crates/rebel-parse/src/ast.rs +++ b/crates/rebel-parse/src/ast.rs @@ -132,12 +132,17 @@ pub struct FuncParam<'a> { pub typ: Expr<'a>, } +pub use token::StringKind; + #[derive(Debug, Clone, PartialEq, Eq)] pub enum Literal<'a> { Unit, Boolean(bool), Integer(u64), - String(Vec<StringPiece<'a>>), + String { + pieces: Vec<StringPiece<'a>>, + kind: StringKind, + }, Tuple(Vec<Expr<'a>>), Array(Vec<Expr<'a>>), Map(Vec<MapEntry<'a>>), diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index 49b1689..9b79d41 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -97,9 +97,12 @@ peg::parser! { / [Token::Number(content)] { ? ast::Literal::number(content) } - / [Token::String(String { pieces, .. })] { ? - let ast_pieces = pieces.iter().map(|piece| piece.try_into()).collect::<Result<_, _>>()?; - Ok(ast::Literal::String(ast_pieces)) + / [Token::String(String { pieces, kind })] { ? + let pieces = pieces + .iter() + .map(|piece| piece.try_into()) + .collect::<Result<_, _>>()?; + Ok(ast::Literal::String{ pieces, kind: *kind }) } / p('(') p(')') { ast::Literal::Unit } / p('(') elements:(expr() ** p(',')) p(',')? p(')') { |