Sema support for SIZE constraints.
[asn2quickder] / asn1ate / parser.py
index 4eb3f12..3cd54a4 100644 (file)
@@ -203,7 +203,7 @@ def _build_asn1_grammar():
     value_range_min = (signed_number | valuereference | MIN)
     value_range_max = (signed_number | valuereference | MAX)
     value_range_constraint = value_range_min + Suppress('..') + value_range_max
-    size_constraint = SIZE + Suppress('(') + value_range_constraint + Suppress(')')
+    size_constraint = Suppress(SIZE) + Suppress('(') + value_range_constraint + Suppress(')')
     constraint = Suppress('(') + value_range_constraint + Suppress(')')
     optional_paren_l = Optional(Suppress('('))
     optional_paren_r = Optional(Suppress(')'))
@@ -225,7 +225,7 @@ def _build_asn1_grammar():
     set_type = SET + braced_list(component_type | extension_marker)
     sequence_type = SEQUENCE + braced_list(component_type | extension_marker)
     sequenceof_type = SEQUENCE + Optional(optional_paren_l + size_constraint + optional_paren_r) + OF + (type_ | named_type)
-    setof_type = SET + Optional(optional_paren_l + size_constraint + optional_paren_r) + OF + (type_ | named_type)
+    setof_type = Suppress(SET) + Optional(optional_paren_l + size_constraint + optional_paren_r) + Suppress(OF) + (type_ | named_type)
     choice_type = CHOICE + braced_list(named_type | extension_marker)
     enumerated_type = ENUMERATED + braced_list(enumeration)
     bitstring_type = BIT_STRING + braced_list(named_number)
@@ -290,6 +290,7 @@ def _build_asn1_grammar():
     setof_type.setParseAction(annotate('SetOfType'))
     named_number.setParseAction(annotate('NamedValue'))
     constraint.setParseAction(annotate('Constraint'))
+    size_constraint.setParseAction(annotate('SizeConstraint'))
     component_type.setParseAction(annotate('ComponentType'))
     component_type_optional.setParseAction(annotate('ComponentTypeOptional'))
     component_type_default.setParseAction(annotate('ComponentTypeDefault'))