mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/while'
Added documentation to statement reference. * origin/topic/jsiwek/while: Add 'while' statement to Bro language. BIT-1315 #merged
This commit is contained in:
commit
abcb8e7c95
13 changed files with 374 additions and 4 deletions
|
@ -45,8 +45,11 @@ Statements
|
|||
| | file |
|
||||
+----------------------------+------------------------+
|
||||
| :bro:keyword:`for`, | Loop over each |
|
||||
| :bro:keyword:`next`, | element in a container |
|
||||
| :bro:keyword:`break` | object |
|
||||
| :bro:keyword:`while`, | element in a container |
|
||||
| :bro:keyword:`next`, | object (``for``), or |
|
||||
| :bro:keyword:`break` | as long as a condition |
|
||||
| | evaluates to true |
|
||||
| | (``while``). |
|
||||
+----------------------------+------------------------+
|
||||
| :bro:keyword:`if` | Evaluate boolean |
|
||||
| | expression and if true,|
|
||||
|
@ -563,6 +566,36 @@ Here are the statements that the Bro scripting language supports.
|
|||
See the :bro:keyword:`return` statement for an explanation of how to
|
||||
create an asynchronous function in a Bro script.
|
||||
|
||||
.. bro:keyword:: while
|
||||
|
||||
A "while" loop iterates over a body statement as long a given
|
||||
condition remains true.
|
||||
|
||||
A :bro:keyword:`break` statement can be used at any time to immediately
|
||||
terminate the "while" loop, and a :bro:keyword:`next` statement can be
|
||||
used to skip to the next loop iteration.
|
||||
|
||||
Example::
|
||||
|
||||
local i = 0;
|
||||
|
||||
while ( i < 5 )
|
||||
print ++i;
|
||||
|
||||
while ( some_cond() )
|
||||
{
|
||||
local finish_up = F;
|
||||
|
||||
if ( skip_ahead() )
|
||||
next;
|
||||
|
||||
[...]
|
||||
|
||||
if ( finish_up )
|
||||
break;
|
||||
|
||||
[...]
|
||||
}
|
||||
|
||||
.. _compound statement:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue