Question: Assign - Parser - DESCR - Summer 2 4 Version: Refer to the version in the file name Contents 1 Description of the Parser and
AssignParserDESCRSummer
Version: Refer to the version in the file name
Contents
Description of the Parser and Respective Grammar.............................................................................................
Problem Background
Problem Description
Grammar
Tokens........................................................................................................................................................................
Parser Input and Output File
Example Source Program without begin and end and Corresponding Parsed Result....................................
Source program..........................................................................................................................................................
The result of parsing the above program....................................................................................................................
The Test Program to Parse and Submit
How to Structure and Organize Your Program
What to Turn in
Grading Rubrics
Description of the Parser and Respective Grammar
Problem Background
Consider the following grammar, which is the same as the one given on page 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 of the textbook.
The given parser, written in Java, implements all the above rules except for the
rule.
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 or higher.
Grammar
program ; end
id
X
AssignParserDESCRSummer
Version: Refer to the version in the file name
Last printed : PM Page of
Filename: AssignParserDESCRSummerVerdoc
id intconstant
is the starting symbol of the grammar.
Tokens
ADDOP
ASSIGNOP
DIVOP
ENDOFFILE
IDENT
INTLIT
LEFTPAREN
MULTOP
PROGBEGIN corresponds to the lexeme program
PROGEND corresponds to the lexeme end
RIGHTPAREN
SEMICOLON
SUBOP
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.
Example Source Program without begin and end and Corresponding Parsed
Result
Source program
sumTotal sum total
Area lengthwidth
The result of parsing the above program
Christian Wojteczko, CSCI Spring Parser
Parsing sumTotal sum total
