Skip to content

Complete Grammar structure transformation in optimizer #70

@EffortlessSteven

Description

@EffortlessSteven

Summary

The IR optimizer has incomplete Grammar structure transformation code with a TODO comment indicating the implementation needs to be fixed for the new Grammar structure.

Location

  • File: ir/src/optimizer.rs
  • Line: 527-528
  • Code:
    // TODO: Fix this for new Grammar structure
    // grammar.rules.retain(|_, r| r.lhs \!= original_symbol);

Issue

The optimizer cannot properly transform grammar rules due to incomplete implementation. The commented-out code suggests this functionality existed but was disabled during a Grammar structure refactor.

Impact

  • Grammar optimizations may not work correctly
  • Left-recursion elimination may be incomplete
  • Could lead to incorrect parser generation

Proposed Solution

  1. Review the current Grammar structure and determine correct API
  2. Implement proper rule retention/removal logic
  3. Add tests to verify optimization correctness
  4. Update related optimization passes that may depend on this

Priority

High - This affects core grammar transformation functionality

Context

Found during codebase analysis. This appears to be a remnant from a Grammar structure refactor that wasn't fully completed.

Related Files

  • ir/src/lib.rs - Grammar structure definition
  • ir/src/optimizer.rs - Other optimization passes that may be affected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions