Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Makefile link: https://drive.google.com/file/d/1Ay8BYb6s4eXzqDDVZJ8lX38ReRrUwXiH/view?usp=sharing) In this prelab you will convert c++ assignment and declaration blocks to python assignment and declaration blocks. 1.Syntax Analysis Declaration blocks Declaration

(Makefile link:

https://drive.google.com/file/d/1Ay8BYb6s4eXzqDDVZJ8lX38ReRrUwXiH/view?usp=sharing)

In this prelab you will convert c++ assignment and declaration blocks to python assignment and declaration blocks.

1.Syntax Analysis Declaration blocks Declaration blocks start with int. After the int or block there can be a variable with initialization or without initialization For the variable with initialization, print on the screen without a int and semicolon For the variable without initialization, do not print anything.

c++ input python output int aa=9,a,bxc=3; aa=9 bxc=3 Assignment blocks There can be any combination of +,-,* and / operations. Also, it can contain ().

c++ input python output b=c+(bxc*2)/7; b=c+(bxc*2)/7

2.Semantic Analysis In the semantic analysis part you will check 2 errors. You can assume that only one of the errors will be in one input file. If there is an error in the input file, only the error message will print on the screen. You can assume that the first line is Line 0. 1. Print a warning message if a value of variable is accessed without initialization. c++ input output int x,y=3,a=5; Line 1: variable x is used without initialized y=x+2; 2. Print a warning message if a variable is used without declaration c++ input output int x,y=3,a=5; Line 1: variable t is not declared t=y+2; int x,y=3,a=5; Line 1: variable t is not declared y=t+2; 3. Output: Example input and output files are provided to you. Be careful, those are examples so do not forget to test your code with different inputs. exampleInput.txt: In this file, there are valid nputs. Your output should be the same with exampleOutput.txt file. There are example files that contain input with errors. Your program should print the correct error message on the screen. How to test your code: Your code should be compiled with the Makefile given to you. Do not change the Makefile. run your code redirect output to a file ./prelab3 exampleInput.txt > output.txt check whether your output and our output file is same or not by using diff command on terminal diff output.txt exampleOutput.txt -wB if your output and our output is same there will be no message on the screen Otherwise, the difference will be shown on the screen. How to submit your code Zip and upload only your lex and yacc file which has name: prelab3.l prelab3.y

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_2

Step: 3

blur-text-image_3

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

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions

Question

2. What are the different types of networks?

Answered: 1 week ago