Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following Flex and Bison specs (only the rules sections are shown, reasonable assumptions can be made about the missing parts), create the tree

Given the following Flex and Bison specs (only the rules sections are shown, reasonable assumptions can be made about the missing parts), create the tree diagrams including final value for the following input: 3 7 + 3 4 + - n

%% [ \t] ; // ignore all whitespace [0-9]+ {yylval.ival = atoi(yytext); return T_INT;} {return T_NEWLINE;} "+" {return T_PLUS;} "-" {return T_MINUS;} "*" {return T_MULTIPLY;} "^" {return T_EXP;} "/" {return T_DIVIDE;} "(" {return T_LEFT;} ")" {return T_RIGHT;} "n" {return NEG;} "exit" {return T_QUIT;} "quit" {return T_QUIT;} %%

///////////////////////////////////////////////////////////////////////////////////////////////

%% input: /* empty */ | input line ; line: T_NEWLINE | expr T_NEWLINE { printf ("\t%d ", $1); } ; expr: T_INT {$$ = $1; } | expr expr T_PLUS { $$ = $1 + $2; } | expr expr T_MINUS { $$ = $1 - $2; } | expr expr T_MULTIPLY { $$ = $1 * $2; } | expr expr T_DIVIDE { $$ = $1 / $2; } | expr expr T_EXP { $$ = pow ($1, $2); } | expr NEG { $$ = -$1; } ; %%

*Note that the upper case words are terminals and lower case words are non-terminals **The empty option for input is a null production

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

What are the various types of followers?

Answered: 1 week ago

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago

Question

Evaluate the importance of diversity in the workforce.

Answered: 1 week ago

Question

Identify the legal standards of the recruitment process.

Answered: 1 week ago