In this programming assignment, you will be building a parser for a simple programming language. The syntax definitions of the small programming language, called Pascal-Like Simple Language (PLSL),...

3 answer below »

In this programming assignment, you will be building a parser for a simple programming language. The syntax definitions of the small programming language, called Pascal-Like Simple Language (PLSL), are given below using EBNF notations. The PLSL syntax has some features similar to the well-known Pascal Language. Your implementation of a parser to the language is based on the following grammar rules specified in EBNF notations.




  1. Prog ::= PROGRAM IDENT; DeclBlock ProgBody


  2. DeclBlock ::= VAR {DeclStmt;}


  3. DeclStmt ::= Ident {, Ident} : (Integer | Real | String)


  4. ProgBody ::= BEGIN {Stmt;} END


  5. Stmt ::= AssigStmt | IfStmt | WriteLnStmt | ForStmt


  6. WriteLnStmt ::= WRITELN (ExprList)


  7. IfStmt ::= IF ( LogicExpr ) THEN Stmt [ELSE Stmt]


  8. ForStmt ::= FOR Var := ICONST (TO | DOWNTO) ICONST DO Stmt


  9. AssignStmt ::= Var := Expr


  10. ExprList ::= Expr {, Expr}


  11. Expr ::= Term {(+|-) Term}


  12. Term ::= SFactor {( * | / ) SFactor}


  13. SFactor ::= [(+ | -)] Factor


  14. LogicExpr ::= Expr (= | > |


  15. Var ::= IDENT

  16. Factor ::= IDENT | ICONST | RCONST | SCONST | (Expr)




Parser Requirements:


Implement a recursive-descent parser for the given PLSP 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 “No statements in program”, “Invalid statement”, “Missing Right Parenthesis”, “Undefined Variable”, “Missing END”, etc.




Provided Files


You are given the header file for the parser, “parse.h” andan incomplete file for the “parse.cpp”. You should use “parse.cpp” to complete the implementation of the parser.In addition, “lex.h”, “lex.cpp”, and “prog2.cpp” files are also provided. See the the descriptions of the files in the programming assignment sheet.






a month ago i gave PA1 assignment so based on that have to work pa 2 assignment highly recommended expert Vibhav work on this he has done PA 1 assignment so he knows about this project






use this website to make code vedio is provided to find more information


https://canvas.njit.edu/


ucid- pp222


password- Princep411$





Answered 11 days AfterMar 22, 2022

Answer To: In this programming assignment, you will be building a parser for a simple programming language. The...

Pawan answered on Apr 03 2022
119 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here