Ejemplo n.º 1
0
def classify_until(lUntils, iToken, lObjects):
    '''
    waveform ::=
        waveform_element { , waveform_element }
      | unaffected
    '''

    if utils.is_next_token('unaffected', iToken, lObjects):
        return utils.assign_next_token_required('unaffected',
                                                token.unaffected_keyword,
                                                iToken, lObjects)

    iCurrent = iToken
    lMyUntils = lUntils
    lMyUntils.append(',')

    iCurrent = waveform_element.classify_until(lMyUntils, iCurrent, lObjects)

    while utils.is_next_token(',', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required(',', token.comma, iCurrent,
                                                    lObjects)
        iCurrent = waveform_element.classify_until(lMyUntils, iCurrent,
                                                   lObjects)

    iCurrent = utils.assign_next_token_if(')', parser.todo, iCurrent, lObjects)

    return iCurrent
Ejemplo n.º 2
0
def classify(iToken, lObjects):
    '''
    assertion ::=
        assert condition
            [ report expression ]
            [ severity expression ]

    The key to detecting this is looking for the keyword **assert** before a semicolon.
    '''

    iCurrent = utils.assign_next_token_required('assert', token.keyword,
                                                iToken, lObjects)

    iCurrent = condition.classify_until(['report', 'severity', ';'], iCurrent,
                                        lObjects)

    if utils.is_next_token('report', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('report',
                                                    token.report_keyword,
                                                    iCurrent, lObjects)
        iCurrent = expression.classify_until(['severity', ';'], iCurrent,
                                             lObjects)

    if utils.is_next_token('severity', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('severity',
                                                    token.severity_keyword,
                                                    iCurrent, lObjects)
        iCurrent = expression.classify_until([';'], iCurrent, lObjects)

    return iCurrent
Ejemplo n.º 3
0
def classify(iToken, lObjects):
    '''
    entity_name_list ::=
        entity_designator { , entity_designator }
      | others
      | all
    '''

    if utils.is_next_token('others', iToken, lObjects):

        return utils.assign_next_token_required('others', token.others_keyword,
                                                iToken, lObjects)

    elif utils.is_next_token('all', iToken, lObjects):

        return utils.assign_next_token_required('all', token.all_keyword,
                                                iToken, lObjects)

    else:

        iCurrent = entity_designator.classify(iToken, lObjects)

        while utils.is_next_token(',', iCurrent, lObjects):

            iCurrent = utils.assign_next_token_required(
                ',', token.comma, iToken, lObjects)

            entity_designator.classify(iToken, lObjects)

    return iCurrent
Ejemplo n.º 4
0
def detect(iToken, lObjects):
    '''
    subprogram_kind ::=
        procedure | function
    '''

    if utils.is_next_token('procedure', iToken, lObjects):
        return True
    if utils.is_next_token('function', iToken, lObjects):
        return True
    return False
Ejemplo n.º 5
0
def detect(iToken, lObjects):
    '''
    signal_kind ::=
        register | bus
    '''

    if utils.is_next_token('register', iToken, lObjects):
        return classify(iToken, lObjects)
    elif utils.is_next_token('bus', iToken, lObjects):
        return classify(iToken, lObjects)

    return iToken
Ejemplo n.º 6
0
def detect(iToken, lObjects):
    '''
    variable_declaration ::=
        [ shared ] variable identifier_list : subtype_indication [ := expression ] ;
    '''

    if utils.is_next_token('shared', iToken, lObjects):
        return classify(iToken, lObjects)
    elif utils.is_next_token('variable', iToken, lObjects):
        return classify(iToken, lObjects)

    return iToken
def classify(iToken, lObjects):
    iCurrent = utils.tokenize_label(iToken, lObjects, token.generate_label,
                                    token.label_colon)

    iCurrent = utils.assign_next_token_required('if', token.if_keyword,
                                                iCurrent, lObjects)

    ### Need to handle alternaive_label ###

    iCurrent = condition.classify_until(['generate'], iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required('generate',
                                                token.generate_keyword,
                                                iCurrent, lObjects)

    iCurrent = generate_statement_body.classify(iCurrent, lObjects)

    while utils.is_next_token('elsif', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('elsif',
                                                    token.elsif_keyword,
                                                    iCurrent, lObjects)

        iCurrent = condition.classify_until(['generate'], iCurrent, lObjects)

        iCurrent = utils.assign_next_token_required('generate',
                                                    token.generate_keyword,
                                                    iCurrent, lObjects)

        iCurrent = generate_statement_body.classify(iCurrent, lObjects)

    if utils.is_next_token('else', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('else', token.else_keyword,
                                                    iCurrent, lObjects)

        iCurrent = utils.assign_next_token_required('generate',
                                                    token.generate_keyword,
                                                    iCurrent, lObjects)

        iCurrent = generate_statement_body.classify(iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required('end', token.end_keyword,
                                                iCurrent, lObjects)
    iCurrent = utils.assign_next_token_required('generate',
                                                token.end_generate_keyword,
                                                iCurrent, lObjects)
    iCurrent = utils.assign_next_token_if_not(';', token.end_generate_label,
                                              iCurrent, lObjects)
    iCurrent = utils.assign_next_token_required(';', token.semicolon, iCurrent,
                                                lObjects)

    return iCurrent
def detect(iToken, lObjects):
    '''
    interface_function_specification ::=
        [ pure | impure ] function designator
            [ [ parameter ] ( formal_parameter_list ) ] return type_mark
    '''

    if utils.is_next_token('pure', iToken, lObjects):
        return classify(iToken, lObjects)
    elif utils.is_next_token('impure', iToken, lObjects):
        return classify(iToken, lObjects)
    elif utils.is_next_token('function', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
Ejemplo n.º 9
0
def classify(iToken, lObjects):

    iCurrent = utils.tokenize_label(iToken, lObjects, token.label, token.label_colon)
    iCurrent = utils.assign_next_token_required('next', token.next_keyword, iCurrent, lObjects)

    if not utils.is_next_token(';', iCurrent, lObjects) and not utils.is_next_token('when', iCurrent, lObjects):
        iCurrent = utils.assign_next_token(token.loop_label, iCurrent, lObjects)

    if utils.is_next_token('when', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('when', token.when_keyword, iCurrent, lObjects)
        iCurrent = condition.classify_until([';'], iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required(';', token.semicolon, iCurrent, lObjects)

    return iCurrent
Ejemplo n.º 10
0
def classify(iToken, lObjects):

    if utils.is_next_token('transport', iToken, lObjects):

        return utils.assign_next_token_required('transport', token.transport_keyword, iToken, lObjects)

    else:

        iCurrent = iToken

        if utils.is_next_token('reject', iCurrent, lObjects):
            iCurrent = utils.assign_next_token_required('reject', token.reject_keyword, iCurrent, lObjects)
            iCurrent = expression.classify_until(['inertial'], iCurrent, lObjects)

        iCurrent = utils.assign_next_token_required('inertial', token.inertial_keyword, iCurrent, lObjects)
        return iCurrent
def classify_until(lUntils, iToken, lObjects):
    '''
    selected_expressions ::=
        { expression when choices , }
        expression when choices
    '''

    iCurrent = iToken
    lMyUntils = lUntils
    lMyUntils.append(',')

    iCurrent = expression.classify_until(['when'], iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required('when', token.when_keyword,
                                                iCurrent, lObjects)

    iCurrent = choices.classify_until(lMyUntils, iCurrent, lObjects)

    while utils.is_next_token(',', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required(',', token.comma, iCurrent,
                                                    lObjects)

        iCurrent = expression.classify_until(['when'], iCurrent, lObjects)

        iCurrent = utils.assign_next_token_required('when', token.when_keyword,
                                                    iCurrent, lObjects)

        iCurrent = choices.classify_until(lMyUntils, iCurrent, lObjects)

    return iCurrent
Ejemplo n.º 12
0
def classify(iToken, lObjects):
    '''
    selected_waveforms ::=
        { waveform when choices , }
        waveform when choices
    '''
    iCurrent = iToken

    iCurrent = utils.assign_tokens_until('when', parser.todo, iCurrent,
                                         lObjects)
    iCurrent = utils.assign_next_token_required('when', token.when_keyword,
                                                iCurrent, lObjects)
    sEnd = utils.find_earliest_occurance([',', ';'], iCurrent, lObjects)
    iCurrent = utils.assign_tokens_until(sEnd, parser.todo, iCurrent, lObjects)

    while utils.is_next_token(',', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required(',', token.comma, iCurrent,
                                                    lObjects)
        iCurrent = utils.assign_tokens_until('when', parser.todo, iCurrent,
                                             lObjects)
        iCurrent = utils.assign_next_token_required('when', token.when_keyword,
                                                    iCurrent, lObjects)
        sEnd = utils.find_earliest_occurance([',', ';'], iCurrent, lObjects)
        iCurrent = utils.assign_tokens_until(sEnd, parser.todo, iCurrent,
                                             lObjects)

    return iCurrent
Ejemplo n.º 13
0
def classify(iToken, lObjects):

    iCurrent = utils.assign_next_token_required('alias', token.alias_keyword,
                                                iToken, lObjects)

    iCurrent = utils.assign_next_token(token.alias_designator, iCurrent,
                                       lObjects)

    if utils.is_next_token(':', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required(':', token.colon, iCurrent,
                                                    lObjects)
        iCurrent = subtype_indication.classify_until(['is'], iCurrent,
                                                     lObjects)

    iCurrent = utils.assign_next_token_required('is', token.is_keyword,
                                                iCurrent, lObjects)

    iCurrent = name.classify_until([';', '['], iCurrent, lObjects)

    iCurrent = signature.detect(iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required(';', token.semicolon, iCurrent,
                                                lObjects)

    return iCurrent
Ejemplo n.º 14
0
def classify(iToken, lObjects):

    iCurrent = utils.assign_next_token_if('shared', token.shared_keyword,
                                          iToken, lObjects)
    iCurrent = utils.assign_next_token_required('variable',
                                                token.variable_keyword,
                                                iCurrent, lObjects)

    iCurrent = identifier_list.classify_until([':'], iCurrent, lObjects,
                                              token.identifier)

    iCurrent = utils.assign_next_token_required(':', token.colon, iCurrent,
                                                lObjects)

    iCurrent = subtype_indication.classify_until([';', ':='], iCurrent,
                                                 lObjects)

    if utils.is_next_token(':=', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required(':=',
                                                    token.assignment_operator,
                                                    iCurrent, lObjects)
        iCurrent = expression.classify_until([';'], iCurrent, lObjects)

    iCurrent = utils.assign_next_token_required(';', token.semicolon, iCurrent,
                                                lObjects)
    return iCurrent
def classify(iToken, lObjects):

    iCurrent = utils.assign_next_token_if('pure', token.pure_keyword, iToken,
                                          lObjects)
    iCurrent = utils.assign_next_token_if('impure', token.impure_keyword,
                                          iCurrent, lObjects)
    iCurrent = utils.assign_next_token_required('function',
                                                token.function_keyword, iToken,
                                                lObjects)
    iCurrent = utils.assign_next_token(token.designator, iCurrent, lObjects)
    iCurrent = utils.assign_next_token_if('parameter', token.parameter_keyword,
                                          iCurrent, lObjects)

    if utils.is_next_token('(', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('(',
                                                    token.open_parenthesis,
                                                    iCurrent, lObjects)

        iCurrent = formal_parameter_list.classify(iCurrent, lObjects)

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

    iCurrent = utils.assign_next_token_required('return', token.return_keyword,
                                                iToken, lObjects)
    iCurrent = type_mark.classify(iToken, lObjects)

    return iCurrent
Ejemplo n.º 16
0
def classify_until(lUntils, iToken, lObjects):
    '''
    conditional_waveforms ::=
        waveform when condition
        { else waveform when condition }
        [ else waveform ]
    '''

    lMyElseUntils = lUntils.copy()
    lMyElseUntils.append('else')
    lMyWhenUntils = lUntils.copy()
    lMyWhenUntils.append('when')

    iCurrent = waveform.classify_until(['when'], iToken, lObjects)
    iCurrent = utils.assign_next_token_required('when', token.when_keyword, iCurrent, lObjects)
    iCurrent = condition.classify_until(lMyElseUntils, iCurrent, lObjects)

    while utils.is_next_token('else', iCurrent, lObjects):
        iCurrent = utils.assign_next_token_required('else', token.else_keyword, iCurrent, lObjects)
        iCurrent = waveform.classify_until(lMyWhenUntils, iCurrent, lObjects)
        if utils.is_next_token_in_list(lUntils, iToken, lObjects):
            break
        iCurrent = utils.assign_next_token_required('when', token.when_keyword, iCurrent, lObjects)
        iCurrent = condition.classify_until(lMyElseUntils, iCurrent, lObjects)

    return iCurrent
Ejemplo n.º 17
0
def classify(iToken, lObjects):

    if utils.is_next_token('while', iToken, lObjects):
        iCurrent = utils.assign_next_token_required('while',
                                                    token.while_keyword,
                                                    iToken, lObjects)
        iCurrent = condition.classify_until(['loop'], iToken, lObjects)
        return iCurrent

    if utils.is_next_token('for', iToken, lObjects):
        iCurrent = utils.assign_next_token_required('for', token.for_keyword,
                                                    iToken, lObjects)
        iCurrent = parameter_specification.classify_until(['loop'], iToken,
                                                          lObjects)
        return iCurrent

    return iToken
def detect(iToken, lObjects):
    '''
    interface_incomplete_type_declaration ::=
        type identifier
    '''
    if utils.is_next_token('type', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
Ejemplo n.º 19
0
def detect(iToken, lObjects):
    '''
    generic_map_aspect ::=
        generic map ( *generic*_association_list )
    '''
    if utils.is_next_token('generic', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
Ejemplo n.º 20
0
def detect(iToken, lObjects):
    '''
    use_clause ::=
        use selected_name { , selected_name } ;
    '''
    if utils.is_next_token('use', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
Ejemplo n.º 21
0
def detect(iToken, lObjects):
    '''
    condition_clause ::=
        until condition
    '''

    if utils.is_next_token('until', iToken, lObjects):
        return True
    return False
def detect(iToken, lObjects):
    '''
    enumeration_type_definition ::=
        ( enumeration_literal { , enumeration_literal } )
    '''
    if utils.is_next_token('(', iToken, lObjects):
        return classify(iToken, lObjects)

    return iToken
Ejemplo n.º 23
0
def classify(iToken, lObjects):
    '''
    interface_subprogram_default ::=
        *subprogram*_name | <>
    '''
    if utils.is_next_token('<>', iToken, lObjects):
        return utils.assign_next_token_required('<>', token.undefined_range,
                                                iToken, lObjects)
    return utils.classify_next_token(token.subprogram_name, iToken, lObjects)
Ejemplo n.º 24
0
def detect(iToken, lObjects):
    '''
    sensitivity_clause ::=
        on sensitivity_list
    '''

    if utils.is_next_token('on', iToken, lObjects):
        return True
    return False
Ejemplo n.º 25
0
def detect(iToken, lObjects):
    '''
    library_clause ::=
        library logic_name_list ;
    '''
    if utils.is_next_token('library', iToken, lObjects):
        iCurrent = classify(iToken, lObjects)
        return iCurrent
    return iToken
Ejemplo n.º 26
0
def detect(iToken, lObjects):
    '''
    case_statement_alternative ::=
        when choices =>
            sequence_of_statements
    '''
    if utils.is_next_token('when', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    interface_file_declaration ::=
        file identifier_list : subtype_indication
    '''

    if utils.is_next_token('file', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    interface_package_declaration ::=
        package identifier is
            new *uninstantiated_package*_name interface_package_generic_map_aspect
    '''
    if utils.is_next_token('package', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    interface_signal_declaration ::=
        [ signal ] identifier_list : [ mode ] subtype_indication [ bus ] [ := *static*_expression ]
    '''

    if utils.is_next_token('signal', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken
def detect(iToken, lObjects):
    '''
    interface_variable_declaration ::=
    [ variable ] identifier_list : [ mode ] subtype_indication [ := static_expression ]
    '''

    if utils.is_next_token('variable', iToken, lObjects):
        return classify(iToken, lObjects)
    return iToken