Basic Statements

Sather - Language Specification
Prev |  | Next

# Chapter 5. Basic Statements

    statement_list ==>
            [ statement ] { ; [ statement ] }

    statement ==>
            declaration_statement | assign_statement | if_statement | return_statement | case_statement | typecase_statement | expression_statement | loop_statement | yield_statement | quit_statement | protect_statement | raise_statement | assert_statement

The body of a method is a semicolon separated list of statements. The statements in a statement list are executed sequentially unless a return, quit, yield, or raise statement is executed. In a routine with a return value, the final statement along each execution path must be either a return statement or a raise statement.

# 5.1. Declaration statements

Example 5-1. Example:

    i,j,k:INT

    declaration_statement ==>
            identifier_list : type_specifier

Declaration statements are used to declare the type of one or more local variables. Local variables may also be declared in assignment statements (See Assignment statements). The scope of a local variable declaration begins at the declaration and continues to the end of the statement list in which the declaration occurs. The scope of method arguments is the entire body of the method. Local variables shadow routines in the class which have the same name and no arguments. Within the scope of a local variable it is illegal to declare another local variable with the same name. Local variables are initialized to void (See void expressions) when the containing method is called; they are not re-initialized when the declaration is encountered in the flow of control.

Prev | Home | Next
Stubs | Up | Assignment statements