Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Split parsing logic from AST objects #31

Merged
merged 64 commits into from
Sep 27, 2023

Conversation

grebaldi
Copy link
Member

@grebaldi grebaldi commented Jul 25, 2023

Remaining TODOs

  • Implement new AST Node objects and parsers
    • Access
    • BinaryOperation
    • BooleanLiteral
    • ComponentDeclaration
    • EnumDeclaration
    • Export
    • Expression
    • Import
    • IntegerLiteral
    • Match
    • Module
    • NullLiteral
    • PropertyDeclaration
    • StringLiteral
    • StructDeclaration
    • Tag
    • TemplateLiteral
    • TernaryOperation
    • Text
    • TypeReference
    • UnaryOperation
  • Remove old AST Node objects and adjust dependent classes
  • Remove leftover AST and Token snapshots
  • Rename IdentifierTypeResolver -> ValueReferenceTypeResolver
  • Rename IdentifierTranspiler -> ValueReferenceTranspiler
  • Turn all Domain\* name objects into flyweights
  • Reform GlobalScope to use explicit type names
  • Refactor all remaining Singletons with Singleton Trait

@grebaldi grebaldi linked an issue Jul 25, 2023 that may be closed by this pull request
@grebaldi grebaldi force-pushed the task/30/split-parsing-logic branch 2 times, most recently from 7aa7a59 to 8cc5fd4 Compare August 4, 2023 15:30
This also turns the EnumName class into a domain concern.
@grebaldi grebaldi force-pushed the task/30/split-parsing-logic branch from 54a3d40 to fb4b6c5 Compare August 5, 2023 17:14
@grebaldi grebaldi force-pushed the task/30/split-parsing-logic branch from 5efc19a to 36cd9bb Compare August 6, 2023 20:45
Comment on lines +271 to +273
$this->booleanLiteralParser ??= BooleanLiteralParser::singleton();

$booleanLiteralNode = $this->booleanLiteralParser->parse($tokens);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think, we need this second instance cache layer. Calling ::singleton() every-time should be fine?

Also it seems we are not using it for tests to swap out implementations...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying consideration is:

using($this->booleanLiteralParser) = cost_of(ReferenceLookup)
vs.
using(BooleanLiteralParser::singleton()) = cost_of(FunctionCall) + cost_of(ReferenceLookup)

It's just a performance optimization (maybe a bit over the top, but it's not nothing :D).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I'm working on #34, I noticed that I'm just one step away from being able to make all parsers static.

That will effectively eliminate this problem :)

@grebaldi grebaldi changed the base branch from task/27/remove-arithmetics to main September 27, 2023 15:19
@grebaldi grebaldi merged commit 86aa961 into main Sep 27, 2023
5 checks passed
@grebaldi grebaldi deleted the task/30/split-parsing-logic branch September 27, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TASK: Split parsing logic from AST objects
2 participants