assistance-engine/docs/developer.avapframework.com/chapter9_29.md

46 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Simple Statements
In AVAP, a simple statement consists of a single logical line. Multiple simple statements can be placed on a single line, separated by semicolons. The syntax for simple statements is:
```javascript
simple_stmt ::= expression_stmt
| assert_stmt
| assignment_stmt
| augmented_assignment_stmt
| annotated_assignment_stmt
| pass_stmt
| del_stmt
| return_stmt
| yield_stmt
| raise_stmt
| break_stmt
| continue_stmt
| import_stmt
| future_stmt
| global_stmt
| nonlocal_stmt
| type_stmt
```
Heres a brief overview of each type of simple statement:
* Expression Statement ( `expression_stmt` ): Executes an expression, which can be used for operations or calling functions.
* Assert Statement ( `assert_stmt` ): Used for debugging purposes to test conditions.
* Assignment Statement ( `assignment_stmt` ): Assigns values to variables or data structures.
* Augmented Assignment Statement ( `augmented_assignment_stmt` ): Performs an operation on a variable and assigns the result back to the variable (e.g., `x += 1` ).
* Annotated Assignment Statement ( `annotated_assignment_stmt` ): Used for assigning values with annotations (e.g., type hints).
* Pass Statement ( `pass_stmt` ): A placeholder that does nothing; used for syntactic requirements.
* Del Statement ( `del_stmt` ): Deletes variables, items, or attributes.
* Return Statement ( `return_stmt` ): Exits a function and optionally returns a value.
* Yield Statement ( `yield_stmt` ): Produces a value from a generator function.
* Raise Statement ( `raise_stmt` ): Raises exceptions for error handling.
* Break Statement ( `break_stmt` ): Exits the closest enclosing loop.
* Continue Statement ( `continue_stmt` ): Skips the current iteration of the closest enclosing loop.
* Import Statement ( `import_stmt` ): Imports modules or specific components from modules.
* Future Statement ( `future_stmt` ): Enables features from future versions of Python.
* Global Statement ( `global_stmt` ): Declares variables as global within a function.
* Nonlocal Statement ( `nonlocal_stmt` ): Declares variables as non-local, affecting scope in nested functions.
* Type Statement ( `type_stmt` ): Declares or checks types (e.g., type hints).
Each simple statement performs a specific task and contributes to the overall functionality of the AVAP program.