Skip to content

Refactor: Break up parse_statement.cpp (554 lines) #139

Description

@clank-hayen

Problem

parser/parse_statement.cpp is the largest file in the parser at 554 lines. While the parser already has good file separation (e.g., parse_if.cpp, parse_while.cpp, parse_for.cpp), parse_statement.cpp still contains significant inline logic that could be extracted:

  1. Generic type declarations (lines 150-232): Parsing of List<T>, Pair<T>, Tuple<T>, Channel<T> variable declarations
  2. Qualified function calls (lines 294-360): Complex logic for module.func() calls
  3. Method call statements (lines 370-450): obj.method() with error handling
  4. Field assignment (lines 450-500): obj.field = value parsing

Suggested Solution

Extract into smaller, focused files:

parser/
  parse_generic_type.cpp    # List<T>, Pair<T>, Tuple<T>, Channel<T> declarations
  parse_qualified.cpp       # module.func() and module.Type handling
  parse_member_access.cpp   # obj.method() and obj.field = value
  parse_statement.cpp       # Main dispatch (now much smaller)

This follows the existing pattern where parse_if.cpp, parse_for.cpp, etc. each handle their specific statement type.

Impact

  • Each file becomes more focused and easier to understand
  • Follows existing codebase patterns
  • Easier to test individual parsing components
  • Better separation of concerns

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions