value_range_constraint = value_range_min + Suppress('..') + value_range_max
constraint = Suppress('(') + value_range_constraint + Suppress(')') # todo: consider exception spec from 45.6
+ # TODO: consider exception syntax from 24.1
+ extension_marker = Unique(ELLIPSIS)
+
component_type_optional = named_type + Suppress(OPTIONAL)
component_type_default = named_type + Suppress(DEFAULT) + value
component_type_components_of = Suppress(COMPONENTS_OF) + type_
named_number = identifier + named_number_value
enumeration = named_number | identifier
- # todo: consider extension and exception syntax from 24.1
- sequence_type = SEQUENCE + braced_list(component_type | ELLIPSIS)
+ sequence_type = SEQUENCE + braced_list(component_type | extension_marker)
sequenceof_type = SEQUENCE_OF + (type_ | named_type)
setof_type = SET_OF + (type_ | named_type)
- choice_type = CHOICE + braced_list(named_type | ELLIPSIS)
+ choice_type = CHOICE + braced_list(named_type | extension_marker)
enumerated_type = ENUMERATED + braced_list(enumeration)
bitstring_type = BIT_STRING + braced_list(named_number)
plain_integer_type = INTEGER
module_reference.setParseAction(annotate('ModuleReference'))
module_body.setParseAction(annotate('ModuleBody'))
module_definition.setParseAction(annotate('ModuleDefinition'))
+ extension_marker.setParseAction(annotate('ExtensionMarker'))
return module_definition
component_exprs = []
for c in components:
- component_exprs.append(self.generate_expr(c))
+ if not isinstance(c, ExtensionMarker):
+ component_exprs.append(self.generate_expr(c))
fragment.write_enumeration(component_exprs)
value_type = _translate_type(type_decl.type_name)
return '%s = %s(%s)' % (assigned_value, value_type, value)
+ def ignore(self, t):
+ return ''
+
def generate_pyasn1(sema_module, out_stream):
return Pyasn1Backend(sema_module, out_stream).generate_code()
__repr__ = __str__
+class ExtensionMarker(object):
+ def __init__(self, elements):
+ pass
+
+ def references(self):
+ # TODO: This appears to never be called. Investigate.
+ return []
+
+ def __str__(self):
+ return '...'
+
+ __repr__ = __str__
+
def _maybe_create_sema_node(token):
if isinstance(token, parser.AnnotatedToken):
return _create_sema_node(token)
return SequenceOfType(token.elements)
elif token.ty == 'SetOfType':
return SetOfType(token.elements)
+ elif token.ty == 'ExtensionMarker':
+ return ExtensionMarker(token.elements)
raise Exception('Unknown token type: %s' % token.ty)