pandaman64/lean-regex

Improve string formatting and debugging utilities

开放

#96 创建于 2025年6月8日

 (2 条评论) (0 个反应) (0 位负责人)Lean (14 个派生)auto 404
enhancementgood first issue

仓库指标

星标
 (109 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南