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 definition for the following terms

Write a definition for the following terms

  The design and testing the design of learning environments

HCI projects will gravitate on the design and testing the design of learning environments. Design or improvement of a computer application to support; promote learning, identifying new means of using technology for fostering and assessing learning..

  Print the minimum cost of conversion for each string

Print the minimum cost of conversion for each string to a Super Ascii string - Your task is to convert the string to super ascii with the minimum cost. While converting the string to super ascii, the final string should contain the same characters ..

  Write program which prompts user to input integer

Write a C++ program which prompts user to input the integer and then ouputs both individual digits of number and the sum of the digits.

  Write program uses while loop to output all odd numbers

Write a program that uses while loop to perform the following steps: Output all the odd numbers between firstnum and secondnum inclusive.

  Develop a form using jsp that collects client body statistic

Develop a form using JavaScript that collects client body statistics and customer contact information for record keeping and marketing purposes.

  Advantages and disadvantages of server

One of the features of Javascript that we have been looking at this week is that the code is interpreted within the browser environment, on the client machine.

  What will the following program segments display

What will the following program segments display

  Design program that accept number below one hundred as input

Design a program that accepts a number below 100 as input. Once your program has received this number as input, your program should pass this number between a group of 5 friends.

  C++ program to design a class

The class should have a constructor that accepts a nonnegative integer and uses it to initialize the Numbers object. It should have a member function print() that prints the English description of the Numbers object. Demonstrate the class by writi..

  Create a template that changes the value of 2 variables

Use the template in a program where you change the value of 2 variables of type int and 2 variables of type long.

  Design an appropriate set of classes to solve the problem

The purpose of this project is for you to demonstrate your understanding of object oriented software development in practice.

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