Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this prelab, you will implement a lex and yacc code that will read a C code snippet that contains declarations and comparisons. In the

In this prelab, you will implement a lex and yacc code that will read a C code snippet that contains
declarations and comparisons. In the input code, there can be any number of if statements and
declarations. Your program should cover all the valid inputs, and reject the invalids.
ATTENTION: Zip your lex, yacc and submit to Yulearn. Your code can be compiled with the
Makefile provided to you. Be sure that Makefile works properly.
1) If statement
Contains a comparison part and body part
The comparison part can contain 1 comparison.
o There will be no && and || operation like we did in prelab2.
Comparison will be only ==
.
If the body can contain other if statements or can contain declarations.
Note: There will be no else if or else In the input file
2) Declaration statement
There can be 2 types of declarations: int and string
.
o You can assume that there will be only 1 declaration per line.
int a;
string b;
o In other words, the input file will not contain declarations like:
int a,b,c;
string a,b;
3) Invalid comparison: The input file can contain invalid comparisons. You should detect
and print an error message for that.
The comparisons should be between the same types. If it is not print an error
message: Type mismatch in line x

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 Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions