Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EDT:Language Overview04
EGL syntax and scope
The smallest units of meaning in the EGL source code are the tokens. As in other languages, they can be categorized as keywords, identifiers, operators, literals, and special characters. At a more composite level, EGL includes type definitions, expressions, and statements.
One often-used construct is the set-values block, which is a code area that sets annotations and field values and is delimited by curly brackets ({}). Consider the following declaration:
myCarCount NumberOfCars { InputRequired = yes };
The example set-values block declares an InputRequired annotation for the myCarCount
variable.
Set-values blocks are valid in type definitions, statements, expressions, and other set-values blocks.
The scoping rules tell whether a given variable, constant, parameter, or function is visible to an expression.
The order of priority for resolving a reference is as follows:
- First in precedence are declarations that are local to the function where the expression resides. This category includes variable, constant, and function-parameter declarations.
- Second in precedence are declarations that are outside of a function but are inside the type where the expression resides. Each field is program global, which means that it is accessible to all members in the type. This category includes variable, constant, program-parameter, and function declarations.
- Third are declarations that are outside a function but are inside a library that is accessible to the expression. Each public field is run-unit global, which means that it is accessible to all functions that run as a unit such that an unhandled exception terminates the unit. This category includes the variable, constant, and function declarations in the library. Those declarations are program global to other functions in the same library.
A reference in an expression can include a series of identifiers, with a period (.) separating one from the next. Here is an expression in which each operand is fully qualified:
autoPkg.AutoLibrary.numberInFleet – autoPkg.CarLibrary.DebtRecord.carLimit
As appropriate, the identifiers can include a package name, the name of a container type, the name of a contained type, and a field name. A contained type can itself be a container type, to any level of depth.
The package and type names are especially useful for accessing values and functions in a library, as suggested in the example. However, for library access you can code a use statement, which offers the convenience of referring more directly to the declarations inside the library.
If a local declaration has the same name as the program-global declaration, only the local declaration is visible to the expression; but you can override that rule by using the this keyword.
♦ Previous: Packages and type-name resolution
♦ First: Introduction