Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THE QUESTION IS : Explain what does the code do and what is the input. What is the output? What does the code checks? 10:03

THE QUESTION IS :
Explain what does the code do and what is the input.
What is the output?
What does the code checks?
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
10:03 4G lexicalAnalyzer.c /*front.c a lexical analyzer system for simple arithmetic expressions/ include winclude Global declarations Variables/ int charClass; char lexeme [100] char nextChar int lexLen; int token; int nextToken FILE in_fp, *fopen ) Function declarations/void addChar) void getChar ): void getNonBlank) int lex *Character classes #define LETTER 0 #define DIGIT 1 define UNKNOWN 99 Token codes #define INT LIT 10 #define IDENT 11 #define ASSIGN OP 20 #define ADD OP 21 #de fine SUB OP 22 #de fine MULT OP 23 #de fine DIV OP 24 #define LEFT PAREN 25 #define RIGHT PAREN 26 main driver * main) ( Open the input data file and process its contents */ if ((in-fp = fopen ("front.in., "r")) t= NULL ) printf("ERROR- cannot open front.in n") else getChar do lex() } while (nextToken != EOF); Open With Print 10:03 lexicalAnalyzer.c / * *lookup - a function to lookup operators and parentheses and return the token int lookup(char ch) switch (ch) case : addChar) nextToken LEFT PAREN; break; case addChar nextToken = RIGHTPAREN; break ; case + addChar(); nextToken = ADD OP; break; case-i addChar nextToken SUB OP: break; - addChar nextToken MULT OP; break; case /: addChar(); nextToken = DIV OP; break; default: addChar(); nextToken = EOF; break; return nextToken;h addChar a function to add nextChar to lexeme */ void addChar) t if (lexlen /* End of function lex */ 10:03 4G lexicalAnalyzer.c /*front.c a lexical analyzer system for simple arithmetic expressions/ include winclude Global declarations Variables/ int charClass; char lexeme [100] char nextChar int lexLen; int token; int nextToken FILE in_fp, *fopen ) Function declarations/void addChar) void getChar ): void getNonBlank) int lex *Character classes #define LETTER 0 #define DIGIT 1 define UNKNOWN 99 Token codes #define INT LIT 10 #define IDENT 11 #define ASSIGN OP 20 #define ADD OP 21 #de fine SUB OP 22 #de fine MULT OP 23 #de fine DIV OP 24 #define LEFT PAREN 25 #define RIGHT PAREN 26 main driver * main) ( Open the input data file and process its contents */ if ((in-fp = fopen ("front.in., "r")) t= NULL ) printf("ERROR- cannot open front.in n") else getChar do lex() } while (nextToken != EOF); Open With Print 10:03 lexicalAnalyzer.c / * *lookup - a function to lookup operators and parentheses and return the token int lookup(char ch) switch (ch) case : addChar) nextToken LEFT PAREN; break; case addChar nextToken = RIGHTPAREN; break ; case + addChar(); nextToken = ADD OP; break; case-i addChar nextToken SUB OP: break; - addChar nextToken MULT OP; break; case /: addChar(); nextToken = DIV OP; break; default: addChar(); nextToken = EOF; break; return nextToken;h addChar a function to add nextChar to lexeme */ void addChar) t if (lexlen /* End of function lex */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

1. Identify the sources for this conflict.

Answered: 1 week ago

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago