10. Program structure

From Ruby Standard Wiki

(Redirected from Program structure)
Jump to: navigation, search
10: Program structure

10.1 Program

10.1: Program

Syntax

 program ::
     compound-statement

Semantics

A program is evaluated as follows:

  1. Push an empty set of bindings onto [[local-variable-bindings]] .
  2. Evaluate the compound-statement.
  3. The resulting value is the value of the program.
  4. 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.

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:

  1. If the statement-list does not occur, the value of the compound-statement is nil.
  2. If the statement-list occurs, evaluate each statement of the statement-list in the order it appears in the program text.
  3. 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.
  4. 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.

Navigation

Previous: 9. Scope of variables Next: 11. Expressions

Personal tools