Question: Assign - Parser - DESCR - Summer 2 4 Version: Refer to the version in the file name Contents 1 Description of the Parser and

Assign-Parser-DESCR-Summer24
Version: Refer to the version in the file name
Contents
1 Description of the Parser and Respective Grammar............................................................................................. 1
1.1 Problem Background ..................................................................................................................................................1
1.2 Problem Description ...................................................................................................................................................1
1.3 Grammar ....................................................................................................................................................................1
1.4 Tokens........................................................................................................................................................................ 2
2 Parser Input and Output File ...................................................................................................................................2
3 Example Source Program (without begin and end) and Corresponding Parsed Result.................................... 2
3.1 Source program.......................................................................................................................................................... 2
3.2 The result of parsing the above program.................................................................................................................... 2
4 The Test Program to Parse and Submit .................................................................................................................4
5 How to Structure and Organize Your Program ......................................................................................................4
6 What to Turn in .........................................................................................................................................................5
7 Grading Rubrics .......................................................................................................................................................5
1 Description of the Parser and Respective Grammar
1.1 Problem Background
Consider the following grammar, which is the same as the one given on page 175 of the
textbook, except for the first two rules. The first rule, is added for the entire
program structure. will be the starting symbol of your grammar. The second rule,
is added for assignment statements.
The respective parser program modules for all the rules, except for the and
, are given on pages 175-178 of the textbook.
The given parser, written in Java, implements all the above rules except for the
rule.
1.2 Problem Description
a. Run the given parser program using the supplied input to ensure it works correctly
in your environment.
b. Change the parser to also implement the rule.
Notes:
i. The lexical analyzer in this parser must be updated to be inline with the one you have
just developed.
ii. Please use Java 14 or higher.
1.3 Grammar
1.-> program {; } end
2.-> id =
X
Assign-Parser-DESCR-Summer24
Version: Refer to the version in the file name
Last printed 7/11/20241:09 PM Page 2 of 5
Filename: Assign-Parser-DESCR-Summer24-Ver01.00.doc
3.->{(+|-)}
4.->{(*|/)}
5.-> id | int_constant |()
is the starting symbol of the grammar.
1.4 Tokens
ADD_OP
ASSIGN_OP
DIV_OP
END_OF_FILE
IDENT
INT_LIT
LEFT_PAREN
MULT_OP
PROG_BEGIN (corresponds to the lexeme program)
PROG_END (corresponds to the lexeme end)
RIGHT_PAREN
SEMICOLON
SUB_OP
2 Parser Input and Output File
Your lexical analyzer must read the source program statements from a file called
sourceProgram.txt, and to generate the appropriate tokens for the parser.
The parser output must be stored on the parseOut.txt file.
3 Example Source Program (without begin and end) and Corresponding Parsed
Result
3.1 Source program
sumTotal =(sum +47)/ total
Area =(length+width)*
3.2 The result of parsing the above program
Christian Wojteczko, CSCI4200, Spring 2024, Parser
********************************************************************************
Parsing sumTotal =(sum +47)/ total
********************************************************

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!