Example #1
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
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
Example #3
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
Example #4
0
def classify_until(lUntils, iToken, lObjects):

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

    iCurrent = condition.classify_until(lUntils, iCurrent, lObjects)

    return iCurrent
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
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
Example #7
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