import re


def get_definitions_of_type_in_text(type_string, text, literal_dictionary):
    """Returns every definition{} in the text as a list of tuples,
    each containing the name of the definition and it's text"""

    all_instances = list()
    find_defintions_regex = r'%s\s*(_LITERAL_\d+)\s*\{([^\}]*)\}' % type_string

    all_definitions = re.findall(find_defintions_regex, text, flags=0)

    # Parse each definition into a tuple containing name and it's text
    index = 0
    while index < len(all_definitions):
        def_name, def_text = all_definitions[index]
        def_name = literal_dictionary[def_name][1:-1]
        _tuple = def_name, def_text
        all_instances.append(_tuple)
        index += 1

    return all_instances