Example #1
0
def label_declarations(node):
    global current_lexem

    current_node = Node('<label_declarations>')

    if current_lexem['lexem'] == 'LABEL':
        add_current_item(current_node)
        next_lexem()

        if unsigned_integer(current_node):
            node.add(current_node)
            error_print('NOT_FOUND', 'unsigned_integer')
            return True

        if label_list(current_node):
            return True

        if current_lexem['code'] != 59:
            node.add(current_node)
            error_print('NOT_FOUND', ';')
            return True

        add_current_item(current_node)
        node.add(current_node)
        next_lexem()

    elif current_lexem['lexem'] == 'BEGIN':
        current_node.add(Node('<empty>'))
        node.add(current_node)
        return False

    else:
        node.add(current_node)
        error_print('NOT_FOUND', 'LABEL')
        return True
Example #2
0
def alternative_part(node):
    global current_lexem

    current_node = Node('<alternative_part>')

    if current_lexem['lexem'] == 'ELSE':
        add_current_item(current_node)
        next_lexem()
        if statements_list(current_node):
            return True
    else:
        next = take_next_item()
        if current_lexem['lexem'] == 'ENDIF':
            current_node.add(Node('<empty>'))
    node.add(current_node)
    return False
Example #3
0
def statements_list(node):
    global statements_stack

    current_node = Node('<statements_list>')
    if not statement(current_node):
        statements_list(current_node)
        node.add(current_node)
        return False

    if current_lexem['lexem'] in empty_authorized:
        current_node.add(Node('<empty>'))
        node.add(current_node)
        return False

    error_print('UNEXPECTED')
    node.add(current_node)
    return True
Example #4
0
def label_list(node):
    global current_lexem

    current_node = Node('<label_list>')

    if current_lexem['lexem'] == ',':
        add_current_item(current_node)
        next_lexem()
        if unsigned_integer(current_node):
            error_print('NOT_FOUND', 'unsigned_integer')
            return True
        if label_list(current_node):
            return True
        node.add(current_node)
    else:
        if not unsigned_integer(current_node):
            error_print('NOT_FOUND')
            return True
        else:
            # print next_item
            current_node.add(Node('<empty>'))
            node.add(current_node)