2.7. Enumeration Declaration

Figure 2.10. Concrete Syntax for Enumeration Declaration

[59] <enum> ::= "enum" <enum-id> "{" <enum-elems> "}"  
[60] <enum-elems> ::= <enum-elem-id> ("," <enum-elem-id>)*  

Figure 2.10, “Concrete Syntax for Enumeration Declaration” presents the concrete syntax for BIR enumeration type declarations. An enumeration type declaration consists of declarations of its identifier <enum-id> and its elements. The elements represents the valid values of the enumeration type. The fully qualified name of an enumeration element is <enum-id> "." <enum-elem-id>. An enumeration element can only be referred using its fully qualified name, except in virtual tables on enumerations (see virtual table declaration).

Namespace. The namespace for enumerations is the global namespace that is shared with constants, records, extensions, type-aliases, global variables, threads and functions, virtual tables, and functional expressions. Each enumeration type has its own namespace for its elements.

Examples. 

              
  enum Day {
    Sunday, Monday, Tuesday, Wednesday, Thursday, Friday
  }
    

Abstract Syntax Tree. 

Figure 2.11. Java AST for Enumeration Declaration

Java AST for Enumeration Declaration
[ .gif, .svg ]

The Java AST class for BIR enumeration is the EnumDefinition class. There is no dedicated Java AST class for enumeration element, instead, the java.lang.String class is used.