diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs index ac3e513..4e965d6 100644 --- a/src/parser/grammar/expressions.rs +++ b/src/parser/grammar/expressions.rs @@ -755,7 +755,6 @@ fn quantifier(p: &mut Parser) { } fn iterable(p: &mut Parser) { - let m = p.start(); match p.current() { T!['('] => { let n = p.start(); @@ -776,10 +775,11 @@ fn iterable(p: &mut Parser) { } } _ => { + let n = p.start(); expr(p, None, 1); + n.complete(p, NESTED_EXPR); } } - m.complete(p, ITERABLE); } fn boolean_expr_tuple(p: &mut Parser) { diff --git a/src/syntax/ast/expr_ext.rs b/src/syntax/ast/expr_ext.rs index 179578d..a5c95fb 100644 --- a/src/syntax/ast/expr_ext.rs +++ b/src/syntax/ast/expr_ext.rs @@ -174,6 +174,16 @@ impl ast::BooleanTermExpr { support::children(self.syntax()).nth(1) } } + +impl ast::VariableWildcard { + pub fn matches(&self, ident: &str) -> bool { + if self.star_token().is_some() { + ident.starts_with(self.variable_token().unwrap().text()) + } else { + ident == self.variable_token().unwrap().text() + } + } +} // //#[derive(Clone, Debug, PartialEq, Eq, Hash)] //pub enum LiteralKind { diff --git a/src/syntax/ast/generated/nodes.rs b/src/syntax/ast/generated/nodes.rs index 2a59172..b84a01e 100644 --- a/src/syntax/ast/generated/nodes.rs +++ b/src/syntax/ast/generated/nodes.rs @@ -580,7 +580,7 @@ impl ForExpr { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } - pub fn boolean_expr(&self) -> Option { + pub fn expression(&self) -> Option { support::child(&self.syntax) } pub fn r_paren_token(&self) -> Option { diff --git a/tests/test38.out b/tests/test38.out index a97d99a..4749812 100644 --- a/tests/test38.out +++ b/tests/test38.out @@ -33,18 +33,17 @@ SOURCE_FILE@0..120 WHITESPACE@79..80 " " IN_KW@80..82 "in" WHITESPACE@82..83 " " - ITERABLE@83..90 - EXPR_TUPLE@83..90 - L_PAREN@83..84 "(" - PRIMARY_EXPR@84..85 - INT_LIT@84..85 "1" - COMMA@85..86 "," - PRIMARY_EXPR@86..87 - INT_LIT@86..87 "2" - COMMA@87..88 "," - PRIMARY_EXPR@88..89 - INT_LIT@88..89 "3" - R_PAREN@89..90 ")" + EXPR_TUPLE@83..90 + L_PAREN@83..84 "(" + PRIMARY_EXPR@84..85 + INT_LIT@84..85 "1" + COMMA@85..86 "," + PRIMARY_EXPR@86..87 + INT_LIT@86..87 "2" + COMMA@87..88 "," + PRIMARY_EXPR@88..89 + INT_LIT@88..89 "3" + R_PAREN@89..90 ")" WHITESPACE@90..91 " " COLON@91..92 ":" WHITESPACE@92..93 " " diff --git a/yara.ungram b/yara.ungram index 7d9e230..d022405 100644 --- a/yara.ungram +++ b/yara.ungram @@ -203,7 +203,7 @@ ForExpr = 'for' Quantifier 'of' ('them' | PatternIdentTuple) | 'for' Quantifier (IdentifierNode (',' IdentifierNode)*) 'in' Iterable ) - ':' '(' BooleanExpr ')' + ':' '(' Expression ')' Quantifier = 'all'