Assignments A sample main program for Project 2 phase 2 is contained in: http://www.cise.ufl.edu/~jnw/COP5555/Assignments/Programs/phase2main.c It reads.

Slides:



Advertisements
Similar presentations
Topics Introduction Types of Errors Exceptions Exception Handling
Advertisements

CSCI 330: Programming Language Concepts Instructor: Pranava K. Jha Control Flow-II: Execution Order.
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
(8.1) COEN Control Structures  Control structure general issues  Compound statements  Selectors (conditional structures) – single – two-way –
Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 13 In a language without exception handling: When an exception occurs, control goes to the operating.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
CSI 3120, Exception handling, page 1 Exception and Event Handling Credits Robert W. Sebesta, Concepts of Programming Languages, 8 th ed., 2007 Dr. Nathalie.
Control Flow C and Data Structures Baojian Hua
PZ07B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ07B - Basic statements Programming Language Design.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 11 Exception Handling and Event Handling.
1 Exception and Event Handling (Based on:Concepts of Programming Languages, 8 th edition, by Robert W. Sebesta, 2007)
Java Software Solutions Foundations of Program Design Sixth Edition
Comparative Programming Languages hussein suleman uct csc304s 2003.
1 Exception Handling Introduction to Exception Handling Exception Handling in PLs –Ada –C++ –Java Sebesta Chapter 14.
PZ11A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ11A - Exception handling Programming Language Design.
Chapter 13, Slide 1 Exception Handling Exception handling is a language feature that allows the programmer to handle runtime "exceptional conditions."
Object Oriented Programming
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
WEEK EXCEPTION HANDLING. Syntax Errors Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while.
Java Software Solutions Lewis and Loftus Chapter 14 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Advanced Flow of Control --
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
Expressions and Statements. Expressions Literals and identifiers are expressions More complex expressions are built from simple expressions by the application.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
ICS 313: Programming Language Theory Chapter 14: Exceptions.
CS212: Object Oriented Analysis and Design Lecture 19: Exception Handling.
Copyright © Curt Hill Flow of Control A Quick Overview.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
1 Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Basic statements Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Exceptions in the Java programming language J. W. Rider.
Eighth Lecture Exception Handling in Java
Exception Handling and Event Handling
PZ11A Programming Language design and Implementation -4th Edition
Exception Handling and Event Handling
Chapter 14: Exception Handling
Exception Handling and
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Designing with Java Exception Handling
Statement-Level Control Structures
Topics Introduction to File Input and Output
Java Programming Language
Control statements Simple statements Basic structured statements
Exceptions.
Programming in C# CHAPTER - 7
Exception Handling Imran Rashid CTO at ManiWeber Technologies.
Exception Handling and Event Handling
Problems Debugging is fine and dandy, but remember we divided problems into compile-time problems and runtime problems? Debugging only copes with the former.
Names and Binding In Text: Chapter 5.
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Java Programming Exceptions CSC 444 By Ralph B. Bisland, Jr.
Tenth step for Learning C++ Programming
Introduction to Programming
Exception and Event Handling
Debugging and Handling Exceptions
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Topics Introduction to File Input and Output
Java Basics Exception Handling.
Exception Handling and Event Handling
Exception Handling.
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Basic statements Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Basic statements Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
PZ07B - Basic statements Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Basic statements Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

Assignments A sample main program for Project 2 phase 2 is contained in: http://www.cise.ufl.edu/~jnw/COP5555/Assignments/Programs/phase2main.c It reads an input program with a filename of form file.g, places executable code in a file named file.c, then execs the g++ compiler to create a file named file, that is the executable version of file.c, which is equivalent in meaning to file.g. My sample program does not put translated garnet code in the program, but it does create a valid C++ program (hello world). Homework Due Tuesday: 6.4, 6.8, 6.29, 6.48

Dijkistra’s Guarded do do B1 -> S1 | B2 -> S2 ... | Bn -> Sn od This behaves like a guarded if that is repeatedly executed until all guards are false. The typical while (B) S is equivalent to do B -> S od

Variations on While Termination test at end rather than beginning of control structure: do S while (B); Mid-loop termination (break) or repitition (continue) for-loop of C for (initialization; go-ahead; update) S; foreach x sequence S CLU Iterator (limited coroutine concept employing yield construct to swap context ).

Goto Considered Harmful Dijkstra’s letter http://www.acm.org/classics/oct95/ (dubbed Goto Statement Considered Harmful) put forth the proposition that goto statements make it difficult to determine how to chart the progress of a process. To help programmers avoid the use of goto, many languages include labelled control structures and allow breaks to exit multiple control constructs.

Exceptions An exception is said to be raised when erroneous computations are requested or detected. Exceptions cause control to transfer without any explicit representation upon the part of the programmer. Most programming languages cause a program to terminate if an exception is raised unless some exception handler is specified. Exception handlers are used to recover a program’s execution (and avoid termination) when an exception has been raised. PL/I had a primitive form of exception handling with its ON conditions that specified an action to take when an error of a given type occurred. ON conditions were executable statements (providing dynamic scope) and any state repair took place in the referencing environment in effect when the ON was executed rather than when the exception occurred. John Goodenough published several papers concerning structured exception handling and some of his ideas were implemented in the CLU programming language. It allowed any block to contain an exception handler which would list named exceptions and associated actions. Raising an exception terminates the current block and initiates execution of the associated exception handler in that block. Unhandled exceptions are raised again in the calling context.

How is an Exception Represented Exceptions may or may not contain data. Exceptions may or may not be arranged in a class hierarchy. Ada exceptions are arranged in a class hierarchty but have no data associated with them. The Dylan language provides a class hierarchy of conditions, some of which contain data and some of which do not. C++ allows any class to be treated as an exception class.

Handling Exceptions The most common approach to exception handling nowadays is to use a try-catch block similar to that of CLU. The try clause specifies the normal execution. If execution of the try clause raises an exception, then an object corresponding to the exception is created and the try clause terminates. Each catch clause can handle one type of exception. If an exception has been raised, the clause trapping the type of exception raised by the try will be executed. Note: this means that the language must be able to determine the class to which the raised exception belongs. This requires some form or run-time type identification (RTTI) mechanism to be provided. If an exception is not handled by a catch block, it is raised again in the context containing the try-catch, and is handled by the nearest dynamically enclosing try-catch. If an exception is handled by a catch block, all major languages nowadays terminate the try-catch after the catch completes. This behavior (known as the termination model) has completely overwhelmed the PL/I behavior (known as the resumption model).

Finalization The term finalization is used to describe a block of code that is to be executed either on termination of a block or when an object is deleted. Java provides a finally clause for its try-catch blocks that will execute on exit from the block no matter whether exit is from the try block or a catch block. The finally clause may close files, or perform other cleanup Those languages that provide finalization of objects do not need to perform object clean-up in an exception handler finalization clause. Such clean-up will be handled as the objects themselves go out of scope. Other forms of finalization may be required for a block, but I’ve yet to see a good example. If you ever find one, please send it to me.