10. Program structure
From Ruby Standard Wiki
(Redirected from Program structure)
10: Program structure
© Information-technology Promotion Agency, Japan (IPA)
10.1 Program
10.1: Program
Syntax
program ::
compound-statement
Semantics
A program is evaluated as follows:
- Push an empty set of bindings onto [[local-variable-bindings]] .
- Evaluate the compound-statement.
- The resulting value is the value of the program.
- Restore the execution context by removing the element from the top of [[local-variable-bindings]], even when an exception is raised and not handled during Step b.
© Information-technology Promotion Agency, Japan (IPA)
10.2 Compound statement
10.2: Compound statement
Syntax
compound-statement ::
statement-list? separator-list?
statement-list ::
statement ( separator-list statement )*
separator-list ::
separator ;*
separator ::
;
| [ line-terminator here ]
Semantics
A compound-statement is evaluated as follows:
- If the statement-list does not occur, the value of the compound-statement is
nil. - If the statement-list occurs, evaluate each statement of the statement-list in the order it appears in the program text.
- If one of the statements of the statement-list is terminated by a jump-expression, terminate the evaluation of the statement-list immediately. None of the following steatements of the statement-list is evaluated. In this case, the value of the compound-statement is undefined.
- If none of the steatements of the statement-list is terminated by a jump-expression, the value of the compound-statement is the value of the last statement of the statement-list.
© Information-technology Promotion Agency, Japan (IPA)
Previous: 9. Scope of variables Next: 11. Expressions