Skip to content

Evaluator: implement relative offset resolution #38

@unclesp1d3r

Description

@unclesp1d3r

Summary

Implement evaluation of relative offsets. The AST representation (OffsetSpec::Relative) already exists, but the evaluator returns a "not yet implemented" error at src/evaluator/offset.rs:167.

Context

Relative offsets use the syntax &+N or &-N to reference positions relative to the end of the previous match. This enables sequential field parsing where each field follows the previous one without hardcoding absolute positions.

Current state: AST variant defined, evaluation stubbed with TODO.

Acceptance Criteria

  • resolve_offset() handles OffsetSpec::Relative using the previous match's end position
  • Evaluation context tracks the current match position for relative offset resolution
  • Positive and negative relative offsets work correctly
  • Bounds checking prevents out-of-buffer access
  • Unit tests for relative offset resolution
  • Integration tests with nested rules using relative offsets

Impact

MEDIUM-HIGH - Used in nested rule structures where child rules reference positions relative to parent matches.

Files to Modify

  • src/evaluator/offset.rs - Implement relative resolution (line ~167)
  • src/evaluator/mod.rs - Track match position in evaluation context

References

Metadata

Metadata

Assignees

Labels

compatibilitylibmagic compatibility and migrationenhancementNew feature or requestevaluatorRule evaluation engine and logicpriority: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