Answered step by step
Verified Expert Solution
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 CC if approved by the instructor If you developtest code on
a different machine than edoras, be sure to use the same versions of the tools
installed on edoras! CC 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
Read from a file or from standard input pick one, state which one in your
README
Scan the input and determine if each statements is valid.
Print the statement, and print passfail for that statement. If it failed,
print something simple stating why it failed.
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 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 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:
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 scanmetxt
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 gccgif
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 files 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 files 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
a~a and upload a tarballzipfile which includes all project files to
Blackboard for Project # entering any comments in the assignments turnin.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started