Figure 2.3. Concrete Syntax for Identifiers
Figure 2.3, “Concrete Syntax for Identifiers” presents the concrete syntax and lexical definitions of BIR identifiers. They are categorized into two: (1) normal identifiers, and (2) type variable identifiers. There are two kinds of normal identifiers: (a) basic identifiers, and (b) Bogor identifiers. Basic identifiers are similar to Java identifiers. That is, they cannot have sequences of characters that are equal to BIR keywords, boolean literals, the null literal, and the float and double special literals (see bir-keywords).
Bogor identifiers are provided for convenience when translating from other languages because one can encode almost anything inside the Bogor identifiers. For example, when translating a Java program that has system as a local variable identifier, the identifier will clash with the BIR "system" terminal symbol (i.e., the BIR system keyword). One can resolve this issue by always encode Java identifiers inside one of the Bogor identifiers. For example, one can use a convention to always encode Java local variables names using the "[|"..."|]" identifier delimiters to avoid name clashes (e.g., "[|system|]").
Type variable identifiers can only be used as variables for types (see generic types).
Notice that in the lexical definitions for identifiers in Figure 2.3, “Concrete Syntax for Identifiers”, we use parameterized terminal symbols for simplicity (e.g. <bogor-id-char(x)>). Notice also that we use escape characters that are usually used in other programming languages such as Java (e.g., '\n' and the unicode escape characters). For simplicity, we define identifiers with -id as their suffixes to be equivalent as <id>, unless specified otherwise.
Abstract Syntax Tree. Identifier does not have dedicated Java abstract syntax tree class, instead, we use java.lang.String objects to represent BIR identifier.