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

  Program to use next character to create and return operator

Convert the string of digits into an integer. Otherwise, use the next character to create and return an operator.

  Create xml document to mark nutrition facts for cookies

Create an XML document that marks up the nutrition facts for a package of Grandma White's cookies. A package of cookies has a serving size of 1 package and the following nutritional value per serving.

  Cooks selected by methods are different which one is taller

He orders the shortest man in each column to step aside and chooses the tallest of these twenty-five. The two cooks chosen by the two methods are different. Which one is taller?

  Explaining the situation in program

Which of the following best explains the situation after Line 1 has been executed?

  Computing return value after execution of program

Compute return value of Antony after its execution?

  Matlab that will use the flipping of two-sided coins to sim

Write a program in matlab that will use the flipping of two-sided coins to simulate any event that has a probability of success(Ps) that ranges between 0 and 1. The simulation will most likely be approximate. It must be accurate to at least 0.01

  Develop the application to show coffee customer orders

Develop the application which shows the total pounds of coffee customer orders, sales tax, and total price of order. Write down the name the solution, project, and form file Jason Coffee Solution, Jason Coffee Project.

  Design program to enter a series of numbers

Design a program that asks the user to enter a series of 20 numbers. The program should determine whether the number is valid by comparing it to the following list of valid charge account numbers.

  Extend the user management

Extend the user management so that user can be stored in database - user can be administrator and he can access that admin page

  Create command line based application for perfect hundred

Create a COMMAND LINE based application to play a game called Perfect Hundred. In this game, the user/player competes against the computer.

  Step by step procedure to solve to create record note book

Create Record note book; The Record note book should be in the follwoing order. Procedure: Write down step by step procedure to solve problem.

  Determine proper lower bound and upper bound on ?nal value

Determine the proper lower bound and upper bound on the ?nal value of the shared variable tally output by this concurrent program.

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