typeparser module¶
|
|
|
|
|
|
- class BasicTypeParserResult(types: Dict[ForwardRef('types.QualifiedName'), ForwardRef('types.Type')], variables: Dict[ForwardRef('types.QualifiedName'), ForwardRef('types.Type')], functions: Dict[ForwardRef('types.QualifiedName'), ForwardRef('types.Type')])[source]¶
Bases:
object
- Parameters:
types (Dict[QualifiedName, Type]) –
variables (Dict[QualifiedName, Type]) –
functions (Dict[QualifiedName, Type]) –
- functions: Dict[QualifiedName, Type]¶
- types: Dict[QualifiedName, Type]¶
- variables: Dict[QualifiedName, Type]¶
- class CoreTypeParser(handle=None)[source]¶
Bases:
TypeParser
- get_option_text(option: TypeParserOption, value: str) str | None [source]¶
Get the string representation of an option for passing to parse_type_*
- Parameters:
option (TypeParserOption) – Option type
value (str) – Option value
- Returns:
A string representing the option if the parser supports it, otherwise None
- Return type:
str | None
- parse_type_string(source: str, platform: Platform, existing_types: types.TypeContainerType | None = None) Tuple[Tuple[types.QualifiedNameType, Type] | None, List[TypeParserError]] [source]¶
Parse a single type and name from a string containing their definition.
- Parameters:
- Returns:
A tuple of (result, errors) where result is a tuple of (type, name) or None of there was a fatal error.
- Return type:
Tuple[Tuple[types.QualifiedNameType, Type] | None, List[TypeParserError]]
- parse_types_from_source(source: str, file_name: str, platform: Platform, existing_types: types.TypeContainerType | None = None, options: List[str] | None = None, include_dirs: List[str] | None = None, auto_type_source: str = '') Tuple[TypeParserResult | None, List[TypeParserError]] [source]¶
Parse an entire block of source into types, variables, and functions
- Parameters:
source (str) – Source code to parse
file_name (str) – Name of the file containing the source (optional: exists on disk)
platform (Platform) – Platform to assume the types are relevant to
existing_types (types.TypeContainerType | None) – Optional container of all existing types to use for parsing context
options (List[str] | None) – Optional string arguments to pass as options, e.g. command line arguments
include_dirs (List[str] | None) – Optional list of directories to include in the header search path
auto_type_source (str) – Optional source of types if used for automatically generated types
- Returns:
A tuple of (result, errors) where the result is None if there was a fatal error
- Return type:
Tuple[TypeParserResult | None, List[TypeParserError]]
- preprocess_source(source: str, file_name: str, platform: Platform, existing_types: types.TypeContainerType | None = None, options: List[str] | None = None, include_dirs: List[str] | None = None) Tuple[str | None, List[TypeParserError]] [source]¶
Preprocess a block of source, returning the source that would be parsed
- Parameters:
source (str) – Source code to process
file_name (str) – Name of the file containing the source (does not need to exist on disk)
platform (Platform) – Platform to assume the source is relevant to
existing_types (types.TypeContainerType | None) – Optional collection of all existing types to use for parsing context
options (List[str] | None) – Optional string arguments to pass as options, e.g. command line arguments
include_dirs (List[str] | None) – Optional list of directories to include in the header search path
- Returns:
A tuple of (preproccessed source, errors), where the preproccessed source is None if there was a fatal error.
- Return type:
Tuple[str | None, List[TypeParserError]]
- class ParsedType(name: 'types.QualifiedNameType', type: 'types.Type', is_user: bool)[source]¶
Bases:
object
- name: types.QualifiedNameType¶
- class QualifiedNameTypeAndId(name: 'types.QualifiedNameType', id: str, type: 'types.Type')[source]¶
Bases:
object
- name: types.QualifiedNameType¶
- class TypeParser(handle=None)[source]¶
Bases:
object
- get_option_text(option: TypeParserOption, value: str) str | None [source]¶
Get the string representation of an option for passing to parse_type_*
- Parameters:
option (TypeParserOption) – Option type
value (str) – Option value
- Returns:
A string representing the option if the parser supports it, otherwise None
- Return type:
str | None
- parse_type_string(source: str, platform: Platform, existing_types: types.TypeContainerType | None = None) Tuple[Tuple[types.QualifiedNameType, Type] | None, List[TypeParserError]] [source]¶
Parse a single type and name from a string containing their definition.
- Parameters:
- Returns:
A tuple of (result, errors) where result is a tuple of (type, name) or None of there was a fatal error.
- Return type:
Tuple[Tuple[types.QualifiedNameType, Type] | None, List[TypeParserError]]
- parse_types_from_source(source: str, file_name: str, platform: Platform, existing_types: types.TypeContainerType | None = None, options: List[str] | None = None, include_dirs: List[str] | None = None, auto_type_source: str = '') Tuple[TypeParserResult | None, List[TypeParserError]] [source]¶
Parse an entire block of source into types, variables, and functions
- Parameters:
source (str) – Source code to parse
file_name (str) – Name of the file containing the source (optional: exists on disk)
platform (Platform) – Platform to assume the types are relevant to
existing_types (types.TypeContainerType | None) – Optional container of all existing types to use for parsing context
options (List[str] | None) – Optional string arguments to pass as options, e.g. command line arguments
include_dirs (List[str] | None) – Optional list of directories to include in the header search path
auto_type_source (str) – Optional source of types if used for automatically generated types
- Returns:
A tuple of (result, errors) where the result is None if there was a fatal error
- Return type:
Tuple[TypeParserResult | None, List[TypeParserError]]
- preprocess_source(source: str, file_name: str, platform: Platform, existing_types: types.TypeContainerType | None = None, options: List[str] | None = None, include_dirs: List[str] | None = None) Tuple[str | None, List[TypeParserError]] [source]¶
Preprocess a block of source, returning the source that would be parsed
- Parameters:
source (str) – Source code to process
file_name (str) – Name of the file containing the source (does not need to exist on disk)
platform (Platform) – Platform to assume the source is relevant to
existing_types (types.TypeContainerType | None) – Optional collection of all existing types to use for parsing context
options (List[str] | None) – Optional string arguments to pass as options, e.g. command line arguments
include_dirs (List[str] | None) – Optional list of directories to include in the header search path
- Returns:
A tuple of (preproccessed source, errors), where the preproccessed source is None if there was a fatal error.
- Return type:
Tuple[str | None, List[TypeParserError]]
- name = None¶
- class TypeParserError(severity: TypeParserErrorSeverity, message: str, file_name: str, line: int, column: int)[source]¶
Bases:
object
- Parameters:
severity (TypeParserErrorSeverity) –
message (str) –
file_name (str) –
line (int) –
column (int) –
- severity: TypeParserErrorSeverity¶
- class TypeParserResult(types: List[ParsedType], variables: List[ParsedType], functions: List[ParsedType])[source]¶
Bases:
object
- Parameters:
types (List[ParsedType]) –
variables (List[ParsedType]) –
functions (List[ParsedType]) –
- functions: List[ParsedType]¶
- types: List[ParsedType]¶
- variables: List[ParsedType]¶