Skip to content

Conversation

nene
Copy link
Collaborator

@nene nene commented Aug 23, 2022

Refactored AST data structure so we no more have to deal with raw tokens inside it.

  • This makes the AST smaller (as can be seen in Parser test snapshots)
  • It simplifies ExpressionFormatter which previously dealt with both AST nodes and Tokens, but now only deals with nodes.
  • It makes AST more type-safe. For example ClauseNode.name could previously contain any type of Token, but now it can only contain a KeywordNode.

The TokenNode is now eliminated and replaced with IdentifierNode, LiteralNode, ...

There's still a some token-data left inside the new KeywordNode, which has a tokenType field. This will hopefully get eliminated in the process of extending the parser.

The old show() method inside ExpressionFormatter is now replaced with showKw(), which only deals with showing KeywordNodes.

It's quite a big change in the amount of code affected, but functionality-wise nothing has changed.

@nene nene requested a review from inferrinizzard August 23, 2022 11:10
@nene nene merged commit 19d297f into master Aug 30, 2022
@nene nene deleted the more-ast-nodes branch August 30, 2022 07:38
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.

1 participant