Nav view search

Navigation

Search

Nothing simpler than a comment, and yet they are the source of frequent syntax errors. ASN.1 standard is very clear, a comment starts with the string "--" and finishes at the end of the current line or with a new sequence "--" on the same line.

It is very common to find comments like this: "------------------" which may cause a syntax error if the number of hyphens is not even.

The following text is an axtract of "ITU-T Recommendation X.680, Abstract Syntax Notation One (ASN.1): Specification of basic notation" which specifically deals with comments:


12.6 Comments

Name of lexical item – comment

12.6.1 A "comment" is not referenced in the definition of the ASN.1 notation. It may, however, appear at any time between other lexical items, and has no syntactic significance.

NOTE – Nonetheless, in the context of a Recommendation | International Standard that uses ASN.1, an ASN.1 comment may contain normative text related to the application semantics, or constraints on the syntax.

12.6.2 The lexical item "comment" can have two forms:

a) One-line comments which begin with "--" as defined in 12.6.3;

b) Multiple-line comments which begin with "/*" as defined in 12.6.4.

12.6.3 Whenever a "comment" begins with a pair of adjacent hyphens, it shall end with the next pair of adjacent hyphens or at the end of the line, whichever occurs first. A comment shall not contain a pair of adjacent hyphens other than the pair which starts it and the pair, if any, which ends it. If a comment beginning with "--" includes the adjacent characters "/*" or "*/", these have no special meaning and are considered part of the comment. The comment may include graphic symbols which are not in the character set specified in 11.1 (see 11.3).

12.6.4 Whenever a "comment" begins with "/*", it shall end with a corresponding "*/", whether this "*/" is on the same line or not. If another "/*" is found before a "*/", then the comment terminates when a matching "*/" has been found for each "/*". If a comment beginning with "/*" includes two adjacent hyphens "--", these hyphens have no special meaning and are considered part of the comment. The comment may include graphic symbols which are not in the character set specified in 11.1 (see 11.3).

NOTE – This allows the user to comment parts of an ASN.1 module that already contain comments (whether they begin with "--" or "/*") by simply inserting "/*" at the beginning of the part to be commented and "*/" at its end, provided there are no character string values within the part to be commented out that contain "/*" or "*/".