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

Python tree-sitter to CAST porting: Loops #745

Merged
merged 7 commits into from
Jan 12, 2024
Merged

Conversation

titomeister
Copy link
Contributor

This PR introduces support for generating CAST for Loops (for/while) using tree-sitter, as part of the ongoing effort to port over the Python AST to CAST generation to using tree-sitter.

Python Tree Sitter

  • Added support for generating CAST Loop nodes using Python tree sitter.
  • Specifically, we added support for Python's For and While loop CAST generation.
  • Added some support for tree-sitter "patterns: "list_pattern", "tuple_pattern", "list_pattern". These are used primarily in the For loop syntax as the item we're iterating over.
  • Also added support for generating Iterator function calls, as used by the Python For Loops.
  • Updated the CAST to AGraph visualizer to better visualize tuples.

Testing

  • Added some small unit tests for loops (for/while) to determine consistency.
  • Added a small unit test for detecting missing identifiers in the first line of a Python program.

Other Fixes

  • Fixes an issue with missing identifier names when they appeared on the first line of the Python program. This was done by adding some additional handling that is specific to the first line of the program.

Resolves #498
Resolves #740

Copy link
Contributor

@vincentraymond-ua vincentraymond-ua left a comment

Choose a reason for hiding this comment

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

@titomeister - Looks good!

@myedibleenso myedibleenso merged commit f2b27d4 into main Jan 12, 2024
7 checks passed
@myedibleenso myedibleenso deleted the ferra/python_ts_loop branch January 12, 2024 18:32
github-actions bot added a commit that referenced this pull request Jan 12, 2024
This PR introduces support for generating CAST for Loops (for/while)
using tree-sitter, as part of the ongoing effort to port over the Python
AST to CAST generation to using tree-sitter.

### Python Tree Sitter
- Added support for generating CAST Loop nodes using Python tree sitter.
- Specifically, we added support for Python's For and While loop CAST
generation.
- Added some support for tree-sitter "patterns: "list_pattern",
"tuple_pattern", "list_pattern". These are used primarily in the For
loop syntax as the item we're iterating over.
- Also added support for generating Iterator function calls, as used by
the Python For Loops.
- Updated the CAST to AGraph visualizer to better visualize tuples.

### Testing

- Added some small unit tests for loops (for/while) to determine
consistency.
- Added a small unit test for detecting missing identifiers in the first
line of a Python program.

### Other Fixes
- Fixes an issue with missing identifier names when they appeared on the
first line of the Python program. This was done by adding some
additional handling that is specific to the first line of the program.

Resolves #498
Resolves #740 f2b27d4
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.

[code2FN] Tree-Sitter to CAST Missing Identifiers Python tree sitter: Loops
3 participants