1/39
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Basic Expressions
Literals (constants) and identifiers
Complex expression
Built up recursively from the basic expressions by the application of operators and functions
Parentheses
Group symbols
Operator
Predefined, written in infix form (if binary), with associativity and precendence
Function
Either predefined or user-defined, written in prefix form, operands are viewed as arguments
New Design
Allow programmers to overload built-in operators. Define new infix operators with arbitrary associativity and precedence
Applicative Order Evaluation/Strict Evaluation
The most common rule in programming languages. Correspond to a bottom-up reduction of the syntax tree to a value.
Operands
Applicative Order Evaluation evaluates ____ first and then apply them to operators
Arguments
Applicative Order Evaluation evaluates ____ first and then apply them to functions
Natural Order
Follow the predefined precedence of operators
Left to right
For operators of the same precedence
Infix Notation
Correspond to inorder traversal of the syntax tree
Unary Operator - Infix Notation
Write the operator first followed by the operand
Binary Operator - Infix Notation
Write the 1st operand followed by the operator and then the 2nd operand
Prefix Notation
Correspond to preorder traversal of the syntax tree
unary operator - Prefix Notation
Write the operator first followed by the operand
binary operator - Prefix Notation
Write the operator followed by the 1st operand and then the 2nd operand
Postfix Notatiion
Correspond to postorder traversal of the syntax tree
Unary Operator - Postfix Notion
Write the operand first followed by the operator
Binary Operator - Postfix Notion
Write the 1st operand followed by the 2nd operand and then the operator
GoTo Controversy
Provide a very flexible control. May result in spaghetti code
Modern Syle
Group code into logical blocks. Avoid explicit jumps. Cannot jump into the middle of block or function
Conditional Branch, loop, and function call/return
Modern style avoids explicit jumps except
Boolean test or logical test
Make __ before entering a sequence of statements
EBNF
if-statemnt → if(expression) statement [else statement]
Statement
Can be a single statement, a null statement, or a sequence of statements surrounded by braces
Dangling Else
The ambiguity between the association of an if and an else
Most Closely Nested Rule
The else is to be associated with the closest prior if that doesn’t have an else part
bracketing keyword
Ada dangling-else problems
Loops
Used to perform repetitive operations
Exception
An unusual event. Usually unpredictable. Detectable by software or hardware, required special processing
Variable or class
C++ an exceptional event is represented by
An Exception Handler
A section of program codes executed when a particular exception occurs
Catches
One part of the program _____ and processes the exception that another part of the program throws
Throw (raise)
To signal the fact that an exception has occurred
Exception Handler Selection
Examines error types in exception handlers
North-South
Exception Handler Selection Order
catch-all
Ellipse parameter (…) is a wild card
User-defined classes (or structures)
Use ___ as exception types
Nonlocal Exception Handlers
It is more common to throw an exception inside a function called by a try-block