class ContextManager:
Class in charge of piling all the parsed elements and then encapsulating them inside one another.
| Method | __call__ |
Interprets the list of tokens provided and deduces context, encapsulating them to their closest neighbour and containing all tokens inbetween. :rtype: list[BaseContainer] :return: Returns the pile entirely processed as a list of containers... |
| Method | __init__ |
Takes a list of parsed tokens. :type parsed_list : list[syntax.SemanticType] :param parsed_list: List of parsed tokens output by our parser. :type name: str :param name: Name of the file being parsed. ... |
| Method | __iter__ |
Iterator over the pile. :ytype: BaseContainer |
| Method | encapsulate |
Method to encapsulate a number of tokens together as a final container object and replace all elements in the pile with None, except the first one which becomes the container. :type start : int :param start: Index of the pile where the encapsulation must begin... |
| Method | finalize |
Function for cleaning up of the pile after full contextualisation. Removes Nones and checks for any errors or illogical containers. :return: list[BaseContainer] |
| Method | get |
Returns the last element in the pile if it is a Container, raises an error otherwise. :type index : int :param index: Index of the element to check. :return: Last element in the pile if it is a Container, raises an error otherwise... |
| Method | lookahead |
Iterates the pile beginning from index and looks for all tokens matching labels with token. :type token : syntax.BaseContainer :param token: Token to look for. :type index : int :param index: Index of the token in the pile... |
| Method | print |
Prints the pile. |
| Method | recontext |
Function to recontextualise the content of a token. :param token: Token to recontextualise. :type token: syntax.SemanticType :return: Token to recontextualise. :rtype: syntax.SemanticType |
| Instance Variable | contextualised |
Undocumented |
| Instance Variable | dict |
Undocumented |
| Instance Variable | ident |
Undocumented |
| Instance Variable | matched |
Undocumented |
| Instance Variable | name |
Undocumented |
| Instance Variable | output |
Undocumented |
| Instance Variable | parsed |
Undocumented |
| Instance Variable | pile |
Undocumented |
| Method | _add |
Method to add a matched element to the dictionary of matched elements. :type label : str :param label: Label of the matched element. :type index: int :param index: Index of the matched element in the pile. |
| Method | _get |
Method to get the index of the last matched element of a given label. :type label: str :param label: Label of the matched element. :rtype: int :return: Index of the last matched element |
Interprets the list of tokens provided and deduces context, encapsulating them to their closest neighbour and containing all tokens inbetween. :rtype: list[BaseContainer] :return: Returns the pile entirely processed as a list of containers. :raises: MismatchedContainerError if a container is not matched to its corresponding token.
Takes a list of parsed tokens. :type parsed_list : list[syntax.SemanticType] :param parsed_list: List of parsed tokens output by our parser. :type name: str :param name: Name of the file being parsed. :type ident: int :param ident: Number of spaces to indent the output.
Method to encapsulate a number of tokens together as a final container object and replace all elements in the pile with None, except the first one which becomes the container. :type start : int :param start: Index of the pile where the encapsulation must begin. :type end: int :param end: Index of the pile where the encapsulation must end. :rtype: list[(BaseContainer|None)] :return: List of containers and None objects.
Function for cleaning up of the pile after full contextualisation. Removes Nones and checks for any errors or illogical containers. :return: list[BaseContainer]
Returns the last element in the pile if it is a Container, raises an error otherwise. :type index : int :param index: Index of the element to check. :return: Last element in the pile if it is a Container, raises an error otherwise. :rtype: BaseContainer :raise: error_mngr.LonelyOptionalError when an element is found in the pile that is not encapsulated in a container.
Iterates the pile beginning from index and looks for all tokens matching labels with token. :type token : syntax.BaseContainer :param token: Token to look for. :type index : int :param index: Index of the token in the pile. :return: (number of tokens matched, number of linebreaks) :rtype: (int, int)
Function to recontextualise the content of a token. :param token: Token to recontextualise. :type token: syntax.SemanticType :return: Token to recontextualise. :rtype: syntax.SemanticType