Closed aholtzma closed 8 years ago
FWIW the size constaint makes it into the parse tree:
ModuleDefinition:
ModuleReference:
Class-definitions
DefinitiveIdentifier:
AUTOMATIC TAGS
None
ModuleBody:
Exports:
Imports:
AssignmentList:
TypeAssignment:
MultiplePLMN-List-r6
::=
Type:
SequenceType:
SEQUENCE
ComponentType:
NamedType:
Identifier:
mibPLMN-Identity
Type:
SimpleType:
BOOLEAN
ComponentType:
NamedType:
Identifier:
multiplePLMNs
Type:
SequenceOfType:
SizeConstraint:
ValueRangeConstraint:
1
5
Type:
DefinedType:
None
PLMN-IdentityWithOptionalMCC-r6
None
However dumping the semantic tree seems be broken:
aaron:asn1ate aholtzma$ python asn1ate/test.py --sema ./missing_size.asn1
Traceback (most recent call last):
File "asn1ate/test.py", line 73, in <module>
sys.exit(main())
File "asn1ate/test.py", line 61, in main
print(module)
File "build/bdist.macosx-10.11-intel/egg/asn1ate/sema.py", line 350, in __str__
+ 'END\n'
File "build/bdist.macosx-10.11-intel/egg/asn1ate/sema.py", line 379, in __str__
return '%s ::= %s' % (self.type_name, self.type_decl)
File "build/bdist.macosx-10.11-intel/egg/asn1ate/sema.py", line 420, in __str__
component_type_list = ', '.join(map(str, self.components))
File "build/bdist.macosx-10.11-intel/egg/asn1ate/sema.py", line 669, in __str__
result = '%s %s' % (self.identifier, self.type_decl)
File "build/bdist.macosx-10.11-intel/egg/asn1ate/sema.py", line 505, in __str__
result = '[%s] ' % ' '.join(class_spec)
TypeError: sequence item 0: expected string, int found
Thanks! I didn't know SIZE
constraints were allowed on SEQUENCE OF
, so this is probably just an oversight. I'll try to take a look, but my asn1ate bandwidth is limited these days, so if you feel comfortable with contributing a patch that might go faster.
Okay I'll take a look. First thing is to fix the sema dump. Any ideas what is up there? It also fails with non-problematic ASN input.
I took a quick look and it appears the class_number is an integer when using automatic tagging. This bug crept in here: https://github.com/kimgr/asn1ate/pull/29/files#diff-6d613dac67af772711af50dfafa21774R396
I think the right thing to do is change sema.py, line 416 like so:
- tagged_type = TaggedType((None, tag_number, None, element))
+ tagged_type = TaggedType((None, str(tag_number), None, element))
I'll try to make that change later today and push.
Done, please resync to master.
Great, thanks. Now we can see that the semantic tree is fine:
Class-definitions DEFINITIONS ::=
BEGIN
MultiplePLMN-List-r6 ::= SEQUENCE { mibPLMN-Identity [0] BOOLEAN, multiplePLMNs [1] SEQUENCE SIZE(1..5) OF PLMN-IdentityWithOptionalMCC-r6 }
END
Will poke around in the pyasn1 back end now to see where the constraints get spit out.
The following input ASN1 definition:
produces the following output, which is missing the size constraint on multiplePLMNs.
Since size contstraints work elsewhere on sequence-ofs, I suspect this problem is due to the sequence-of being nested inside a sequence.