aboutsummaryrefslogtreecommitdiff
path: root/language/statements/index.rst
blob: 93ff6902c77f17db590ef0ebbaecf4614eb1019a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Statements
----------

.. crowbar:element:: Block <- '{' Statement* '}'

    Compile-time Behavior:

    A block is a possibly-empty sequence of statements surrounded by curly braces.
    Any declaration or definition within the block must not be visible outside of the block.

    Runtime Behavior:

    When a block is executed, each of the containing statements, in linear order, is executed.

.. crowbar:element:: Statement <- VariableDefinition / StructureStatement / FlowControlStatement / AssignmentStatement / FragileStatement / ExpressionStatement / EmptyStatement

    Crowbar has many different types of statement.

.. crowbar:element:: EmptyStatement <- ';'

    Compile-time Behavior:

    None.

    Runtime Behavior:

    None.

.. crowbar:element:: FragileStatement <- 'fragile' Statement

    Some behaviors are difficult to ensure the robustness of at compile time, and these behaviors are defined in this specification as *fragile*.
    Fragile behaviors used outside of fragile statements should produce a compiler error.

    Compile-time Behavior:

    Fragile behaviors used inside a fragile statement must not produce a compiler error for their fragility.
    Nesting fragile statements should produce a compiler error.

    Runtime Behavior:

    The contained statement is executed.

.. crowbar:element:: ExpressionStatement <- Expression ';'

    Compile-time Behavior:

    If the expression is not a function call, the compiler may emit a warning.

    Runtime Behavior:

    The expression is evaluated and the resulting value is discarded.
    Function calls must be fully evaluated, but expressions that are not function calls may be optimized out.

..  toctree::
    :maxdepth: 1

    variables
    structure
    flow-control
    assignment