Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Java Expert


Home >> Java

You have to design the syntactic analyzer for language specified by the grammar shown below. We are using the following convention: Terminals (lexical elements) are represented with bold courier font like this.  Non-terminals are represented in the angle brackets .  The character ε (epsilon) represents an empty stream. The non-terminal is the starting symbol of grammar.

Grammar

   ::= *
  ::=  class id {**};
  ::=  program;*
  ::=  id()
  ::=  ;
  ::=  {**}
  ::=  id*;
  ::=  ;
  |  if()thenelse;
  |  while()do;
  |  read();
  |  prepare();
  |  return();
  ::=  {*} | | ε
  ::= |
  ::= |  
  ::=  + | -
  ::= |
  ::=
  |  *id()
  |  num
  |   ()
  |  not
  |
  ::=  *id*
  ::=  id*.
  ::=  []
  ::=  [ int ]
  ::=  integer | real | id
  ::=  id** | ε
  ::=  * | ε
  ::=  ,id*
  ::= ,
Operators and additional lexical conventions
   ::=  =
  ::=  == | <> | < | > | <= | >= 
  ::=  + | - | or 
  ::=  * | / | and
    
id  ::=  follows specification for identifiers found in assignment#1
num  ::=  follows specification for numbers found in assignment#1
int  ::= *
  ::=  1..9
  ::=  | 0
 
For illustration, the non-terminal is a generalization of the addition operators tokens +, - and or. The use of this notation here doesn’t necessarily imply which you have to define a new kind of token in your lexical analyzer. Also, id and num are tokens that refer to the lexical conventions. Note that a new lexical convention for the token int has been added. 
Work to be done

• Analyze the syntactical definition given on the first page (and the additional lexical definition for the token int). Remove all the * notations and replace them by list-generating productions. List in your documentation all the ambiguities and left recursions, or any error you might find in grammar. Modify the productions so that the left recursions and ambiguities are deleting without modifying the language. You must get a set of productions that can be parsed using the top-down predictive parsing method. Include the transformed grammar in your documentation.

• Derive the FIRST and FOLLOW sets for each non-terminal in your transformed grammar and list them in your documentation.

• Implement a predictive parser (recursive descent or table-driven) for your modified set of grammar rules.

• Your parser must optionally output to a file the derivation which derives the source program from the starting symbol.

• The parser must call your lexical analyzer as it needs a new token.

• The parser must properly identify the errors in the input program and print a meaningful message to the user for each error encountered.

The parser must implement an error recover way that permits to report all errors. The error messages must be informative on the nature of the errors, as well as the location of the errors in the input file.

• In this assignment, you only check the syntactic correctness of the program, that is, check whether the source program can be parsed according to the grammar. Don’t check the semantic correctness of the program in this assignment.

• prepare a set of source files that facilitate to test the parser for all syntactical structures involved in the language. Include cases testing for a variety of different errors to demonstrate the accurateness of your error reporting and recovery.

Java, Programming

  • Category:- Java
  • Reference No.:- M91652

Have any Question? 


Related Questions in Java

Develop a console program for java on microsoft notepad

Develop a console program for JAVA on Microsoft notepad that simulates a section of a restaurant menu. Each item will have a different price and your program should define at least ten items. You will need to obtain an o ...

Programming assignmentyou to write a class named

Programming Assignment You to write a class named WeaklyCalendar. This class must be in a package named pa4. Note that the description of a programming assignment is not a linear narrative and often requires multiple rea ...

Assignmentproductjavacreate a class to encapsulate the data

Assignment Product.java Create a class to encapsulate the data and behavior of a product in a store's inventory. The class should have the following data for an inventory item: Product Number - String Description - Strin ...

Create a separate class for the selected product that holds

Create a separate class for the selected product that holds the item number, the name of the product, the department in which the product belongs, the number of units in stock, and the price of each unit. You must use th ...

Write a java application using netbeans integrated

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors: A salesperson will earn a fixed salary of 8 ...

Submit one properly named rtf document inside your one jar

Submit one properly named .rtf document inside your one .jar file. lastname.firstname.mod4. 1. What is the characteristic behavior of a stack? 2. What is the characteristic behavior of a queue? 3. What are the advantages ...

Assignmentobjectivethis project focuses on demonstrating

Assignment Objective This project focuses on demonstrating your understanding of Java Collections. Before attempting this project, be sure you have completed all of the reading assignments listed in the syllabus to date, ...

Program- java applet to practice multiplication with user

Program- Java Applet to Practice Multiplication with User Interaction 1) Develop a Java applet that will help an elementary school student learn multiplication. Use the Math.random method or a Random object to produce tw ...

Introduction to programmingjava programming assignment

Introduction to Programming Java Programming Assignment: Objects and Loops Your previous Alice programs implemented the count (for) and while loops. This assignment will apply the same concepts to Java, along with a thir ...

Program 1objectivethis program assignment is provided to

Program 1 Objective: This program assignment is provided to let the students know how to handle threads and enhance system availability on a multiprocessor or multicore environment. A single process is supposed to create ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen