case construction is used in a project file to effect conditional
Here is a typical example:
project MyProj is type OS_Type is ("GNU/Linux", "Unix", "NT", "VMS"); OS : OS_Type := external ("OS", "GNU/Linux"); package Compiler is case OS is when "GNU/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).
The case expression must be a typed string variable.
Each alternative comprises the reserved word
when, either a list of
literal strings separated by the
"|" character or the reserved word
others, and the
Each literal string must belong to the string type that is the type of the
others alternative, if present, must occur last.
=>, there are zero or more constructions. The only
constructions allowed in a case construction are other case constructions,
attribute declarations and variable declarations. String type declarations and
package declarations are not allowed. Variable declarations are restricted to
variables that have already been declared before the case construction.
The value of the case variable is often given by an external reference (see External References in Project Files).