The package Character_Io whose specificationis given below, provides a function for reading…
The package Character_Io whose specificationis given below, provides a function for reading characters from the terminal. It also provides a procedure for throwing away all the remaining characters on the current line. The package may raise the exception Io_Error.
Another package Look contains the function Read which scans the current input line looking for the punctuation characters comma (,) period (,) and semicolon (;). The function will return the next punctuation character found or raise the exception I l lega l_Punct:uat ion if a non—alphanumeric character is found. If, during the process of scanning the input line, an Io_Error is encountered, then the exception is propagated to the caller of Read. The specificationof Look is given below.
Sketch the package body of Look using the Charac ter_Io package for reading characters from the terminal. On receipt of a legal punctuation character, an illegal punctuation character or an :1 o_3rror exception, the remainder of the input line should be discarded. You may assume that an input line will always have a legal or illegal punctuation character and that Io_Errors occur at random. Using the Look package, sketch the code of a procedure Get-Punctuat ion which will always return the next punctuation character in spite of the exceptions that Look raises. An infinite input stream may be assumed.