javaannotationsgrammarbnfebnf

Grammar for Java's annotations


Is there a BNF or EBNF that describes the grammar for Java's annotations?


Solution

  • The authoritative source for Java-related grammar, is, of course, the JLS.

    JLS 18.1 The Grammar of the Java Programming Language

    Annotations:
            Annotation [Annotations]
    
    Annotation:
            @ TypeName [( [Identifier =] ElementValue)]
    
    ElementValue:
            ConditionalExpression
            Annotation
            ElementValueArrayInitializer
    
    ... rest ommitted