kimgr / asn1ate

A Python library for translating ASN.1 into other forms.
Other
69 stars 41 forks source link

restricted_integer_type range constraint #57

Open karlsv opened 6 years ago

karlsv commented 6 years ago

shouldn't restricted_integer_type, at line 275 in parse.py, have the possibility for value_range_constraint? I edited mine to: restricted_integer_type = INTEGER + braced_list(named_number) + Optional(value_range_constraint | single_value_constraint, default=None)

and it resolved an error I had and seems to work fine. Please correct me if I'm wrong.

kimgr commented 6 years ago

No, I think that's fine!

The current grammar is a little broken with regards to constraints, and I have a branch somewhere with a better generalization. But doesn't appear to move forward very quickly, so this is a good start.

Have you run the test suite after your change without problems? Could you add a test case somewhere with a few syntax examples, so this is covered for the future? And with all that in place, could you post a pull request?

Thanks!

karlsv commented 6 years ago

Sure, I haven't run the test suite yet, but I'll get to that. I also found that constraints can be on the form PathDeltaTime ::= INTEGER { tenMilliSecondsInPast(1) } (1..65535, ...) With an ellipsis after the range, but I have no idea what that means yet. If I find out I could try to fix support for that too. For reference I'm working with the ITS CAM/DENM specification, for which the ASN1 can be found on asn1-playground.oss.com with direct links: CAM DENM maybe some of this could be a test case