Implement a lexical and syntax analyzer

Assignment Help Programming Languages
Reference no: EM131384944

Programming Assignment:

Implement a lexical and syntax analyzer based on the following grammar. Your analyzer should read an input test program from a file and then determine if it contains a syntax error. It does not have to show where the syntax error occurs or what kind of error it is.

<program>  →  begin <statement_list> end

<statement_list> → <statement> {;<statement_list>}

<statement>  → <assignment_statement> | <loop_statement>

<assignment_statement> → <variable> = <expression>

<variable> → identifier  (An identifier is a string that begins with a letter followed by 0 or more letters and/or digits)

<expression> → <variable> { (+|-) <variable>}          

<loop_statement> →  loop (<logic_expression>)  <statement>

<logic_expression> → <variable> (< | >) <variable> (Assume that logic expressions have only less than or greater than operators)

Use the examples below to test your analyzer.

Input program with no syntax errors:

begin

total = var1 + var2;

loop (var1 < var2)

loop (var3 > var4)

var 2 = var2 - var 1

end

Input programs containing syntax errors:

total = var1 + var2;

loop (var1 < var2)

loop (var3 > var4)

var 2 = var2 - var 1

end

The keyword begin is missing

begin

total = var1 + var2;

loop (var1 < var2)

loop (var3 > var4)

var 2 = var2 - var 1

end

The last statement shouldn't end with a semicolon.

begin

total = var1 + var2;

loop (var1 < var2)

var 2 = var2 - var1

end

The keywords loops is misspelled.

Verified Expert

The solution file is created in netbeans and implemented lexical and syntax analyzer for the given expression. The solution file contains 3 programs lexical.java, syntax.java and anaysis.java (main program). The screen shot of the program is attached.

Reference no: EM131384944

Questions Cloud

Explain how you would develop sales forecast for product : Assume you are planning to market a new facial tissue. Write a detailed customer profile, and explain how you would develop the sales forecast for this product.
Determine the type of marketing research : Visit a local small retailer and observe its marketing efforts-for example, salesperson style, store atmosphere, and warranty policies.
Describe emerging technology that you propose for community : Write a memo to the state emergency manager describing the emerging technology that you propose for your community. Explain how you plan to use this emerging technology in your community and why the state should also adopt this technology.
Identify best tips for using market segmentation strategies : About.com is a large and complex site offering advice and information on a wide range of topics.- Compare and contrast the sources listed. Then identify the best tips for using market segmentation strategies.
Implement a lexical and syntax analyzer : Implement a lexical and syntax analyzer based on the following grammar. Your analyzer should read an input test program from a file and then determine if it contains a syntax error. It does not have to show where the syntax error occurs or what ki..
What should governments prioritize individual rights : Who's ideas make more sense to you, Thomas Hobbes or John Locke? What should governments prioritize: individual rights or the 'greater good'?
What is the customer profile for your product and service : Who is your competition?- Have you conducted a SWOT analysis?- What is the customer profile for your product and/or service?
What steps have already been taken to develop : What are the distinguishing characteristics of your product and/or service?- What steps have already been taken to develop your product and/or service?
What special selling skills will be required : What type of distribution plan will you use?- Will you export to other countries?- What type of selling effort will you use?- What special selling skills will be required?

Reviews

inf1384944

2/14/2017 5:07:54 AM

there is everything right in the assignment i requested that utilization the contingent administrator as opposed to utilizing the Decision structures. I adored the expert and would need for my future task. Thanks team.

len1384944

2/7/2017 2:44:00 AM

I have a programming assignment to do. You should use java coding for the assignment. Implement a lexical and syntax analyzer based on the following grammar. Your analyzer should read an input test program from a file and then determine if it contains a syntax error. It does not have to show where the syntax error occurs or what kind of error it is.

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