From 35ada4a21d5850dd7682a48bf71ff12a79a98644 Mon Sep 17 00:00:00 2001 From: Alain Zscheile Date: Mon, 22 May 2023 21:07:32 +0200 Subject: [PATCH] split expression types --- crates/wafl-parser/src/parser.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/crates/wafl-parser/src/parser.rs b/crates/wafl-parser/src/parser.rs index 7d00a5c..637b54d 100644 --- a/crates/wafl-parser/src/parser.rs +++ b/crates/wafl-parser/src/parser.rs @@ -35,7 +35,10 @@ pub struct Entry { #[derive(Clone, Debug)] pub enum Expression { Code { - cfe: bool, + data: Box<[Expression]>, + ret: Option>, + }, + CodeCfe { data: Box<[Expression]>, ret: Option>, }, @@ -47,6 +50,10 @@ pub enum Expression { obj: Box, args: BTreeMap, (Location, Expression)>, }, + Tag { + obj: Box, + args: BTreeMap, (Location, Expression)>, + }, } #[derive(Clone, Debug)] @@ -201,10 +208,16 @@ impl Expression { break; } } - Ok(Expression::Code { - cfe, - data: codata.into_boxed_slice(), - ret, + Ok(if cfe { + Expression::CodeCfe { + data: codata.into_boxed_slice(), + ret, + } + } else { + Expression::Code { + data: codata.into_boxed_slice(), + ret, + } }) } Some(&(loc, _)) if cfe => Err(Error { @@ -329,7 +342,7 @@ impl Module { let obj = if ctx.maybe_eat_token(Token::Assign).is_some() { let obj = Expression::parse_high(ctx)?; - if let Expression::Code { cfe: true, .. } = obj { + if let Expression::CodeCfe { .. } = obj { flags |= EntryFlags::CTRLFE; } Some(obj)