Exemple #1
0
def _lift_attribute(location, attribute_param, default=None):
    if isinstance(default, six.string_types):
        assert default[0] == default[-1] == '"', 'unquoted string used as ' \
            'attribute default value (bug in stage 1 parser?)'
        default = default[1:-1]  # Strip quotes
    return Attribute(attribute_param.type, attribute_param.name,
                     attribute_param.array, default, location)
Exemple #2
0
def _lift_attribute_scalar_parameter(location, *args):
    assert len(args) == 2
    type, name = args
    assert(isinstance(type, (six.string_types, Reference, Struct)))
    if isinstance(type, six.string_types):
        # do not allow `struct blah` in attributes
        if type.startswith("struct "):
            raise ParseError("type: \"%s\" is not a valid type" % type, location)
    return Attribute(type, name, array=False, default= None, location=location)
Exemple #3
0
def p_attribute_defn(t):
    '''attribute_defn : type ID SEMI'''
    t[0] = Attribute(t[2], t[1], filename=t.lexer.filename, lineno=t.lexer.lineno)
Exemple #4
0
def _lift_attribute_array_parameter(location, scalar_parameter):
    return Attribute(scalar_parameter.type,
                     scalar_parameter.name,
                     True,
                     default=None,
                     location=location)
Exemple #5
0
def p_attribute_statement(t):
    '''attribute_statement : attribute type ID SEMI'''
    t[0] = Attribute(t[2], t[3], filename=t.lexer.filename, \
        lineno=t.lexer.lineno)