summaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-26 00:37:59 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-26 00:39:28 +0200
commita4470a2e26fc4cf43e9af80d741c68c58383f3c6 (patch)
tree0f130dd5e1e70e98693c1890b89b075e17c30625 /crates
parent175c790cc730c01283c1aa0cf65cfce8c7152d4b (diff)
downloadrebel-a4470a2e26fc4cf43e9af80d741c68c58383f3c6.tar
rebel-a4470a2e26fc4cf43e9af80d741c68c58383f3c6.zip
rebel-parse: ast: store string kind again
We need the kind after all, as different string kinds will need different escaping for interpolation.
Diffstat (limited to 'crates')
-rw-r--r--crates/rebel-parse/src/ast.rs7
-rw-r--r--crates/rebel-parse/src/grammar/recipe.rs9
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(')') {