Parser#

Implementation#

class clanguru.cparser.Node(raw_node: clang.cindex.Cursor, previous_node: ForwardRef('Node') | None, next_node: ForwardRef('Node') | None, tokens: clanguru.cparser.TokensCollection, parent: 'TranslationUnit')[source]#

Bases: object

is_function_definition() bool[source]#

Check if the node type is function declaration and it is a definition.

class clanguru.cparser.SourceCodeSnippet(content: str, start_line: int, end_line: int)[source]#

Bases: object

Represents a source code snippet with line number information.

class clanguru.cparser.Token(raw_token: clang.cindex.Token, previous_token: ForwardRef('Token') | None, next_token: ForwardRef('Token') | None, cached_offset_start: int = 0, cached_offset_end: int = 0, cached_file_name: str = '', cached_line: int = 0, cached_spelling: str = '')[source]#

Bases: object

class clanguru.cparser.TokensCollection(tokens: list[Token])[source]#

Bases: list[Token]

find_matching_token(raw_token: Token) Token | None[source]#

Find the token in the collection by the raw token.

Builds a lookup Token with cached_spelling and cached_line populated because Token identity (hash/eq) is based on these cached fields.

first() Token | None[source]#

Get the first token in the collection.

class clanguru.cparser.TranslationUnit(raw_tu: clang.cindex.TranslationUnit, tokens: clanguru.cparser.TokensCollection, nodes: list[clanguru.cparser.Node])[source]#

Bases: object

parsing_error() str | None[source]#

Check if there was a parsing error.

Testing#