-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support percent notation in grammar. #43
Conversation
Add support for "x% of them" notation to gyp. While I was here I noticed that the protobuf generated code was being put into the github.com/VirusTotal/gyp/pb directory, which was causing various problems when trying to build things as they all expected to find the protobuf related code in the pb/ directory. To deal with this I modified the Makefile so that the protobuf generated code is going in the pb/ directory yet the go_package remains as github.com/VirusTotal/gyp/pb. I'm not sure if this is going to cause problems with builds of other things using bazel that depend upon this so it may be good to get @Zohiartze to review this so we can avoid a repeat of VirusTotal#42.
parser/grammar.y
Outdated
@@ -824,6 +824,13 @@ expression | |||
Strings: $3, | |||
} | |||
} | |||
| primary_expression '%' _OF_ string_set | |||
{ | |||
$$ = &ast.PercentOf{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we do in the yara compiler is validate that if the percentage is defined that it is between 1 and 100 (inclusive). I'm not doing that here but I suspect I should.
Instead of creating a new expression
|
@wxsBSD thank you for the fix and the heads up, as of my tests everything is all right with bazel 👍 |
Sorry for the delay, been a bit burnt out and unable to bring myself to finish this work the past week. I think I can get it done though...
To be clear, you're talking about making a new |
No, the What I mean is having a special kind of In turn, type Percentage struct {
Expression
} This way I'm not sure if my explanation is clear enough, do you get what I mean? |
This way you don't need to change the existing |
I think I understand this now. I will take a shot at this in the next couple of days and update this PR. |
The
The
I know you said Turns out that trying to learn golang while hacking on abstract things like this is difficult. ;) |
The quantifier := &Quantifier{KeywordAll}
quantifier := &Quantifier{&LiteralInteger{Value: 1}} Similarly you could do: type Percentage struct {
Expression
}
quantifier := &Quantifier{&Percentage{&LiteralInteger{Value: 1}}} When you say |
Address comments from Victor, which I understand conceptually but may have implemented in a weird way. ;)
Sorry for the delay, I didn't see your response until a few days ago but I think I finally got it. This is ready for review now. |
@@ -971,6 +973,14 @@ string_enumeration_item | |||
; | |||
|
|||
|
|||
percent_expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
percent_expression
is not needed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this clause in bd33cde
Add support for "x% of them" notation to gyp.
While I was here I noticed that the protobuf generated code was being put into
the github.com/VirusTotal/gyp/pb directory, which was causing various problems
when trying to build things as they all expected to find the protobuf related
code in the pb/ directory. To deal with this I modified the Makefile so that the
protobuf generated code is going in the pb/ directory yet the go_package remains
as github.com/VirusTotal/gyp/pb. I'm not sure if this is going to cause problems
with builds of other things using bazel that depend upon this so it may be good
to get @Zohiartze to review this so we can avoid a repeat of #42.