13
Programming Language Features • Syntax • Semantics

Programming Language Features Syntax Semantics. Syntax Diagram

Embed Size (px)

Citation preview

Page 1: Programming Language Features Syntax Semantics. Syntax Diagram

Programming Language Features

• Syntax• Semantics

Page 2: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 3: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 4: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 5: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 6: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 7: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 8: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 9: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 10: Programming Language Features Syntax Semantics. Syntax Diagram

Syntax Diagram

Page 11: Programming Language Features Syntax Semantics. Syntax Diagram

Drawing Gizmo Example// Example program with parameters that displays a T// The T is drawn by the method drawT

public class Driver { private DrawingGizmo pencil; public void drawT() { //Draws a letter T //PRE: Assumes the current position of the pen is the // leftmost postion of the top of the T and the direction // of the pen is 0 degrees //POST: The method leaves the pen at the rightmost // position of the top of the T and the direction of the // pen is 0 degrees pencil.draw(); pencil.turnBy(90); pencil.moveBy(80);

Page 12: Programming Language Features Syntax Semantics. Syntax Diagram

Drawing Gizmo Example //Move the pen to the middle of the top of the T pencil.dontDraw(); pencil.turnBy(-180); pencil.moveBy(40); //Draw the vertical part of the T pencil.draw(); pencil.turnBy(-90); pencil.moveBy(120); //Move pen to the rightmost position of the top of the T //leave the direction of the pen at 0 degrees pencil.dontDraw(); pencil.turnBy(180); pencil.moveBy(120); pencil.turnBy(90); pencil.moveBy(40); pencil.turnBy(-90); }

Page 13: Programming Language Features Syntax Semantics. Syntax Diagram

Drawing Gizmo Example

public Driver() { pencil = new DrawingGizmo(); //Move the pen to the left pencil.dontDraw(); pencil.turnBy(-90); pencil.moveBy(80); pencil.turnBy(90); drawT();

}}