Summary
Implement the remaining bitwise and special operators: ^ (XOR), ~ (NOT/complement), and x (match any value).
Context
GNU file's magic format supports these operators for bit-level format detection:
^ (XOR) - Used for flag toggling and bitmask checks
~ (NOT/complement) - Used for inverted bit patterns
x (any value) - Matches any value at an offset (used to unconditionally output text, often in child rules)
Current state: Only =, !=, &, and &mask are implemented.
Acceptance Criteria
Impact
MEDIUM - x (any value) is particularly common in magic files for unconditional child rule output. XOR and NOT are less common but needed for full compatibility.
Files to Modify
src/parser/ast.rs - Extend Operator enum
src/parser/grammar.rs - Parse new operators
src/evaluator/operators.rs - Implement logic
References
Summary
Implement the remaining bitwise and special operators:
^(XOR),~(NOT/complement), andx(match any value).Context
GNU file's magic format supports these operators for bit-level format detection:
^(XOR) - Used for flag toggling and bitmask checks~(NOT/complement) - Used for inverted bit patternsx(any value) - Matches any value at an offset (used to unconditionally output text, often in child rules)Current state: Only
=,!=,&, and&maskare implemented.Acceptance Criteria
^,~,xoperatorsOperatorenum extended withBitwiseXor,BitwiseNot,AnyValuevariantsxoperator always returns true (matches any value)Impact
MEDIUM -
x(any value) is particularly common in magic files for unconditional child rule output. XOR and NOT are less common but needed for full compatibility.Files to Modify
src/parser/ast.rs- ExtendOperatorenumsrc/parser/grammar.rs- Parse new operatorssrc/evaluator/operators.rs- Implement logicReferences