Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Workbench * V Workbench x PA 2 Submission: Building an SPI x PA3.cpp - /* Implementation of R x () Language-Interpreter/parse.cpp x _ week 10
Workbench * V Workbench x PA 2 Submission: Building an SPI x PA3.cpp - /* Implementation of R x () Language-Interpreter/parse.cpp x _ week 10 - Google Docs x Topic: Wee courses/28123/assignments/324734?module_item_id=1069286 g 20... > Assignments > PA 2 Submission: Building an SPL Parser PA 2 Submission: Building an SPL Parser Due Sunday by 11:59pm Points 20 Submitting an external tool Available Mar 8 at 9am - Apr 5 at 11:59pm In this programming assignment, you will be building a parser for the Simple Perl-Like (SPL) programming language. The syntax definitions of SPL programming language are given below using EBNF notations. Your implementation of a parser to the language is based on the following grammar rules specified in EBNF notations. 1. Prog :- StmtList 2. StmtList := Stmt ;[ Stmt; ] 3. Stmt := AssignStme | WriteLnStmt | IfStemt 4. WriteLnStmt := writeIn (ExprList) 5. IfStemt ::= if (Expr) '['StmtList "]' [ else '[ StmtList "]' ] 6. AssignStmt :- Var - Expr 7. Var := NIDENT | SIDENT 8. Exprlist ::= Expr [, Expr ] 9. Expr := RelExpr [(-eql==) RelExprl 0. RelExpr :- AddExpr [ (-It |-gt | ) AddExpr ] 1. AddExpr :: MultExpr { ( + | - |.) MultExpr 12. MultExpr := ExponExpr [ (* 1/ |"*) ExponExpr 3. ExponExpr :- UnaryExpr [ ^ UnaryExpr 4. UnaryExpr := [( - | + )] PrimaryExpr 15. Primary Expr ::= IDENT | SIDENT | NIDENT | ICONST | RCONST | SCONST | (Expr) Parser Requirements: mplement a recursive-descent parser for the given language. You may use the lexical analyzer you wrote for Programming Assignment 1, OR you may use the provided implementation when it is posted. The parser should provide the following: The results of an unsuccessful parsing are a set of error messages printed by the parser functions, as well as the error messages that might be detected by the lexical analyzer. . If the parser fails, the program should stop after the parser function returns. . The assignment does not specify the exact error messages that should be printed out by the parser; however, the format of the messages should be the line number, followed by a colon and a space, followed by some descriptive text. Suggested messages might include "Missing semicolon at end of Statement.", "Incorrect Declaration Statement.", "Missing Right Parenthesis", "Undefined Variable", "Missing END", etc. If the scanning of the input file is completed with no detected errors, the parser should display the message (DONE) on a new line before returning successfully to the caller program
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