There are annotations that should be handled uniformly by all CASL parsers because the information is needed for further parsing stages, e.g. mixfix parsing.
There are annotations that should be handled uniformly by all parsers which support them. These include:
Since the annotations mentioned in this section do not have a uniform syntax, each CASL lexer/parser has to understand them explicitly in order to determine the end of an annotation. This holds true even if the parser chooses to ignore the annotation. This implies that CASL lexers/parsers have to be changed when a new such standard annotation is added to CASL.
For a parser created by flex/bison to be able to handle such annotations it is necessary in particular to extend the grammar describing the concrete syntax of CASL such that the annotations occur in the grammar in the places in which the annotation is allowed in the CASL text.
As an example consider the definition of SPEC in [CoF98, p. C.5], the fifth alternative of which reads
SPEC ::= ... | SPEC then SPEC then...then SPEC | ...Writing this out in a left-recursive manner using an auxiliary non-terminal THEN-SPEC and providing rules for the optional semantic annotations THEN-ANNOTATION the part of the grammar could look similar to the following.2
SPEC ::= ... | THEN-SPEC | ... THEN-SPEC ::= SPEC then THEN-ANNOTATION/ SPEC | THEN-SPEC then THEN-ANNOTATION/ SPEC THEN-ANNOTATION ::= "%cons" | "%def"
Because all CASL parsers have to be changed whenever such annotations are added to CASL or their syntax is changed, annotations defined and used by one specific tool should not fall under this category. This note proposes to handle these special purpose annotations similarly to the way comments are handled (cf. the following section).