Skip to content

Csharp

CSharpParser

Bases: ParserBase

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

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

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

        self.keywords = set()