The Abstract Syntax Notation One, ASN.1, is first and foremost a notation to describe data structures. It’s modern cousin is, in a rather broad sense, XML. Being a bit more precise, ASN.1 is what XML’s schema definition (XSD) is for XML. The idea behind both notations is the same, i.e. to provide a data description idependent of any machine specific logic. ASN.1 is still widley used in telecommunications and computer networking. An area where ASN.1 is silently used by each of us every day is internet security. This is due to the fact that the data strutures behind public-key certficates are described using ASN.1.

Usually ASN.1 is mentioned along with formal encoding rules, i.e. rules how to translate data into bits and bytes for storage or sending over the wire. The traditional encoding rules are the Basic Encoding Rules (BER) and later additions have been the Canonical, Disthinguished and Packed Encoding Rules (DER, CER and PER resp).

ASN.1 is a joint ISO/IEC and ITU-T standard, originally defined in 1984 as part of CCITT X.409:1984. ASN.1 moved to its own standard, X.208, in 1988 due to wide applicability. The substantially revised 1995 version is covered by the X.680 series. The latest available version is dated 2002, and is backward compatible with the 1995 version.

When working for Computec GmbH Software I participated in a European Research Project which lead eventually to the development of ASN2CXX, an ASN.1 Compiler along with supporting libraries. Unfortunatley, ASN2CXX was pure commercial product and it’s source code is closed and can’t be made open source.

During my work on pyAntlr I was looking for an example grammer to check how easy or difficult it gets to develop a grammar using Antlr. So what’s better than using a grammar I’m familiar with. Therefore I choose ASN.1 as ginnie pig (The result was rather impressiv. Gone are the days with shift/reduce or worse, with reduce/reduce conflicts when using traditonal tools like yacc or bison).