Question
Develop a scanner that will recognize the list of keywords shown in the following section. Use the finite state machine/table approach. The scanner should be
Develop a scanner that will recognize the list of keywords shown in the following section. Use the finite state machine/table approach. The scanner should be implemented as an object; the nexttoken() function should be a member function; the table should be a private data structure within the object. Each time the nexttoken() function is called, it should return the next token in the input stream; when no more text remains in the input stream, it should return an EOF indicator. Your scanner should skip space characters (tab, space, and newline). Write a test program to call the nexttoken(). It should accept input from STDIN, and output to STDOUT, and continue until the scanner function returns an EOF. The test program should output a text label for each token recognized in the input stream, one token per line.
Scanner is NOT case sensitive.
\begin{tabular}{|c|c|} \hline; & SEMICOLOR \\ \hline, & COMMA \\ \hline 1 & LPAREN \\ \hline 1 & RPAREN \\ \hline[ & LBRACKET \\ \hline 1 & RBRACKET \\ \hline\{ & LBRACE \\ \hline} & RBRACE \\ \hline( & LCOMMENT \\ \hline) & RCOMMENT \\ \hline \end{tabular}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started