Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this C code. We are modifying the existing files given to create a predictive parser based on a BNF. All the

Please help me with this C code. We are modifying the existing files given to create a predictive parser based on a BNF. All the code needed is in the file given; however we are to only edit the files: 'parser.c', 'expr.c', 'prog.c', and 'stmt.c' . ALL OTHER FILES STAY THE SAME.

Thank You!

-----------------------------------------------------------------------------------------------------------------

The file: drive.google.com/file/d/1ZkOEkaILlEhbSeI4RNfQDKN9oB42YHhP/view?usp=sharing

image text in transcribed

image text in transcribed

image text in transcribed

contains starter code for a parser. The parser is for a simple language. In this language: a program is one or more statements, and each statement must end with a"" e a statement is either a function call with exactly one argument, or an assignment statement . an expression is either a function call with exactly one argument, a variable, or a non-negative integer (in other words, a string of digits) ere's an example program that shows most of the features of the language x - abs (z); print(x); Note that functions calls always contain exactly one expression within parentheses Your job is to complete the code in prog.tar so that it will parse a program in this language, and then print it. The file prog.tar contains not just code, but a Makefile and some test files you can run Please do the following copy the tar file to your own directory, untar it, and understand it. Start with main.d compile the code (see the Makefile) to make sure it compiles for you write a BNF grammar for the language edit file parser.c to create a predictive parser based on your BNF (see comment "YOUR CODE HERE" edit your parser so that it returns a prog' object, which in turn contains 'stmt' and 'expr' objects edit files prog.c, stmt.c, and expr.c to implement the print functions in those files (see comments YOUR CODE HERE" Do NOT edit any other files, and do not edit the files above except as explained in the comments. When l test your code I will only use your parser.c, prog.c, stmt.c, and expr.c files. The main program will call your parser to get a prog' object, then print the 'prog' object to reconstruct the program from its parse tree. You can test your code using the program run-tests.sh that is provided in the tar file. This program runs the parser on multiple input files, and provides formatted output. Here's what happens when I use run- tests.sh contains starter code for a parser. The parser is for a simple language. In this language: a program is one or more statements, and each statement must end with a"" e a statement is either a function call with exactly one argument, or an assignment statement . an expression is either a function call with exactly one argument, a variable, or a non-negative integer (in other words, a string of digits) ere's an example program that shows most of the features of the language x - abs (z); print(x); Note that functions calls always contain exactly one expression within parentheses Your job is to complete the code in prog.tar so that it will parse a program in this language, and then print it. The file prog.tar contains not just code, but a Makefile and some test files you can run Please do the following copy the tar file to your own directory, untar it, and understand it. Start with main.d compile the code (see the Makefile) to make sure it compiles for you write a BNF grammar for the language edit file parser.c to create a predictive parser based on your BNF (see comment "YOUR CODE HERE" edit your parser so that it returns a prog' object, which in turn contains 'stmt' and 'expr' objects edit files prog.c, stmt.c, and expr.c to implement the print functions in those files (see comments YOUR CODE HERE" Do NOT edit any other files, and do not edit the files above except as explained in the comments. When l test your code I will only use your parser.c, prog.c, stmt.c, and expr.c files. The main program will call your parser to get a prog' object, then print the 'prog' object to reconstruct the program from its parse tree. You can test your code using the program run-tests.sh that is provided in the tar file. This program runs the parser on multiple input files, and provides formatted output. Here's what happens when I use run- tests.sh

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

Explain the meaning of the SQL EXISTS comparison operator.

Answered: 1 week ago

Question

3. What are potential solutions?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago