Skip to content

Cpp

CPPParser

Bases: ParserBase

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

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

    def __init__(self, library_path: Path | str):
        super().__init__(library_path)
        self.language: Language = Language(tscpp.language())
        self.parser: Parser = Parser(self.language)
        # TODO Fix, doesn't work - It doesn't find the namespaced identifiers
        self.identifiers_pattern: str = """
                                        ((identifier) @identifier)
                                        ((type_identifier) @type)
                                        """
        self.identifiers_query = self.language.query(self.identifiers_pattern)

        self.keywords = set()