CSC 460 Compiler Construction Assignment

Assignment Help JAVA Programming
Reference no: EM132460605

CSC 460/660 - Compiler Construction - University of Nevada

The Espresso Compiler Project

Phase - Parse Tree Construction

The second phase of the Espresso compiler project is concerned with adding actions to the CUP file. These actions will build a parse tree for the program being parsed. We need such a parse tree in the next 4 phases. Many checks and computations can be performed by implementing traversals of the parse tree.

If the input is syntactically correct, your compiler should build a parse tree. This is done by providing Java code to construct the tree between the {: ... :} symbols.

Work List

Question 1: Determine the types of all the non-terminals. Some are pretty obvious, like for example the if statement. Naturally the non-terminals if then statement, if then else statement, and if then else statement no short if are all of type IfStat (i.e., they create an object of the IfStat class). Once you have determine this you can use the types in the constructor of the IfStat to determine the types of the individual parts of the if statement. Start with the obvious non-terminals and work your way back like I just explained.

Question 2: Add action to your cup file. That is, add {: RESULT = ... :} to each production rule, where ... creates an object of the right type. This will always be one of the classes in the parse tree node files, or null. Keep in mind that if one right-hand-side of a production creates a sequence, then all right-hand-sides should create a sequence. For example, if we have a production like

A ::= A a
    | a
we are dealing with a repetition or a list of as. The typical action you would add looks like this:

A ::= A:lst a:e {: RESULT = lst.append(e); :}
| a:e {: RESULT = new Sequence(e); :}

As you can see, both right-hand-sides return a sequence, so the type of the entire production is Sequence. Now if we have the following production in addition to the above one:

A opt ::= A
        | ∈
then the first right-hand side will return a Sequence, so in order to type this correctly, the empty production must also return a Sequence. We solve this problem in the following way:

A opt ::= A:lst {: RESULT = lst; :}
|  {: RESULT = new Sequence(); :}

of course you only need to use this technique if the non-empty right-hand-side returns a sequence.
• Compile your compiler using the ant command.
• Run the espressoc script to test your compiler.
• Compare your results to my reference implementation.

Running the Reference Implementation

In order to check your compiler against my version of the Espresso compiler, you can use the espressocr script. That will submit your file to my reference implementation and return the output.

Pre-supplied Code and Testing

When you hand in your project we will use the build.xml file and the ant command to make your project, and the espressoc script to run your compiler. If we cannot do that we will not mark your project, i.e., you get 0 on this phase. We will do the following to test your compiler:
ant clean
ant
espressoc <testfile.java>

Attachment:- Compiler Construction.rar

Reference no: EM132460605

Questions Cloud

Planning to invest your money today : If you are planning to invest your money today in a security that pay you $5,000,000 in 15 years with rate of return on your investment
What would its future value be : What's the future value of 7%, 7-year ordinary annuity that pays $500 each year? If this was annuity due, what would its future value be?
Determine estimated salvage value : Determine estimated salvage value of $3,000. If the company uses the straight line method, the depreciation expense for 2018 would be
Prepare general journal entries to record the transactions : Prepare general journal entries to record these transactions (use account titles listed in part 2).Prepare a trial balance as of April 30.
CSC 460 Compiler Construction Assignment : CSC 460/660 Compiler Construction Assignment Help and Solution, University of Nevada - Assessment Writing Service - The Espresso Compiler Project Homework Help
CSC72003 - Programming Assignment : CSC72003 - Programming Assignment Help and Solution - Southern Cross University, Australia. Draw a map for your game scenario
Determine the term hospitality accounting : In hospitality accounting, Explain and discuss the steps in preparing the work sheet ? Detail each step and what is done in each process
Determine the legal services revenue : Should be recognized in two installments ($400 in February and $600 in April).Should be recognized in full in March.Should be recognized in full in April
What interest are you being charged : You borrow $85,000 from a bank, the annual loan payments are $8,273.59 for 15 years. What interest are you being charged?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

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

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