Skip to content

Commit

Permalink
Merge pull request #747 from pankajskku/dev-pankaj
Browse files Browse the repository at this point in the history
Increase recursion limit and add error handling for deep recursion of…
  • Loading branch information
touma-I authored Nov 8, 2024
2 parents a9166ad + 9f1b302 commit 723e675
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions transforms/code/code_profiler/python/src/UAST_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import json
from tree_sitter import Tree
import os
import sys
sys.setrecursionlimit(10000)

"""
Initialize the parser with a path for rules and grammar.
"""
Expand Down Expand Up @@ -251,7 +254,10 @@ def _dfs(self, AST_node, parent) :
parent = node

for child in AST_node.children:
self._dfs(AST_node= child, parent = parent)
try:
self._dfs(AST_node= child, parent = parent)
except RecursionError as e:
print(f"RecursionError caught: {str(e)}")

def _extract(self, ast_snippet, node_type, exec_string):
code_snippet = ast_snippet
Expand All @@ -262,4 +268,4 @@ def _extract(self, ast_snippet, node_type, exec_string):
try:
return self.grammar[node_type]["keyword"] + " " + self.extracted
except Exception as e:
print(e)
print(e)

0 comments on commit 723e675

Please sign in to comment.