kimgr / asn1ate

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

allow underscore in identifier suffices #39

Closed hermansc closed 8 years ago

hermansc commented 8 years ago

Following ASN is valid according to spec and asn1-playground:

FooProtocol DEFINITIONS ::= BEGIN
  Foo ::= SEQUENCE {
    hello_world  INTEGER
  }
END
kimgr commented 8 years ago

Thanks for the patch!

Following ASN is valid according to spec

Unfortunately, I can't find anything in X.680 that allows underscore. I web-searched for "asn.1 underscore" and found this, which explicitly says underscore is not allowed: http://www.freesoft.org/CIE/RFC/1510/50.htm

and asn1-playground

It could be that their parser accepts this as an extension.

I've had extensions in for compatibility with the Objective Systems ASN.1 toolkit, but I've been meaning to remove them. Do you have a published protocol that requires this?

hermansc commented 8 years ago

Ah, very interesting. I found this grammar file, which allowed it - https://github.com/richb-hanover/mibble-2.9.2/blob/master/src/grammar/asn1.grammar#L163, but I think you're right - it's not part of the spec after all and I'll might go and change our protocol ASN files to reflect this.

Indeed, if you enabled the "strict syntax checking" in the playground it does not work.

Having a differentiation between strict and relaxed grammar checking in asn1ate would of course be nice - but out of the scope of this PR :-)

Thanks again.

kimgr commented 8 years ago

OK, thanks!

Yeah, it would be nice to be able to tell asn1ate about individual extensions you wanted to enable (we had a few PDUs with unnamed members that we've now scrapped.)

So rather than strict/relaxed it would be more useful to be able say "allow unnamed members" and "allow underscores in identifiers". No idea how to make it happen nicely, though :-)