aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ast/parser.go
diff options
context:
space:
mode:
authorJiao, Joey <quic_jiangenj@quicinc.com>2024-11-06 13:41:21 +0800
committerAleksandr Nogikh <nogikh@google.com>2024-11-13 11:16:59 +0000
commit4dfba277487a7023ab9f5783302da4a9b5e9bef8 (patch)
tree72c5a0b86f7e38922230b4421ebe50c5654e5cdc /pkg/ast/parser.go
parentbb3f84250514d5990939e57b5d1ff8badc566033 (diff)
all: support || operator in syzlang if condition
ex. f3 field has logic or operator in if condition: conditional_struct { mask int32 f1 field1 (if[value[mask] & FIELD_FLAG1]) f2 int64 (if[value[mask] & FIELD_FLAG2]) f3 int64 (if[value[mask] == FIELD_FLAG1 || value[mask] == FIELD_FLAG2]) } [packed]
Diffstat (limited to 'pkg/ast/parser.go')
-rw-r--r--pkg/ast/parser.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/pkg/ast/parser.go b/pkg/ast/parser.go
index 839d8e6d6..273a4889f 100644
--- a/pkg/ast/parser.go
+++ b/pkg/ast/parser.go
@@ -438,17 +438,18 @@ type operatorInfo struct {
prio int
}
-const maxOperatorPrio = 1
+const maxOperatorPrio = 2
// The highest priority is 0.
var binaryOperators = map[token]operatorInfo{
- tokCmpEq: {op: OperatorCompareEq, prio: 0},
- tokCmpNeq: {op: OperatorCompareNeq, prio: 0},
- tokBinAnd: {op: OperatorBinaryAnd, prio: 1},
+ tokOr: {op: OperatorOr, prio: 0},
+ tokCmpEq: {op: OperatorCompareEq, prio: 1},
+ tokCmpNeq: {op: OperatorCompareNeq, prio: 1},
+ tokBinAnd: {op: OperatorBinaryAnd, prio: 2},
}
// Parse out a single Type object, which can either be a plain object or an expression.
-// For now, only expressions constructed via '(', ')', "==", "!=", '&' are supported.
+// For now, only expressions constructed via '(', ')', "==", "!=", '&', '||' are supported.
func (p *parser) parseType() *Type {
return p.parseBinaryExpr(0)
}