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

Where is the tree structure actually generated? #17

Open
bakhtiarZ opened this issue Mar 11, 2022 · 2 comments
Open

Where is the tree structure actually generated? #17

bakhtiarZ opened this issue Mar 11, 2022 · 2 comments

Comments

@bakhtiarZ
Copy link

bakhtiarZ commented Mar 11, 2022

In lab2, we have many classes and derived classes, this seems like a linked list type structure and it is shown to create an AST but I can't find where it does this, like the actual linking of nodes and creation of the tree.

Is it done in the parser where we do things like $$ = $1 ? Is this linking the node to the previous one from the grammar>?

@ymherklotz
Copy link
Member

Yes, the parser is the one that generates the AST. You do that by allocating new nodes wherever they are needed, and otherwise just assigning the pointer that was already constructed by one of the nodes lower down in the parser returned ($$ = $1).

I wouldn't call it a linked list though, it's just a tree structure, with various different nodes that link to more nodes.

@bakhtiarZ
Copy link
Author

bakhtiarZ commented Oct 11, 2022 via email

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

No branches or pull requests

2 participants