Splitting out AstNode to AstNode, Block, Pipeline, StatementNode, ExpressionNode.#68
Draft
WindSoilder wants to merge 12 commits intonushell:mainfrom
Draft
Splitting out AstNode to AstNode, Block, Pipeline, StatementNode, ExpressionNode.#68WindSoilder wants to merge 12 commits intonushell:mainfrom
WindSoilder wants to merge 12 commits intonushell:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As title, this pr is a huge refactor of the codebase, it splits a general
AstNodeto different nodes.We can look into
enum StatementNodeandenum ExpressionNodeto see what they can be.It's a little different to another pr #54 , this pr saves all these nodes into
Compiler, so we have the following fields:AstNode)For Expression Node, I dupliated the storage of
NameNode,StringNodeandVariableNodeto an individual place, because they can be re-used in many places, after that, we can defineStatementNode::Let,StatementNode::Defeasier.After we pushing these node, we also put an Indexer into
Compiler.indexer, we can still get all nodes sequentially from this field.For every type of node, they have a new id type, for example:
NameNode:NameNodeIdStringNode:StringNodeIdVariableNode:VariableNodeIdAnd here we define
NodeIdGetter traitforNodeIdandNodePush traitforNode. So we can push node to compiler and get node information from compiler easily.What can we actheves after this pr:
AstNodeevery time after we get a node, we are more likely to get right node when we get from a dedicated typed id.Something might goes bad after this pr:
display_statemethod. Currently it doesn't show useful information.I only finished changes in
compiler.rsandparser.rs, and part oftypechecker.rs, before making more progress, I'd like to create this draft pr to see if I am on the right way.