Skip to content

Parser: implement quad (64-bit integer) type with endian variants #36

@unclesp1d3r

Description

@unclesp1d3r

Summary

Implement the quad type (64-bit integer) and its endianness variants: quad, lequad, bequad.

Context

64-bit integer fields are essential for modern file formats. Many binary formats store sizes, offsets, and identifiers as 64-bit values.

Current state: Only byte (8-bit), short (16-bit), long (32-bit), and string types are implemented.

Acceptance Criteria

  • TypeKind enum extended with Quad variant
  • Parser recognizes quad, lequad, bequad type specifiers
  • read_quad() function in evaluator/types.rs reads 8 bytes with correct endianness
  • All operators work with quad values (=, !=, &, and future comparison operators)
  • Overflow-safe arithmetic for 64-bit values
  • Unit tests for each endian variant
  • Integration tests with real magic rules

Impact

HIGH - Required for modern binary formats, large file handling, and 64-bit timestamp fields.

Files to Modify

  • src/parser/ast.rs - Extend TypeKind enum
  • src/parser/grammar.rs - Parse quad type specifiers
  • src/evaluator/types.rs - Implement read_quad()
  • src/evaluator/operators.rs - Ensure operator support for u64/i64

References

Metadata

Metadata

Assignees

Labels

compatibilitylibmagic compatibility and migrationenhancementNew feature or requestevaluatorRule evaluation engine and logicparserMagic file parsing components and grammarpriority:highImportant, significant compatibility or architecture impact
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions