Static allocations
This commit is contained in:
@@ -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())));
|
||||
}
|
||||
}
|
||||
@@ -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 ~ "]" }
|
||||
|
||||
Reference in New Issue
Block a user