http://seed7.sourceforge.net/manual/index.htm
Depois vá para a seção: 15. ERRORS
Detalhes da seção:
Exemplo
case
currChar of
when {'A' .. 'Z'} | {'a' .. 'z'}:
characterClass := LETTER;
when {'0' .. '9'}:
characterClass := DIGIT;
when {'!', '$', '%', '&', '*', '+', ',',
'-', '.', '/',
':', ';', '<', '=', '>', '?', '@',
'\', '^', '`',
'|', '~'}:
characterClass := SPECIAL;
when {'(', ')', '[', ']', '{', '}'}:
characterClass := PAREN;
when {'"'}: # Also possible '\"'
characterClass := APPOSTROPHE;
when {'''}:
# Also possible '\''
characterClass := QUOTE;
otherwise:
characterClass := ILLEGAL;
end
case;
Semântica:
A expressão entre "case" e "of" é analisada.
Quando o resultado "casa" com algum elemento entre as várias
instruções "when" as instruções logo após os : (dois-pontos) são executadas e a
instrução "case" é finalizada.
Quando o valor não "casar" com nenhum elemento entre as
várias instruções "when", então as instruções logo após os :
(dois-pontos) do bloco "otherwise" são executadas e a instrução "case" é finalizada.
Quando o valor não "casar" com nenhum elemento entre as
várias instruções "when" e não houver a instrução "otherwise" a instrução "case" é finalizada.
Sintaxe:
case_statement
::=
'case'
expression 'of'
{ 'when' set_expression ':'
statement }
[ 'otherwise' ':'
statement ]
'end'
'case' .
set_expression
::=
expression
.
Declaration:
$
syntax expr: .case.().of.().end.case is -> 25;
$
syntax expr: .case.().of.().otherwise. : .().end.case is -> 25;
$
syntax expr: .case.().of.end.case is -> 25;
$
syntax expr: .when.(). : .().() is
<- 60;
$
syntax expr: .when.(). : .() is
<- 60;
const
proc: CASE_DECLS (in type: aType) is func
local
var type: WHEN_RESULT is void;
var type: WHEN_PROC is void;
var type: SELECTOR_TYPE is void;
begin
WHEN_RESULT := newtype;
WHEN_PROC := (func WHEN_RESULT);
SELECTOR_TYPE := set of aType;
const proc: case (ref aType param) of end
case is noop;
const proc: case (ref aType param) of
(ref WHEN_PROC param)
end case
is action "PRC_CASE";
const proc: case (ref aType param) of
(ref WHEN_PROC param)
otherwise : (ref proc param)
end case
is action "PRC_CASE_DEF";
const proc: (ref WHEN_RESULT param) ::=
enumlit is action "ENU_GENLIT";
const WHEN_RESULT: WHEN_EMPTY (attr aType)
is enumlit;
const proc: (ref WHEN_PROC param) ::= (ref
WHEN_RESULT param) is action
"ENU_CREATE";
const WHEN_PROC: when (ref SELECTOR_TYPE
param) : (ref proc param) is
WHEN_EMPTY(aType);
const WHEN_PROC: when (ref SELECTOR_TYPE
param) : (ref proc param)
(ref WHEN_PROC
param) is
WHEN_EMPTY(aType);
end func;
CASE_DECLS(integer);
CASE_DECLS(char);
Exemplo
if
sumValue < minimum then
factor := sumValue;
sumValue := minimum;
elsif
sumValue > maximum then
factor := -sumValue;
sumValue := maximum;
else
factor := 0;
end
if;
Semântica:
A expressão entre "if" e "then" é processada.
Quando tal expressão resulta em TRUE as instruções seguintes a "then" são executadas e a
instrução "if" é finalizada.
Se a expressão de "if" e todas expressões "elsif" resultarem em FALSE as instruções do bloco "else" serão executadas e
a instrução "if" é finalizada.
Se a expressão de "if" e todas expressões "elsif" resultarem em FALSE e não existir um "else" a instrução "if" é finalizada.
Sintaxe:
if_statement
::=
'if'
expression 'then'
statement
{
'elsif' expression 'then'
statement }
[
'else'
statement ]
'end'
'if' .
A expressão deve ser do tipo "boolean".
Declaration:
$
syntax expr: .if.().then.().end.if is
-> 25;
$
syntax expr: .if.().then.().().end.if is
-> 25;
$
syntax expr: .elsif.().then.() is
<- 60;
$
syntax expr: .elsif.().then.().() is
<- 60;
$
syntax expr: .else.() is <- 60;
const
type: ELSIF_RESULT is newtype;
const
proc: (ref ELSIF_RESULT param) ::= enumlit is
action "ENU_GENLIT";
const
ELSIF_RESULT: ELSIF_EMPTY is enumlit;
const
type: ELSIF_PROC is
(func ELSIF_RESULT);
const
proc: (ref ELSIF_PROC param) ::= (ref ELSIF_RESULT param) is action
"ENU_CREATE";
const
proc: if (in boolean param) then
(in proc param)
end if is action
"PRC_IF";
const
proc: if (in boolean param) then
(in proc param)
(in ELSIF_PROC param)
end if is action
"PRC_IF_ELSIF";
const
ELSIF_PROC: elsif (in boolean param) then
(in proc param) is action "PRC_IF";
const
ELSIF_PROC: elsif (in boolean param) then
(in proc param)
(in ELSIF_PROC param) is action "PRC_IF_ELSIF";
const
ELSIF_PROC: else
(in void param) is ELSIF_EMPTY;
const
proc: if TRUE then (in void param) end
if is noop;
const
proc: if TRUE then (in void param) (in
ELSIF_PROC param) end if is noop;
const
proc: if FALSE then (in proc param) end if is noop;
const
proc: if FALSE then (in proc param) (in ELSIF_RESULT param) end if is noop;
const
ELSIF_PROC: elsif TRUE then (in void
param) is
ELSIF_EMPTY;
const
ELSIF_PROC: elsif TRUE then (in void param) (in ELSIF_PROC param) is
ELSIF_EMPTY;
const
ELSIF_PROC: elsif FALSE then (in proc param) is ELSIF_EMPTY;
const
ELSIF_PROC: elsif FALSE then (in proc param) (in ELSIF_RESULT param) is
ELSIF_EMPTY;