Previous: Associative Array Attributes, Up: Project File Syntax
case
ConstructionsA case
construction is used in a project file to effect conditional
behavior.
Here is a typical example:
project MyProj is type OS_Type is ("Linux", "Unix", "NT", "VMS"); OS : OS_Type := external ("OS", "Linux"); package Compiler is case OS is when "Linux" | "Unix" => for Default_Switches ("Ada") use ("-gnath"); when "NT" => for Default_Switches ("Ada") use ("-gnatP"); when others => end case; end Compiler; end MyProj;
The syntax of a case
construction is based on the Ada case statement
(although there is no null
construction for empty alternatives).
Following the reserved word case
there is the case variable (a typed
string variable), the reserved word is
, and then a sequence of one or
more alternatives.
Each alternative comprises the reserved word when
, either a list of
literal strings separated by the "|"
character or the reserved word
others
, and the "=>"
token.
Each literal string must belong to the string type that is the type of the
case variable.
An others
alternative, if present, must occur last.
The end case;
sequence terminates the case construction.
After each =>
, there are zero or more constructions. The only
constructions allowed in a case construction are other case constructions and
attribute declarations. String type declarations, variable declarations and
package declarations are not allowed.
The value of the case variable is often given by an external reference (see External References in Project Files).