Evaluating bids

Ddesgin compiler by any programming language

Published on the May 29, 2023 in IT & Programming

About this project

Open

Given the grammar defined by the following set of production rules in the EBNF :
project-declaration  project-def "."
Project-def  project-heading declarations compound-stmt
project-heading  project "name" ";"
declarations  const-decl var-decl subroutine-decl
const-decl  const ( const-item ";" )+ | 
const-item  "name" = "integer-value"
var-decl  var (var-item ";" )+
| 
var-item  name-list ":" int
name-list  "name" ( "," "name" )*
subroutine-decl  subroutine-heading declarations compound-stmt “;” | 
subroutine-heading  routine "name" ";"
compund-stmt  start stmt-list end
stmt-list  ( statement ";" )*
statement  ass-stmt | inout-stmt | if-stmt | loop-stmt | compound-stmt | 
ass-stmt ” name” ":=" arith-exp
arith-exp  term ( add-sign term )*
term  factor ( mul-sign factor )*
factor  "(" arith-exp ")" | name-value
name-value  "name" | "integer-value"
add-sign  "+" | "-"
mul-sign  "*" | "/" | “%”
inout-stmt  input "(" "name" ")" | output "(" name-value ")"
if-stmt  if “(“ bool-exp “)” then statement else-part endif
else-part  else statement | 
loop-stmt  loop “(“ bool-exp “)” do statement
bool-exp  name-value relational-oper name-value
relational-oper  "=" | "<>" | "<" | "<=" | ">" | ">="
Notes:
(0) All “names” and “integer-value” are user defined names and values in the source code.
(1) The tokens in bold letters are reserved words.
(2) The words between “ …” are terminals (tokens).
Write an a recursive descent parser for the above grammar.

Category IT & Programming
Subcategory Other
Project size Small
Is this a project or a position? Project
Required availability As needed

Delivery term: June 03, 2023

Skills needed