Static allocations

This commit is contained in:
2023-11-22 23:40:25 -06:00
parent 640ef91306
commit 33c28ceb4a
9 changed files with 86 additions and 12 deletions
+6
View File
@@ -19,6 +19,7 @@ impl AstNode for Expr {
.map_primary(|term| match term.as_rule() {
PestRule::number => Expr::Number(term.into_number()),
PestRule::alloc => Expr::New(Expr::from_pair(term.first()).into()),
PestRule::static_alloc => Expr::Static(Expr::from_pair(term.first()).into()),
PestRule::name => Expr::Name(String::from(term.as_str())),
PestRule::expr => Expr::from_pair(term),
PestRule::string => Self::String(term.into_quoted_string()),
@@ -275,4 +276,9 @@ mod test {
fn alloc() {
assert_eq!(Expr::from_str("new(8)"), Ok(Expr::New(8.into())));
}
#[test]
fn static_alloc() {
assert_eq!(Expr::from_str("static(8)"), Ok(Expr::Static(8.into())));
}
}
+2 -2
View File
@@ -63,9 +63,9 @@ operator = _{
}
expr = { prefix* ~ term ~ suffix* ~ (operator ~ prefix* ~ term ~ suffix*)* }
term = _{ number | alloc | name | "(" ~ expr ~ ")" | string }
term = _{ number | alloc | static_alloc | name | "(" ~ expr ~ ")" | string }
alloc = { "new" ~ "(" ~ expr ~ ")" }
static_alloc = { "static" ~ "(" ~ expr ~ ")" }
suffix = _{ subscript | arglist }
subscript = { "[" ~ expr ~ "]" }