Write a recursive-descent parser

Assignment Help Programming Languages
Reference no: EM13315210

Submission: Please upload the following to the CMS.
1. Source code
2. A screen shot of the execution of your program including the input file you used

Use any programming language you prefer to write a recursive-descent parser that parses the language generated by the following EBNF descriptions. Your parser should detect whether or not the input program has any syntax errors. It does not have to specify what and where the error is.

<program> → begin <stmt_list> end
<stmt_list> → <stmt> {;<stmt_list>}
<stmt> → <assign_stmt> | <while_stmt>
<assign_stmt> → <var> = <expr>
<var> → identifier (An identifier is a string that begins with a letter followed by 0 or more letters and digits)
<expr> → <var> { (+|-) <var>}
<while_stmt> → while (<logic_expr>) <stmt>
<logic_expr> ® <var> (< | >) <var> (Assume that logic expressions have only less than or greater than operators)

You can use the following examples to test your parser.
An input program without syntax errors:

begin

total = var1 + var2;

while (var1 < var2)

     while ( var3 > var4)

                 var2 = var2 - var1

end

 

Some input programs with syntax errors:

 

total = var1 + var2;

while (var1 < var2)
while ( var3 > var4)
var2 = var2 - var1

end

The keyword begin is missing

 

begin

total = var1 + var2;

while (var1 < var2)
while ( var3 > var4)
var2 = var2 - var1;

end

The last statement should not end with a semicolon

 

begin

total = var1 + var2;

whie (var1 < var2)
while ( var3 > var4)
var2 = var2 - var1

end

The keyword while is misspelled

Reference no: EM13315210

Questions Cloud

Question for database schema : The patient information along with the ID of any prescribing doctor for each patient and the prescription information along with patient name, DOB, medication brand name, and prescribing doctor name sorted by most recent date.
What type of system would you classify an electric wire : A system consists of a gas confined between a cylinder and piston such that work and heat may cross the boundary. What type of system is that. What type of system is a free body as used in mechanics or civil engineering.
Find the surface charge density on each sphere : Charge is placed on two conducting spheres that are very far apart and connected by a long thin wire. Find the surface charge density on each sphere
Air traffic controllers use radar to keep track of location : Air traffic controllers use radar to keep track of the location of aircraft.
Write a recursive-descent parser : Use any programming language you prefer to write a recursive-descent parser that parses the language generated by the following EBNF descriptions.
Determine what tension load is needed to return the length : A 4 meter long steel plate with a rectangular cross section (10mm x 50mm) is resting on a frictionless surface under the sun. The plate temperature is measured to be at 40 degrees Celsius.
Find the heat flow from the hot to the cold temperature : A brass rod with a length of 20.0 cm is placed side by side with an aluminum rod with a length of 20.0 cm, What is the heat flow from the hot temperature to the cold temperature
Physics and chemistry found in vital signs of planet earth : Physics and Chemistry Found in Vital Signs of Planet Earth
What is the steady-state concentration of radon in the house : The total volume of the house is 650 m3 (assume that the volume is well mixed throughout). The radon source emits 250 pCi/s (A picoCurie [pCi] is a unit proportional to the amount of radon gas and indicates the amount of radioactivity of the gas)

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd