-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Milestone
Description
Currently, all AST objects have static factory methods that contain the actual parsing logic.
While convenient at first, it turns out, it is better for maintenance, testing and the overall design to have all AST objects available as simple DTOs.
The parsing logic should be moved into dedicated service classes of the form:
final class {ASTConceptName}Parser
{
/**
* @param \Iterator<mixed,Token> $tokens
* @return null|{ASTConceptName}Node
*/
public function parse(\Iterator $tokens): ?{ASTConceptName}Node;
}
This leads to the following acceptance criteria for each AST concept:
- There is a class
{ASTConceptName}Node
that consists entirely of public, readonly, constructor-promoted properties. The constructor is public. - There is a class
{ASTConceptName}Parser
with a methodparse
that accepts an\Iterator
ofToken
objects and produces a (potentially nullable){ASTConceptName}Node
- There is a unit test for
{ASTConceptName}Parser
Metadata
Metadata
Assignees
Labels
No labels