Compilers check programs for syntax errors

Assignment Help JAVA Programming
Reference no: EM13811696

Compilers check programs for syntax errors, but frequently a lack of one symbol (such as a missing brace or comment starter) will cause the compiler to spill out a number of diagnostics without identifying the real error. A useful tool in this situation is a program that checks whether every pair of symbols is balanced. Thus, every right brace, bracket, and parenthesis must correspond to its left counterpart. For instance, the sequence [()] is legal, but [(]) is not.

In this assignment, you are asked to write a balance-symbol checker which checks for the following pairs of symbols in the source code files of Java programs: (), [], {}. This checker must implement the following algorithm:

1. Make an empty stack.

2. Read symbols until the end of the source code file.

a. If the symbol is an opening symbol, push it onto the stack.

b. If it is a closing symbol, do the following:

i. If the stack is empty, report an error.

ii. Otherwise, pop the stack. If the symbol popped is not the corresponding opening symbol, report an error.

3. At the end of the file, if the stack is not empty, report an error.

As the algorithm above shows, a stack data structure must be used in this programming assignment. You are encouraged to use the Stack class available in the collections package of the Java API.

Input

Your program must take as input the name of a Java source code file such as the source file containing the source code of this assignment.

Reference no: EM13811696

Questions Cloud

Write an essay on your short term personal financial and car : Write an essay on your short term personal financial and career goals and the tentative plan on how you will achieve them.
For initial public offerings of common stock : For initial public offerings of common stock, 2010 was a relatively slow year, with about $30.7 billion raised by the process. Relatively few of the 94 firms involved paid cash dividends. Why do you think that most chose not to pay cash dividends? Ex..
The affect of language between speakers and listeners : How does language affect the relationship between speakers and listeners
Process design for the production : Using the Six Sigma DMAIC process, develop a new process design for the production of the Riordan electric fans. Be sure to take advantage of any global opportunities available to Riordan, such as lower labor costs.
Compilers check programs for syntax errors : Compilers check programs for syntax errors, but frequently a lack of one symbol (such as a missing brace or comment starter) will cause the compiler to spill out a number of diagnostics without identifying the real error
Calibration of new production equipment : Mary Chong, capital expenditure manager for PDA Manufacturing, knows that her company is facing a series of monthly expenses associated with installation and calibration of new production equipment. The company has $1 million in a bank account right ..
If the volatility of each investment is 8 then find the valu : 1. The current price of a bond is 100. The instantaneous rate of change or derivative of the price of the bond with respect to the yield rate is 700. The yield rate is an annual effective rate of 8%. Calculate the Macaulay duration of the bond. Note:..
How college students outside our class view graphic novels : Conduct a small study to discover how college students outside our class view graphic novels. Then select an idea, theme, or minute detail related to WWII that you learned about by reading Maus.
Present value of perpetuity-when dealing with estate taxes : Stock A has a current price of $40.00, a beta of 2.5, and a dividend yield of8%. If the Treasury bill yield is 5% and the market portfolio is expected to return15%, what should stock A sell for at the end of an investor’s three year horizon? What is ..

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