diff --git a/src/dreammaker/ast.rs b/src/dreammaker/ast.rs index 18299629..a8070038 100644 --- a/src/dreammaker/ast.rs +++ b/src/dreammaker/ast.rs @@ -336,7 +336,7 @@ pub enum Expression { /// The unary operations applied to this value, in reverse order. unary: Vec, /// The term of the expression. - term: Spanned, + term: Box>, /// The follow operations applied to this value. follow: Vec>, }, @@ -486,7 +486,7 @@ impl From for Expression { term => Expression::Base { unary: vec![], follow: vec![], - term: Spanned::new(Default::default(), term), + term: Box::new(Spanned::new(Default::default(), term)), }, } } diff --git a/src/dreammaker/constants.rs b/src/dreammaker/constants.rs index 585929a7..b013f02e 100644 --- a/src/dreammaker/constants.rs +++ b/src/dreammaker/constants.rs @@ -760,12 +760,8 @@ impl<'a> ConstantFolder<'a> { if args.len() != 1 { return Err(self.error(format!("malformed defined() call, must have 1 argument and instead has {}", args.len()))); } - match args[0] { - Expression::Base { - ref unary, - term: Spanned { elem: Term::Ident(ref ident), .. }, - ref follow - } if unary.is_empty() && follow.is_empty() => { + match args[0].as_term() { + Some(Term::Ident(ref ident)) => { Constant::Int(if defines.contains_key(ident) { 1 } else { 0 }) }, _ => return Err(self.error("malformed defined() call, argument given isn't an Ident.")), diff --git a/src/dreammaker/parser.rs b/src/dreammaker/parser.rs index de9d765b..cc2de1a4 100644 --- a/src/dreammaker/parser.rs +++ b/src/dreammaker/parser.rs @@ -1879,7 +1879,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> { success(Expression::Base { unary: unary_ops, - term, + term: Box::new(term), follow, }) }