devana.preprocessing.premade.components.parser

devana.preprocessing.premade.components.parser.argumentsparser

class ArgumentGenericTypeParser(pattern, value_creator)[source]

Bases: IParsable

Universal type parser created based on regex and callback function or based on enum to create enum parser.

classmethod create_from_enum(enum)[source]
parse(text, dispatcher)[source]

Should get text and return parsed token as python value (except named argument - it is a dictionary). This method should call dispatcher argument with the rest of the text string to allow to parse the whole text with recursion. For example [value, *dispatcher(test_text)] is a typical return value.

Return type

Union[List[Any], Type[NoValue]]

class ArgumentsParser(extra_parsers=None)[source]

Bases: object

Helper class to parse function arguments (provided as text) and return list of python values.

tokenize(text)[source]
Return type

List[Any]

class IParsable[source]

Bases: ABC

Interface for parsable token element.

end_pattern = '\\s*((?P<comma>,.*)|(?P<empty>\\s*))$'
abstract parse(text, dispatcher)[source]

Should get text and return parsed token as python value (except named argument - it is a dictionary). This method should call dispatcher argument with the rest of the text string to allow to parse the whole text with recursion. For example [value, *dispatcher(test_text)] is a typical return value.

Return type

Union[List[Any], Type[NoValue]]

class ListArgumentParser[source]

Bases: IParsable

Implementation of a parsing list type.

parse(text, dispatcher)[source]

Should get text and return parsed token as python value (except named argument - it is a dictionary). This method should call dispatcher argument with the rest of the text string to allow to parse the whole text with recursion. For example [value, *dispatcher(test_text)] is a typical return value.

Return type

Union[List[Any], Type[NoValue]]

class NameArgumentParser[source]

Bases: IParsable

Implementation of parsing named argument like name=value.

parse(text, dispatcher)[source]

Should get text and return parsed token as python value (except named argument - it is a dictionary). This method should call dispatcher argument with the rest of the text string to allow to parse the whole text with recursion. For example [value, *dispatcher(test_text)] is a typical return value.

Return type

Union[List[Any], Type[NoValue]]

class NoValue[source]

Bases: object

Stub class to not-find argument token. We can’t use None because None is a valid value.

devana.preprocessing.premade.components.parser.extractor

class CommentExtractor(modules, file_filter=None)[source]

Bases: IExtractor

This function extracts function parsable data from comments in C++ source files.

extract()[source]

Extract from source - managed by this class - to specifics data.

Return type

List[ExtractedFunction]

class ExtractedFunction(text, parent)[source]

Bases: object

One line (can contain none, one or more functions) of text and parent of this line.

parent: ISyntaxElement
text: str
class IExtractor[source]

Bases: ABC

Interface for extract functions strings to parser.

abstract extract()[source]

Extract from source - managed by this class - to specifics data.

Return type

List[ExtractedFunction]

devana.preprocessing.premade.components.parser.functionparser

class FunctionEntity(name, namespaces, arguments)[source]

Bases: object

Parsing function information, argument are provided as string for another parser.

arguments: str
name: str
namespaces: List[str]
class FunctionParser[source]

Bases: object

Class realized parsing function.

class State(transactions, on_enter=<function FunctionParser.State.<lambda>>, on_exit=<function FunctionParser.State.<lambda>>, on_self=<function FunctionParser.State.<lambda>>)[source]

Bases: object

State information of parser.

on_enter()
on_exit()
on_self()
transactions: Callable[[Optional[str]], StateName]
class StateName(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Name of state.

ARGS = 5
END = 8
ERROR = 9
FUNCTION_SEPARATOR = 4
NAMESPACE = 2
NAMESPACE_SEPARATOR = 3
SEARCH = 1
STRING = 6
STRING_ESCAPE = 7
parse(text)[source]

Parse line to find functions.

Return type

List[FunctionEntity]

devana.preprocessing.premade.components.parser.parser

class Parser(extractor, signatures)[source]

Bases: ISource

Parser of preprocessor functions given as string. Extractor must provide string of function, or example, from source code.

feed()[source]

Create data, one by one.

Return type

List[CallingData[ISyntaxElement]]

classmethod get_produced_type()[source]

Specifies a result type, typically as an interface.

Return type

Type

devana.preprocessing.premade.components.parser.typechecker

is_arguments_valid(given, expected)[source]
Return type

bool

is_type_valid(value, maybe_hint)[source]
Return type

bool

Components for create your own function calls parser for preprocessor.