summaryrefslogtreecommitdiffstats
path: root/crates/rebel-parse/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rebel-parse/src/ast.rs')
-rw-r--r--crates/rebel-parse/src/ast.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/rebel-parse/src/ast.rs b/crates/rebel-parse/src/ast.rs
index 389523e..ef27ecf 100644
--- a/crates/rebel-parse/src/ast.rs
+++ b/crates/rebel-parse/src/ast.rs
@@ -132,16 +132,16 @@ pub struct FuncParam<'a> {
pub typ: Expr<'a>,
}
-pub use token::StringKind;
+pub use token::StrKind;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Literal<'a> {
Unit,
- Boolean(bool),
- Integer(u64),
- String {
- pieces: Vec<StringPiece<'a>>,
- kind: StringKind,
+ Bool(bool),
+ Int(u64),
+ Str {
+ pieces: Vec<StrPiece<'a>>,
+ kind: StrKind,
},
Tuple(Vec<Expr<'a>>),
Array(Vec<Expr<'a>>),
@@ -161,27 +161,27 @@ impl<'a> Literal<'a> {
};
let digits = rest.replace('_', "");
let value = u64::from_str_radix(&digits, radix).or(Err("number"))?;
- Ok(Literal::Integer(value))
+ Ok(Literal::Int(value))
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
-pub enum StringPiece<'a> {
+pub enum StrPiece<'a> {
Chars(&'a str),
Escape(char),
Interp(Expr<'a>),
}
-impl<'a> TryFrom<&token::StringPiece<'a>> for StringPiece<'a> {
+impl<'a> TryFrom<&token::StrPiece<'a>> for StrPiece<'a> {
type Error = &'static str;
- fn try_from(value: &token::StringPiece<'a>) -> Result<Self, Self::Error> {
+ fn try_from(value: &token::StrPiece<'a>) -> Result<Self, Self::Error> {
use crate::recipe;
Ok(match value {
- token::StringPiece::Chars(chars) => StringPiece::Chars(chars),
- token::StringPiece::Escape(c) => StringPiece::Escape(*c),
- token::StringPiece::Interp(tokens) => StringPiece::Interp(
+ token::StrPiece::Chars(chars) => StrPiece::Chars(chars),
+ token::StrPiece::Escape(c) => StrPiece::Escape(*c),
+ token::StrPiece::Interp(tokens) => StrPiece::Interp(
recipe::expr(tokens).or(Err("Invalid expression in string interpolation"))?,
),
})