def detect(iToken, lObjects):
    '''
    return_statement ::=
        [ label : ] return [ expression ] ;
    '''

    if utils.find_in_next_n_tokens(':', 2, iToken, lObjects):
        if utils.find_in_next_n_tokens('return', 3, iToken, lObjects):
            return classify(iToken, lObjects)
    if utils.is_next_token('return', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
Beispiel #2
0
def detect(iToken, lObjects):
    '''
    selected_signal_assignment ::=
        selected_waveform_assignment
      | selected_force_assignment
    '''

    if utils.find_in_range('<=', iToken, ';', lObjects):
        if utils.find_in_next_n_tokens('with', 3, iToken, lObjects):
            return True
        if utils.find_in_next_n_tokens('if', 3, iToken, lObjects):
            return True
    return False
def detect(iToken, lObjects):
    '''
    subprogram_instantiation_declaration ::=
        subprogram_kind identifier is new uninstantiated_subprogram_name [ signature ]
            [ generic_map_aspect ] ;
    '''

    if subprogram_kind.detect(iToken, lObjects):
        if utils.find_in_next_n_tokens('is', 3, iToken, lObjects):
            if utils.find_in_next_n_tokens('new', 4, iToken, lObjects):
                return classify(iToken, lObjects)
        else:
            return iToken
    return iToken
def detect(iToken, lObjects):
    '''
    process_statement ::=
        [ *process*_label : ]
            [ postponed ] process [ ( process_sensitivity_list ) ] [ is ]
                process_declarative_part
            begin
                process_statement_part
            end [ postponed ] process [ *process*_label ] ;
    '''
    if utils.find_in_next_n_tokens('process', 4, iToken, lObjects):
        if not utils.find_in_next_n_tokens(';', 3, iToken, lObjects):
            return classify(iToken, lObjects)
    return iToken
Beispiel #5
0
def detect(iToken, lObjects):
    '''
    iteration_scheme ::=
        while condition
      | for *loop*_parameter_specification
    '''
    if utils.find_in_next_n_tokens(';', 3, iToken, lObjects):
        return False
    if utils.find_in_next_n_tokens('else', 3, iToken, lObjects):
        return False
    if utils.find_in_next_n_tokens('while', 3, iToken, lObjects):
        return True
    if utils.find_in_next_n_tokens('for', 3, iToken, lObjects):
        return True
    return False
Beispiel #6
0
def detect(iToken, lObjects):
    '''
    procedure_call_statement ::=
        [ label : ] procedure_call ;
    '''

    iCurrent = iToken
    # Move past label if it exists
    if utils.find_in_next_n_tokens(':', 2, iCurrent, lObjects):
        iCurrent = utils.find_next_token(iCurrent, lObjects)
        iCurrent += 1
        iCurrent = utils.find_next_token(iCurrent, lObjects)
        iCurrent += 1
    # Check if next token is keyword
    iCurrent = utils.find_next_token(iCurrent, lObjects)
    if lObjects[iCurrent].get_value().lower() in lKeywords:
        return iToken
    # Check if signal assignment operator exists
    if utils.find_in_range('<=', iCurrent, ';', lObjects):
        return iToken
    # Check if variable assignment operator exists
    if utils.find_in_range(':=', iCurrent, ';', lObjects):
        return iToken
    # Otherwise it must be a procedure_call_statement
    return classify(iToken, lObjects)
def detect(iToken, lObjects):
    '''
    package_declaration ::=
        package identifier is
            package_header
            package_declarative_part
        end [ package ] [ package_simple_name ] ;
    '''

    iCurrent = utils.find_next_token(iToken, lObjects)
    if utils.object_value_is(lObjects, iCurrent, 'package'):
        if not utils.find_in_next_n_tokens('body', 5, iCurrent, lObjects):
            if not utils.find_in_next_n_tokens('new', 5, iCurrent, lObjects):
                return classify(iToken, lObjects)
        else:
            return iToken

    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 detect(iToken, lObjects):
    '''
    procedure_specification ::=
        procedure designator
            subprogram_header
            [ [ parameter ] ( formal_parameter_list ) ]
    '''

    if utils.is_next_token('procedure', iToken, lObjects):
        if not utils.find_in_next_n_tokens('new', 4, iToken, lObjects):
            return classify(iToken, lObjects)
    return iToken
Beispiel #10
0
def detect(iToken, lObjects):
    '''
    constrained_array_definition ::=
        array index_constraint of *element*_subtype_indication
    '''

    if utils.is_next_token('array', iToken, lObjects):
        if not utils.find_in_next_n_tokens('<>', 5, iToken, lObjects):
            return classify(iToken, lObjects)
        else:
            return iToken

    return iToken
Beispiel #11
0
def detect(iToken, lObjects):
    '''
    unbounded_array_definition ::=
        array ( index_subtype_definition { , index_subtype_definition } )
            of *element*_subtype_indication
    '''

    if utils.is_next_token('array', iToken, lObjects):
        if utils.find_in_next_n_tokens('<>', 5, iToken, lObjects):
            return classify(iToken, lObjects)
        else:
            return iToken

    return iToken
Beispiel #12
0
def detect(iToken, lObjects):
    '''
    concurrent_assertion_statement ::=
        [ label : ] [ postponed ] assertion ;

    assertion ::=
        assert condition
            [ report expression ]
            [ severity expression ]

    '''

    if utils.find_in_next_n_tokens('assert', 4, iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    conditional_signal_assignment ::=
        conditional_waveform_assignment
      | conditional_force_assignment
    '''

    if utils.is_next_token('when', iToken, lObjects):
        return False
    if utils.find_in_next_n_tokens('if', 3, iToken, lObjects):
        return False
    if utils.find_in_range('<=', iToken, ';', lObjects):
        if utils.find_in_range('when', iToken, ';', lObjects):
            return True
    return False
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
Beispiel #15
0
def classify(iToken, lObjects):

    if utils.find_in_next_n_tokens('(', 2, iToken, lObjects):
        iCurrent = utils.assign_next_token_required('generic',
                                                    token.generic_keyword,
                                                    iToken, lObjects)
        iCurrent = utils.assign_next_token_required('(',
                                                    token.open_parenthesis,
                                                    iCurrent, lObjects)

        iCurrent = generic_list.classify(iCurrent, lObjects)

        iCurrent = utils.assign_next_token_required(')',
                                                    token.close_parenthesis,
                                                    iCurrent, lObjects)

    iCurrent = generic_map_aspect.detect(iToken, lObjects)

    return iCurrent
Beispiel #16
0
def detect(iToken, lObjects):
    '''
    loop_statement ::=
        [ loop_label : ]
            [ iteration_scheme ] loop
                sequence_of_statements
            end loop [ loop_label ] ;
    '''
    if utils.find_in_next_n_tokens(':', 2, iToken, lObjects):
        iCurrent = utils.find_next_token(iToken, lObjects)
        iCurrent += 1
        iCurrent = utils.find_next_token(iCurrent, lObjects)
        iCurrent += 1
    else:
        iCurrent = iToken

    if iteration_scheme.detect(iCurrent, lObjects):
        return classify(iToken, lObjects)
    if utils.is_next_token('loop', iCurrent, lObjects):
        return classify(iToken, lObjects)

    return iToken