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

  Develop a java based gui application using swing that

develop a java based gui applicationusing swing that allows the user to enter charityfund informationwrite the

  Elliptic curve encryption

write a program to implement Elliptic Curve encryption/decryption and program will read parameters, plaintext and ciphertextfrom a file named "input.txt" (under the same directory).

  Define a piece of dna sequence

Please consider the features of Java classes, and then define a Java class for a DNA sequence object to include instance variable names and methods that you can use to define a piece of DNA sequence

  Define a class called counter

Define a class called Counter. An object of this class is used to count things, so it records a count that is a non negative whole number. Include methods to set the counter to 0, to increase the count by

  Design a java application to carry out additions

You are to design a Java application to carry out additions and subtractions for numbers of any length - You are not allowed to convert these strings to numbers before the operation.

  Java program which demonstrates cellular automata

Using the internet, locate a Java program (or Java applet) which demonstrates "Cellular Automata", in particular "the Game of Life".

  Recommend at least five factors which programmers must

propose at least five factors that programmers should consider when choosing between data types such as those used in c

  Read the article titled teaching software componentization

read the article titled teaching software componentization a bar chart java bean.write a page paper in which

  Java application modeled after the game of hangman

Creating a Java application modeled after the game of hangman, where a user must guess a hidden word or phrase in a limited number of guesses.

  Write a program that prompts the user to input three numbers

Write a program that prompts the user to input three numbers. This program should then output the numbers in nondescending order.

  Uml exercise automated teller machine atmnbspbrief

uml exercise automated teller machine atmnbspbrief statement of purposean atm is an electronic device designed for

  Add a draw() method to horse class.

Add a draw() method to your Horse class. You will also need to create a couple of Horses in your DrawPanel class, and call the draw() method for each Horse from the paintComponent() method. There is no need to modify the DrawPanelDriver 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