Skip to content

C

CParser

Bases: ParserBase

C specific parser. Uses a generic grammar for multiple versions of c. It uses tree_sitter.

Source code in src/parser/languages/c.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class CParser(ParserBase, lang=Extension.c.name):
    """
    C specific parser. Uses a generic grammar for multiple versions of c. It uses tree_sitter.
    """

    def __init__(self, library_path: Path | str):
        super().__init__(library_path)
        self.language: Language = Language(tsc.language())
        self.parser: Parser = Parser(self.language)
        self.identifiers_pattern: str = """
                                        ((identifier) @identifier)
                                        ((type_identifier) @type)
                                        """
        self.identifiers_query = self.language.query(self.identifiers_pattern)

        self.keywords = {'malloc'}