注释 King 参考手册/语句
外观
此页面正在建设中。
sequence_of_statements ::= statement {statement} statement ::= simple_statement | compound_statement simple_statement ::= null_statement | assignment_statement | exit_statement | procedure_call_statement | wait_statement | return_statement | end_statement compound_statement ::= if_statement | case_statement | loop_statement | declare_statement | task_declare_statement | select_statement null_statement ::= null; statement_identifier ::= direct_name
-
-
State.Seed <- Seed + 1;
assignment_statement ::= variable_name <- expression;
-
-
if Success then
Stick (ID) <- True;
Stick (Wrap.Next (ID) ) <- True;
Owner (ID) <- True;
end if;
if_statement ::= simple_if_statement | extended_if_statement
simple_if_statement ::= if condition then sequence_of_statements [else sequence_of_statements] end if; extended_if_statement ::= if condition then sequence_of_statements else_if condition then sequence_of_statements {else_if condition then sequence_of_statements} else sequence_of_statements end if; condition ::= boolean_expression
-
-
-
case_statement ::= normal_case_statement | exception_handling_case_statement
normal_case_statement ::= case selecting_expression is normal_case_statement_alternative {normal_case_statement_alternative} end case; normal_case_statement_alternative ::= when discrete_choice_list => sequence_of_statements
exception_handling_case_statement ::= case exception_identifier is exception_handling_case_statement_alternative {exception_handling_case_statement_alternative} end case; exception_handling_case_statement_alternative ::= when exception_occurrence_list => sequence_of_statements
- 正常的 case 语句可以出现在任何语句序列中。异常处理 case 语句只能出现在异常处理程序中。
exception_标识符必须是封闭异常处理程序的 when 之后的标识符。
-
Get_Line : loop
exit Get_Line when King.IO.Text.End_Of_Line;
Value <- Value & King.IO.Text.Next'As_Universal;
Get_Line : end loop;
loop_statement ::= loop_statement_identifier : [iteration_scheme] loop sequence_of_statements loop_identifier : end loop; iteration_scheme ::= for loop_parameter_specification | for loop_parameter_specification_no_reverse task | for iterator_specification [task] loop_parameter_specification ::= defining_identifier in [reverse] discrete_subtype_definition [iterator_filter] loop_parameter_specification_no_reverse ::= defining_identifier in discrete_subtype_definition [iterator_filter] discrete_subtype_definition ::= discrete_subtype_indication | range_specification iterator_specification ::= defining_identifier of iterable_name [iterator_filter] iterator_filter ::= when condition
-
-
-
declare_statement ::= declare_statement_identifier: declare declarative_part declare_identifier : begin sequence_of_statements declare_identifier : when identifier => sequence_of_statements declare_identifier : end declare;
-
-
-
task_declare_statement ::= task_declare_statement_identifier : task declare declarative_part task_declare_identifier : begin sequence_of_statements task_declare_identifier : and sequence_of_statements {task_declare_identifier : and sequence_of_statements} task_declare_identifier : end task declare;
-
-
exit Get_Line when King.IO.Text.End_Of_Line;
exit_statement ::= exit loop_name [when condition];
-
-
wait of 1.0;
wait_statement ::= wait wait_mode wait_expression; wait_mode ::= for | of
wait of 语句用于相对时间,并将任务阻塞给定秒数。可以理解为,“等待这么多秒”。wait for 语句接受一个 Duration 值,并将任务阻塞到该时间到达,除非该时间已过去。可以理解为,“等待该时间到达”。持续时间是自纪元以来的秒数,纪元没有定义,但可以使用标准库构建有意义的值。
-
-
select_statement ::= select_statement_identifier : select blocking_call [sequence_of_statements] {select_identifier : or blocking_call [sequence_of_statements]} select_identifier : or wait_statement [sequence_of_statements] select_identifier : end select; blocking_call ::= assignment_statement | procedure_call_statement
阻塞调用是指对任何被动任务的子程序的调用。
-
Message_Queue.Put (Item => ID'Image & " waiting for podium");
King.IO.Text.Put_Line (Line => Message);
procedure_call_statement ::= procedure_prefix [actual_parameter_part]; actual_parameter_part ::= (parameter_association {, parameter_association}) parameter_association ::= formal_parameter_selector_name => explicit_actual_parameter explicit_actual_parameter ::= expression | variable_name
-
-
return State.Seed;
return_statement ::= return [expression] [when condition];
-
-
end Task_Name;
end_statement ::= end task_name;
-
-