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

Implementing AST (Abstract Syntax Tree) Nodes #5

Open
ahmetozdemirrr opened this issue Sep 18, 2024 · 0 comments
Open

Implementing AST (Abstract Syntax Tree) Nodes #5

ahmetozdemirrr opened this issue Sep 18, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ahmetozdemirrr
Copy link
Owner

ahmetozdemirrr commented Sep 18, 2024

Aim: To create a hierarchical representation of the source code and add the AST structure to the project to support the semantic analysis, code generation and optimization phases.

In the process of compiler or interpreter development, creating an Abstract Syntax Tree (AST) allows us to perform a structural and semantic analysis of the source code. The AST is a hierarchical representation of the code parse according to grammar rules and plays a critical role in phases such as code generation, optimization and interpretation.

To Do:

1 - Design AST Data Structure:

* Define AST node structure (e.g., node type, child nodes, values). 
* Specify node types for different expression and statement types. 

2 - Update Bison Rules:

* Create AST nodes in the bodies of grammar rules. 
* Link nodes using symbols such as $$, $1, $2, etc. 

3 - Symbolic Table Integration:

* Integrate symbolic table management for variables and functions with AST.
* Support type checking and scope management. 

4 - Visitor Functions for Code Generation:

* Write functions that generate intermediate or target code by traversing the AST. 
* Generate code templates for operations and expressions. 

5 - Memory Management and Debugging:

* Organize memory allocation and release for AST nodes. 
* Use location information in error messages to provide more meaningful feedback.
@ahmetozdemirrr ahmetozdemirrr self-assigned this Sep 18, 2024
@ahmetozdemirrr ahmetozdemirrr added the enhancement New feature or request label Sep 18, 2024
@ahmetozdemirrr ahmetozdemirrr added this to the Syntax Design milestone Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant