Writing a program that parses

Assignment Help JAVA Programming
Reference no: EM13161285

The programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines. The grammar for this language is defined below:

gui ::=

    Window STRING '(' NUMBER ',' NUMBER ')' layout widgets End '.'

layout ::=

    Layout layout_type ':'

layout_type ::=

    Flow |

    Grid '(' NUMBER ',' NUMBER [',' NUMBER ',' NUMBER] ')'

widgets ::=

    widget widgets |

    widget

widget ::=

    Button STRING ';' |

    Group radio_buttons End ';' |

    Label STRING ';' |

    Panel layout widgets End ';' |

    Textfield NUMBER ';'

radio_buttons ::=

    radio_button radio_buttons |

    radio_button

radio_button ::=

    Radio STRING ';'

In the above grammar, the red symbols are nonterminals, the blue symbols are tokens and the black punctuation symbols are BNF metasymbols. Among the tokens those in title case are keywords. The character literals are punctuation tokens.

Below is an explanation of the meaning of some of the symbols in the above productions that should help you understand the actions that are to be performed when each of the productions is parsed:

  • In the window production the string is name that is to appear in the top border of the window and the two numbers are the width and height of the window
  • In the production for layout_type that define the grid layout, the first two numbers represent the number of rows and columns, and the optional next two the horizontal and vertical gaps
  • In the production for widget that defines a button, the string is the name of the button
  • In the production for widget that defines a label, the string is text that is to be placed in the label
  • In the production for widget that defines a text field, the number is the width of the text field
  • In the production for radio_button, the string is the label of the button

You parser should properly handle the fact that panels can be nested in other panels. Recursive productions must be implemented using recursion. Syntactically incorrect input files should detect and report the first error.

Below is an example of an input file:

Window "Calculator" (200, 200) Layout Flow:

Textfield 20;

Panel Layout Grid(4, 3, 5, 5):

    Button "7";

    Button "8";

    Button "9";

    Button "4";

    Button "5";

    Button "6";

    Button "1";

    Button "2";

    Button "3";

    Label "";

    Button "0";

End;

End.

The above input file should produce the GUI shown below:

Reference no: EM13161285

Questions Cloud

Relationship unethical : Under what circumstances is the use of power in a relationship unethical? Explain your answer.  Please respond with at least 150 words.
An isp has received a block : An ISP has received a block of addresses in which the prefix length (n = 24). The ISP needs to make 8 sub-nets (sub-blocks) of equal sizes from this block. What is the prefix of each sub-block?
Include the iostream, fstream, string, and cctype libraries : 1. Include the iostream, fstream, string, and cctype libraries in your program.
Building plans-what is shater : Know the building plans, the names of the two building plans, the domes and roofs of the early structures and why they were used in the cathedrals of Europe and of Byzantine Russia especially churches in Moscow.
Writing a program that parses : The programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines.
Diagnosis of terminal cancer : My boyfriend of one year has been given a diagnosis of terminal cancer. He has no family around, and I have been his primary caretaker. We had a wonderful relationship, but we had not discussed long-term plans, and his declining health has changed mu..
Which disease is epidemic or endemic : Which disease is epidemic or endemic.
What is the mechanism of action of malariamedications : What is the life cycle of the protozoa responsible formalaria?
What is the ionization state of this protein : Consider the tetrapeptide Met-Trp-Ser-Arg.

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Executing stringed musical instrument class

Create and execute a stringed musical instrument class.

  What position along the chord does minimum pressure occur

At what position along the chord does the minimum pressure occur? What is special about the point where C p is a maximum?

  Determine the java application on web

Determine the Java application on Web and explain how program structure functions. Explain the application in as much detail as possible.

  Minimal spanning tree decreasing edge dismissal

Minimal Spanning Tree Decreasing Edge Dismissal, Reverse-delete algorithm. Develop an implementation that computes the MST

  Java program for real estate agent

Write down java program for real estate agent. Program must perform the following tasks: ask users for average house price for the each of past 5 years for single family residence of 1500 square feet.

  Recognize one high severity vulnerability for computer

Recognize one high severity vulnerability for each computer (if there is one). Explain vulnerability and describe control(s) to minimize risk from vulnerability.

  Develop java applet that will help elementary school student

Develop a Java applet that will help an elementary school student learn multiplication. Use the Math.random method or a Random object to produce two positive one-digit integers.

  Write applet which reads five numbers-draw equivalent stars

Write the applet which reads five numbers (each between 1 and 30). For each number read, your program must design line containing that number of adjacent asterisks.

  What makes a program easy to modify

Describe the order of magnitude of the code section using Big(O) notation and Explain the relationship between dynamic storage allocation and recursion.

  Java program to read line of text which ends with period

Write down the java program which will read the line of text which ends with the period, which serves as sentinel value. Show all the letters which occur in the text.

  Cascading style sheet to a website

Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page.

  Java script program for song

Construct a JavaScript program that declares and prints an array that includes at least twenty of your favorite songs.

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