diff --git a/transforms/code/code_profiler/python/src/UAST_parser.py b/transforms/code/code_profiler/python/src/UAST_parser.py index 3538d8884..fc5bc9819 100644 --- a/transforms/code/code_profiler/python/src/UAST_parser.py +++ b/transforms/code/code_profiler/python/src/UAST_parser.py @@ -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. """ @@ -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 @@ -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) \ No newline at end of file + print(e)