Transition to new literals compiling.

Tests still need work, as does the implementation for json.
This commit is contained in:
Tom Alexander
2020-05-16 22:30:04 -04:00
parent bc25c1ee16
commit c905e705ff
5 changed files with 21 additions and 126 deletions

View File

@@ -7,6 +7,7 @@ pub use parser::Body;
pub use parser::DustTag;
pub use parser::Filter;
pub use parser::KVPair;
pub use parser::OwnedLiteral;
pub use parser::RValue;
pub use parser::Special;
pub use parser::Template;

View File

@@ -118,11 +118,16 @@ pub struct Partial<'a> {
pub params: Vec<KVPair<'a>>,
}
#[derive(Clone, Debug, PartialEq)]
pub enum OwnedLiteral {
LString(String),
LPositiveInteger(u64),
}
#[derive(Clone, Debug, PartialEq)]
pub enum RValue<'a> {
RVPath(Path<'a>),
RVString(String),
RVPositiveInteger(u64),
RVLiteral(OwnedLiteral),
}
#[derive(Clone, Debug, PartialEq)]
@@ -226,8 +231,12 @@ fn postitive_integer_literal(i: &str) -> IResult<&str, u64> {
fn rvalue(i: &str) -> IResult<&str, RValue> {
alt((
map(path, RValue::RVPath),
map(quoted_string, RValue::RVString),
map(postitive_integer_literal, RValue::RVPositiveInteger),
map(quoted_string, |s| {
RValue::RVLiteral(OwnedLiteral::LString(s))
}),
map(postitive_integer_literal, |num| {
RValue::RVLiteral(OwnedLiteral::LPositiveInteger(num))
}),
))(i)
}