ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 10 Weeks Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 9.00

writing a program that parses, using recursive descent

Hide Submission Folder Information
Submission Folder  
Project 1
Instructions  

Requirements

The first 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, using a supplied lexical analyzer. 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

Your 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:

 

Source Code Skeleton for Project 1

The attached .zip file contains two classes, one that defines a lexical analyzer and a second that defines a syntax error. In addition, a third file that contains an enumerated type for the tokens is included. You should use this code when developing the first project.

Sample Input Files

Please post an example of valid input to this program in the "Ask the Professor" discussion area. I will check whether it conforms to the syntax defined by the grammar, and if it it does, show you what the corresponding output should look like.

Project Submission Instructions

You are to submit two files.

  1. The first is a .zip file that contains all the source code for the project, which includes any code that was provided. The .zip file should contain only source code and nothing else, which means only the .java files. If you elect to use a package the .java files should be in a folder whose name is the package name.
  2. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following:
    1. A brief description of your approach to the design
    2. A UML class diagram that includes all classes including any that were supplied . Do not include predefined classes. You need only include the class name for each individual class, not the variables or methods
    3. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing
    4. A short paragraph on lessons learned from the project

 

Answers

(11)
Status NEW Posted 22 May 2017 02:05 AM My Price 9.00

-----------

Not Rated(0)