Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop, test, and deliver a simple parser that can evaluate statements. STATEMENT PARSER REQUIREMENTS: Develop a grammar and implement a parser which recognizes valid statements

Develop, test, and deliver a simple parser that can evaluate statements.
STATEMENT PARSER REQUIREMENTS:
Develop a grammar and implement a parser which recognizes valid statements as
described below in the assignment specification. You may develop your code using
flex & bison (or C/C++, if approved by the instructor). If you develop/test code on
a different machine than edoras, be sure to use the same versions of the tools
installed on edoras! C/C++ developers, you may use all libraries found in the
directories on edoras. You shall develop a file named README. The README file shall
contain (in addition to the information required at the top of all project files):
* The grammar (use BNF) describing a valid statement (rules specifying what can
be accepted for an expression)
* A listing of all the files in the project
* Instructions on how to compile and run the program
* Issues, if any (potential errors, implementation issues)
* Lessons learned, significant findings
* Any additional information we should know when grading your assignment
SPECIFICATION:
Your program shall
1. Read from a file or from standard input (pick one, state which one in your
README)
2. Scan the input and determine if each statement(s) is valid.
3. Print the statement, and print pass/fail for that statement. If it failed,
print something simple stating why it failed.
4. Each statement is independent from all other statements, once you evaluate
that statement evaluate the next statement until EOF.
Note: id :== identifier, exp :== expression, op :== operator, char :== character
Your compiler will recognize the following as valid statements:
assignment
expression
assignment shall have the form:
id = exp;
expression shall have the form:
id op id {op id}-- any length as long as pairs of op and id are added
Note 1- A parenthesis pair may be used to group any id op id combination.
Therefore:
id op (id op id) op id AND id op id op (id op id)-- valid expressions
Note 2- each id, op,=, and ; will have a space as it's precedent and antecedent
in my test file. The open parenthesis will have a space as it's precedent but it
may or may not have a space immediately following it. The converse is true for the
closing parenthesis (guaranteed a space as it's antecedent but not necessarily
preceding it).
An id shall be made up of any combination of digits and char. The first position of
the identifier must contain a char
A digit is one of: 1,2,3,4,5,6,7,8,9,0
A char is one of: a, b, c, d, e, f, g, h, i, j, k, l m, n, o, p, q, r, s, t, u, v,
w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X,
Y, Z
An op is one of:
+,-,*,/,%
If reading from a file, your program shall read from a file named scanme.txt
which contains a collection of statements (some will be valid, some invalid).
TEAMS:
You shall work on this individually.
ADDITIONAL REQUIREMENTS:
README file - you shall create a README file; consult the instructions for README
file content on the course in Canvas. Points will be taken off for inadequate
README file.
Compiler and make (and Makefile) You shall use flex & bison or gcc/g++(if
approved). You shall use make to read a makefile to compile your program for this
assignment. Name your executable scanner.
Test files I have posted a testfile and a file with correct, expected output for
you to use during development and test. I do recommend that you prepare your own
additional test file(s) and if you do, include those in your turnin.
Make sure that all files (README, source files, header files, Makefile) contains
your name and RedID.
TURNING IN YOUR WORK:
Your project shall source file(s), a Makefile, and a README file. To turn in your
project, all files shall be in your class account on edoras in a directory named
a3(~/a3) and upload a tarball/zipfile which includes all project files to
Blackboard for Project #3, entering any comments in the assignments turnin.

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 Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago