Menu

[solved] – Question 81083

Write a program that implements the algorithm delimterMatching()

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;

Expert Answer


OR


Leave a Reply

Your email address will not be published. Required fields are marked *