Rien de plus simple qu'un commentaire, et pourtant, ils sont la source d'erreurs de syntaxe fréquentes. La norme ASN.1 est pourtant très claire, un commentaire commence par la séquence "--" et se termine à la fin de la ligne ou à la fin d'une nouvelle séquence "--" sur la même ligne.
Il est pourtant fréquent de trouver des commentaires comme ceci : "------------------" qui peuvent provoquer une erreur de syntaxe si le nombre de tirets n'est pas pair.
Le paragraphe suivant est un extrait de "ITU-T Recommendation X.680, Abstract Syntax Notation One (ASN.1): Specification of basic notation" qui traite spécifiquement des commentaires :
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 "*/".