From 8868b5fa2e8b9f40a31035c51519cce40e73f079 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 2 Nov 2020 13:37:32 -0700 Subject: define compile-time vs runtime behavior --- language/statements/structure.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 language/statements/structure.rst (limited to 'language/statements/structure.rst') diff --git a/language/statements/structure.rst b/language/statements/structure.rst new file mode 100644 index 0000000..9330bf6 --- /dev/null +++ b/language/statements/structure.rst @@ -0,0 +1,21 @@ +Structure Statements +^^^^^^^^^^^^^^^^^^^^ + +.. crowbar:element:: StructureStatement <- IfStatement / SwitchStatement / WhileStatement / DoWhileStatement / ForStatement + + A structure statement creates some nonlinear control structure. + There are several types of these structures. + +.. crowbar:element:: IfStatement <- 'if' '(' Expression ')' Block ('else' Block)? + + An if statement allows some action to be performed only sometimes, based on the value of the expression. + + Compile-time Behavior: + + If the expression does not have type bool, the compiler must emit an error. + + Runtime Behavior: + + First, the expression is evaluated. + If the expression evaluates to a ``bool`` value of ``true``, then the first block will be executed. + If the expression evaluates to a ``bool`` value of ``false``, either the second block is executed or nothing is executed. -- cgit v1.2.3