Implement intermediate representation ParseState#525
Conversation
|
What exactly is subclassable about this? It has no public methods and exists only in private modules. |
|
Good catch. _build_result should be public. Will update. The bit that's relevant for subclass-ability is that |
|
BTW as a follow-up I'll make a PR to ensure we get coverage for the unhit lines in _build_taware and _build_tzinfo |
|
For one thing, That said, if the only thing that matters is that a class implements I think some of this is already being done in the |
|
One thing I'll note is that the reason why I wanted all these broken up methods to be private wasn't because they should be private forever, but because I want to give a hard think about how the parser interface works and whether we can design something with an elegant way of implementing custom parsing behaviors, and I'm not sure a simple refactoring of the existing logic will work for that. As a result, I don't really want to commit to any significant changes to the public interface until we have an idea of what the final version should look like. I don't think this really solves the problem that I see with customization. You either have to rely on private interfaces or completely re-implement them, neither of which is ideal. |
|
Several small comments instead of one long one.
Even if we don't put post-parsing methods into the _result/ParseState class, defining it at the normal level of indentation and pinning it to the class will be an aesthetic improvement. |
|
Setting aside subclassing, the methods |
Not sure what you mean here. The _build_foo methods aren't part of |
|
It's probably premature to separate responsibilities out of (Note: acknowledging that the refactoring is premature is part of an effort to meet you halfway on this) |
Totally on board, and this has the added benefit of not feeling like the goal posts keep moving. |
|
I think focusing on subclassability was a mistake on my part: it's a red herring not really central here. So how about the following: _construction.ParseState --> _parser._ParseState, so there is no new module and nothing new in the public namespace. The nice qualities of Keep Make |
|
Closing for now, may revisit later. #539 implements the less controversial bits of this. |
Implement the intermediate representation as a full-fledged (easily-subclassable) class.
A subset of
parsermethods are focused on taking this intermediate representation and building the final representation. These methods are moved into the new class. As a result, they actually useself! (Well a couple don't, but I kept them as-is as a token of goodwill).Note:
tokenscould pretty reasonably be an attribute of the intermediate representation.