Question: Write a program that implements the algorithm delimterMatching() from section 4.1. delimiterMatching(file) read character ch from file; while not end of file if ch is
Write a program that implements the algorithm delimterMatching() from section 4.1.
delimiterMatching(file)
read character ch from file;
while not end of file
if ch is '(', '[', or '{'
puch(ch);
else if ch is ')', ']', or '}'
if ch and popped off delimiter do not match
failure;
else if ch is '/'
read the next character;
if this character is '*'
skip all characters until '*/' is found and report an error
if the end of the file is reached before '*/' is encountered;
else ch = the character read in;
continue; // go to the beginning of the loop;
// else ignore the other characters;
read next character ch from file;
if stack is empty
success;
else failure;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
