Skip to content

Commit

Permalink
minor changes due to integration
Browse files Browse the repository at this point in the history
  • Loading branch information
TommYDeeee committed Apr 8, 2024
1 parent 63e8b6a commit bc3a227
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/parser/grammar/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions src/syntax/ast/expr_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/ast/generated/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ impl ForExpr {
pub fn l_paren_token(&self) -> Option<SyntaxToken> {
support::token(&self.syntax, T!['('])
}
pub fn boolean_expr(&self) -> Option<BooleanExpr> {
pub fn expression(&self) -> Option<Expression> {
support::child(&self.syntax)
}
pub fn r_paren_token(&self) -> Option<SyntaxToken> {
Expand Down
2 changes: 1 addition & 1 deletion yara.ungram
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ ForExpr =
'for' Quantifier 'of' ('them' | PatternIdentTuple)
| 'for' Quantifier (IdentifierNode (',' IdentifierNode)*) 'in' Iterable
)
':' '(' BooleanExpr ')'
':' '(' Expression ')'

Quantifier =
'all'
Expand Down

0 comments on commit bc3a227

Please sign in to comment.