cs480 091411
cs480 091411
<expr> <term> + <expr> <expr> <term> <term> <unit> * <term> <term> <unit> <unit> num <expr> <expr> <unit> ( <expr> )
cs480(Prasad)
L2Syntax
Extended BNF
<expr> <term> ( + <term> ) * <term> <unit> ( * <unit> ) * <unit> num | ( <expr> )
<expr> <expr> <expr> <op> <expr> ( <op> <expr> ) * ( <expr> ) num +|*
cs480(Prasad)
L2Syntax
cs480(Prasad)
L2Syntax
(ambiguous)
<expr> <expr> + <expr> | <expr> * <expr> | ( <expr> ) | <variable> | <constant> <variable> <constant>
cs480(Prasad)
x|y|z 0|1|2
L2Syntax 4
1L
cs480(Prasad)
L2Syntax
Left associative +
ldarg.0 ldarg.1 add ldarg.2 add
Mixing int and double variables (requiring coercion code) for static f(double a,int i, j) i+j*a
ldarg.1 conv.r8 ldarg.2 conv.r8 ldarg.0 mul add
Translation algorithm essence trans (e1 * e2) = trans(e1) [type coercion code?] trans(e2) [type coercion code?] trans(*) Map grammar rules to control structures
E.g., alternatives, while-loop, etc
Mixing int and double variables (requiring coercion code) for static f(double a,int i, j) i+j*a
iload_2 i2d iload_3 i2d dload_0 dmul dadd
Object-Oriented Programming
Programming with Data Types to enhance reliability and productivity (through reuse and by facilitating evolution)
CS480 (Prasad)
L3OOP
17
Object (instance)
State (fields) Behavior (methods) Identity
Class
code describing implementation of an object
Inheritance Polymorphism
CS480 (Prasad)
L3OOP
18
Abstraction
General: Focus on the meaning
Suppress irrelevant implementation details
Programming Languages :
Assign names to recurring patterns
Value Expression Statements Control Value/ops
CS480 (Prasad)
Data Abstraction
Focus on the meaning of the operations (behavior), to avoid over-specification. The representation details are confined to only a small set of procedures that create and manipulate data, and all other access is indirectly via only these procedures.
Facilitates code evolution.
CS480 (Prasad) L3OOP 20
Restrict users from making unwarranted assumptions about the implementation. Reserve right to change representation to improve performance, (maintaining behavior).
CS480 (Prasad)
L3OOP
21