Esempio n. 1
0
def detect(iToken, lObjects):
    '''
    delay_mechanism ::=
        transport
      | [ reject *time*_expression ] inertial
    '''
    if utils.is_next_token_one_of(['transport', 'reject', 'inertial'], iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
Esempio n. 2
0
def detect(iToken, lObjects):
    '''
    file_open_information ::=
        [ open *file_open_kind*_expression ] is file_logical_name
    '''

    if utils.is_next_token_one_of(['open', 'is'], iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    function_specification ::=
        [ pure | impure ] function designator
            subprogram_header
            [ [ parameter ] ( formal_parameter_list ) ] return type_mark
    '''

    if utils.is_next_token_one_of(['pure', 'impure', 'function'], iToken, lObjects):
        if not utils.find_in_next_n_tokens('new', 4, iToken, lObjects):
            return classify(iToken, lObjects)
    return iToken
def classify(iToken, lObjects):
    '''
    generate_statement_body ::=
            [ block_declarative_part
        begin ]
            { concurrent_statement }
        [ end [ alternative_label ] ; ]
    '''
    iCurrent = utils.find_next_token(iToken, lObjects)
    iLast = iCurrent
    iCurrent = block_declarative_part.detect(iCurrent, lObjects)

    if iCurrent != iLast:
        iCurrent = utils.assign_next_token_required('begin',
                                                    token.begin_keyword,
                                                    iCurrent, lObjects)

    iCurrent = utils.assign_next_token_if('begin', token.begin_keyword,
                                          iCurrent, lObjects)

    iLast = 0
    while iCurrent != iLast:
        iLast = iCurrent
        if utils.is_next_token_one_of(['elsif', 'else', 'when'], iCurrent,
                                      lObjects):
            return iCurrent
        if utils.is_next_token_one_of(['end'], iCurrent, lObjects):
            break
        iCurrent = concurrent_statement.detect(iCurrent, lObjects)

    if not utils.are_next_consecutive_tokens(['end', 'generate'], iCurrent,
                                             lObjects):
        iCurrent = utils.assign_next_token_required('end', token.end_keyword,
                                                    iCurrent, lObjects)
        iCurrent = utils.assign_next_token_if_not(';', token.alternative_label,
                                                  iCurrent, lObjects)
        iCurrent = utils.assign_next_token_required(';', token.semicolon,
                                                    iCurrent, lObjects)

    return iCurrent
Esempio n. 5
0
def detect(iToken, lObjects):
    '''
    simple_force_assignment ::=
        target <= force [ force_mode ] expression ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken,
                                  lObjects):
        return False
    if utils.find_in_range('<=', iToken, ';', lObjects):
        if utils.find_in_range('force', iToken, ';', lObjects):
            return classify(iToken, lObjects)
    return iToken
Esempio n. 6
0
def detect(iToken, lObjects):
    '''
    selected_waveform_assignment ::=
        with expression select [ ? ]
            target <= [delay_machanism] selected_waveforms ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken, lObjects):
        return False
    if utils.find_in_range('<=', iToken, ';', lObjects):
        if not utils.find_in_range('force', iToken, ';', lObjects):
            return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    conditional_waveform_assignment ::=
        target <= [ delay_mechanism ] conditional_waveforms ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken,
                                  lObjects):
        return False
    if utils.find_in_range('<=', iToken, ';', lObjects):  #
        if not utils.find_in_range('force', iToken, ';', lObjects):
            return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    selected_force_assignment ::= [§ 10.5.4]
        with expression select [ ? ]
            target <= force [ force_mode ] selected_expressions ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken,
                                  lObjects):
        return False
    if utils.find_in_range('<=', iToken, ';', lObjects):
        if utils.find_in_range('force', iToken, ';', lObjects):
            return classify(iToken, lObjects)
    return iToken
Esempio n. 9
0
def detect(iToken, lObjects):
    '''
    selected_variable_assignment ::=
        with expression select [ ? ]
           target := selected_expressions ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken, lObjects):
        return False
    if utils.find_in_range(':=', iToken, ';', lObjects):
        if utils.find_in_range('with', iToken, ';', lObjects):
            return True
        return False
    return False
def detect(iToken, lObjects):
    '''
    conditional_variable_assignment ::=
        target := conditional_expressions ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken,
                                  lObjects):
        return False
    if utils.find_in_range(':=', iToken, ';', lObjects):
        if not utils.find_in_range('with', iToken, ';', lObjects):
            if utils.find_in_range('when', iToken, ';', lObjects):
                return True
    return False
def detect(iToken, lObjects):
    '''
    simple_waveform_assignment ::=
        target <= [ delay_mechanism ] waveform ;
    '''

    if utils.is_next_token_one_of(['when', 'if', 'elsif', 'else'], iToken,
                                  lObjects):
        return False
    if utils.find_in_range('<=', iToken, ';', lObjects):
        if utils.find_in_range('force', iToken, ';', lObjects):
            return iToken
        if utils.find_in_range('release', iToken, ';', lObjects):
            return iToken
    return classify(iToken, lObjects)
def detect(iToken, lObjects):
    '''
        This is a classification if the signal, constant, or variable keywords can not be found.
        This is not in the VHDL LRM.
        It is based off the interface_signal_declaration as it has the most keywords.

        interface_unknown_declaration ::=
            identifier_list : [ mode ] subtype_indication [ bus ] [ := *static*_expression ]
    '''

    if utils.is_next_token_one_of(
        ['type', 'file', 'function', 'procedure', 'impure', 'pure', 'package'],
            iToken, lObjects):
        return iToken
    else:
        return classify(iToken, lObjects)
Esempio n. 13
0
def classify_until(lUntils, iToken, lObjects, oToken=token.identifier):
    '''
    identifier_list ::=
        identifier { , identifier }
    '''
    iEnd = len(lObjects) - 1
    iCurrent = iToken

    while not utils.is_next_token_one_of(lUntils, iCurrent, lObjects):
        if iCurrent == iEnd:
            return iCurrent
        iCurrent = utils.assign_next_token_if_not(',', oToken, iCurrent,
                                                  lObjects)
        iCurrent = utils.assign_next_token_if(',', token.comma, iCurrent,
                                              lObjects)

    return iCurrent
def detect(iCurrent, lObjects):
    '''
    instantiated_unit ::=
        [ component ] component_name
      | entity entity_name [ ( *architecture*_identifier ) ]
      | configuration configuration_name
    '''
    iToken = iCurrent
    if utils.is_next_token_one_of(['component', 'entity', 'configuration'],
                                  iToken, lObjects):
        return True
    if utils.find_in_next_n_tokens(';', 2, iToken, lObjects):
        return True
    # Check if this is a signal assignment
    if utils.find_in_range('<=', iToken, ';', lObjects):
        return False
    if utils.find_in_range('generate', iToken, ';', lObjects):
        return False
    return True
Esempio n. 15
0
def classify(iToken, lObjects):

    iCurrent = utils.tokenize_label(iToken, lObjects, token.if_label, token.label_colon)
    iCurrent = utils.assign_next_token_required('if', token.if_keyword, iCurrent, lObjects)
    iCurrent = condition.classify_until(['then'], iCurrent, lObjects)
    iCurrent = utils.assign_next_token_required('then', token.then_keyword, iCurrent, lObjects)

    iCurrent = sequence_of_statements.detect(iCurrent, lObjects)

    while utils.is_next_token_one_of(['else', 'elsif'], iCurrent, lObjects):
        if utils.is_next_token('elsif', iCurrent, lObjects):
            iCurrent = utils.assign_next_token_required('elsif', token.elsif_keyword, iCurrent, lObjects)
            iCurrent = condition.classify_until(['then'], iCurrent, lObjects)
            iCurrent = utils.assign_next_token_required('then', token.then_keyword, iCurrent, lObjects)
            iCurrent = sequence_of_statements.detect(iCurrent, lObjects)
        else:
            iCurrent = utils.assign_next_token_required('else', token.else_keyword, iCurrent, lObjects)
            iCurrent = sequence_of_statements.detect(iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required('end', token.end_keyword, iToken, lObjects)
    iCurrent = utils.assign_next_token_required('if', token.end_if_keyword, iCurrent, lObjects)
    iCurrent = utils.assign_next_token_if_not(';', token.end_if_label, iCurrent, lObjects)
    iCurrent = utils.assign_next_token_required(';', token.semicolon, iCurrent, lObjects)
    return iCurrent
def detect(iToken, lObjects):
    if utils.is_next_token_one_of(['type', 'file', 'function', 'procedure', 'impure', 'pure', 'package'], iToken, lObjects):
        return iToken
    else:
        return classify(iToken, lObjects)