Coverage for parsers / shared.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-08 15:04 -0800

1"""Shared parser utilities for all languages.""" 

2 

3from __future__ import annotations 

4 

5from parsers.common import parse_with_language 

6 

7 

8def create_parse(language): 

9 """Create parse function for a specific language.""" 

10 

11 def parse(code: str): 

12 """Parse source code and return the tree root node.""" 

13 return parse_with_language(code, language) 

14 

15 return parse 

16 

17 

18def create_collect_functions(recursive_collect_fn): 

19 """Create collect_functions wrapper from language-specific recursive function.""" 

20 

21 def collect_functions(root) -> list: 

22 """Collect all function nodes at all depths.""" 

23 functions = [] 

24 recursive_collect_fn(root, functions) 

25 return functions 

26 

27 return collect_functions