pandaman64/lean-regex

Improve string formatting and debugging utilities

オープン

#96 opened on 2025/06/08

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)Lean (14 件のフォーク)auto 404
enhancementgood first issue

Repository metrics

Stars
 (109 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Improve string formatting and debugging utilities

Description

Enhance string representation and debugging utilities throughout the codebase to make development and troubleshooting easier.

Current State

Several types have basic ToString instances using reprStr, but could benefit from more user-friendly string representations.

Proposed Implementation

Improve ToString instances and add debugging utilities.

Areas for Improvement

  1. AST Pretty Printing (regex/Regex/Syntax/Ast.lean):

    • Add human-readable AST formatting
    • Show regex structure in a tree-like format
  2. NFA Visualization (regex/Regex/NFA/Basic.lean):

    • Add method to display NFA structure
    • Show state transitions in readable format
  3. Better Error Formatting:

    • Enhance existing error messages
    • Add color coding for terminal output (optional)
  4. Regex Pattern Display:

    • Add method to show compiled regex in readable form
    • Display capture group information

Implementation Steps

  1. Create new ToString instances that prioritize readability
  2. Add optional debugging methods (prefixed with debug_)
  3. Ensure formatting works well in both terminal and programmatic contexts
  4. Add examples in documentation

Files to Modify

  • regex/Regex/Syntax/Ast.lean - Better AST formatting
  • regex/Regex/NFA/Basic.lean - NFA visualization
  • Various files with ToString instances

Testing

  • Verify output is readable and helpful
  • Test with complex regex patterns
  • Ensure no performance impact on core functionality

Skills Required

  • Basic functional programming
  • String manipulation and formatting
  • Understanding of data structure visualization
  • No Lean theorem proving experience needed

Expected Outcome

Developers have better tools for understanding regex compilation and debugging issues, improving the development experience.

コントリビューターガイド