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:
- Generic type declarations (lines 150-232): Parsing of
List<T>, Pair<T>, Tuple<T>, Channel<T> variable declarations
- Qualified function calls (lines 294-360): Complex logic for
module.func() calls
- Method call statements (lines 370-450):
obj.method() with error handling
- 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
Problem
parser/parse_statement.cppis 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.cppstill contains significant inline logic that could be extracted:List<T>,Pair<T>,Tuple<T>,Channel<T>variable declarationsmodule.func()callsobj.method()with error handlingobj.field = valueparsingSuggested Solution
Extract into smaller, focused files:
This follows the existing pattern where
parse_if.cpp,parse_for.cpp, etc. each handle their specific statement type.Impact