Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm very lost on how to proceed with this project, any help would be greatly appreciated. This is a Java project. Programming Assignment 5 -Java

image text in transcribedimage text in transcribed

I'm very lost on how to proceed with this project, any help would be greatly appreciated. This is a Java project.

Programming Assignment 5 -Java Identifier Parser Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assistance from the instructor). Project Description Variables in a computer program are programmer-defined and sere as a named location in memory. Selecting good identifiers helps with the human understanding and maintainability of source code. But there are restrictions imposed on identifiers by the Java language. These rules and conventions are summarized here: Variable names are case-sensitive. A variable's name can be any legal identifier -an unlimited- length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character"_". The convention, however, is to always begin your variable names with a letter, not "$" or"_". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it's technically legal to begin your variable's name with"_", this practice is discouraged. White space is not permitted Subsequent characters may be letters, digits, dollar signs, or underscore characters. Conventions (and common sense) apply to this rule as well. When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases, it will also make your code self-documenting; fields named cadence, speed, and gear, for example, are much more intuitive than abbreviated versions, such as s,c, and g. Also, keep in mind that the name you choose must not be a .If the name you choose consists of only one word, spell that word in all lowercase letters. If it consists of more than one word, capitalize the first letter of each subsequent word. The names gearRatio and currentGear are prime examples of this convention. If your variable stores a constant value, such as static final int NUM GEARS- 6, the convention changes slightly, capitalizing every letter and separating subsequent words with the underscore character. By convention, the underscore character is never used elsewhere. (Oracle.com, 2015) A compiler must examine tokens in a program and decide whether they are reserved words in the Java language or valid identifiers defined by the user. Design a program that reads a Java source code file and makes a list of all the valid Java identifiers along with the number of occurrences of each identifier in the source code. It should display any invalid identifiers that exist in the program, too. To do this, you should make use of a Hash Map data structure. The Hash Map will hold all the identifiers that you find in the Java program and the number of times the identifier appears in the source code file. In addition, your program will need a data structure containing all the Java reserved words and operators for efficient searching, optionally this structure may include the query language keywords. Write Java code that will create an AVL tree of the reserved words in the Java language, operators, and the query language keywords (if included in the input file) using the BRIDGES bridges.base.BinTreeElement class. (We are using the BinTreeElement for the AVL Tree, rather than the bridges. base.AVLTreeElementK, E> class, to align better with the AVL Tree code used in our textbook.) After you create the AVL tree of reserved words, write code to visualize this tree in BRIDGES A listing of reserved words, operators, and, query language keywords (if included in the input file) is to be read from a single input file. Both the name of the keyword file and the name of the source code file to be analyzed are supplied as command line arguments. The first argument is the keyword file and the second argument is the source code to be checked. Both files are plain text format, regardless of the extension. Whenever your program encounters a token in the source code file, after verifying that the token does not violate the rules for the characters shown above, it should search the binary search tree of reserved words. If the token is not found, then search the HashMap of identifiers. If the token is not in the HashMap, add it. If the token appears in the identifier HashMap, increment the frequency counter for that entry Your main program file should be named Project5.java Use object-oriented program design for this project. Follow style and documenting examples given in class for earlier projects. Each file must begin with a comment block with your name, program name, course number and due date. The block must also include the purpose, input, and output of the program. Upload a compressed folder containing Blackboard. Remember to remove package statements from each file. Do not include the test files that you may have created files of your program to the assignment link in Input Your program must be able to retrieve the names of the input files from the command line. The first argument is the keyword file name and the second is the name of the source code file to be parsed for identifiers. If command line arguments are missing, prompt the user to enter the missing file name(s). Output Your program will display the URL for the visualization of the tree containing the Java reserved words, operators, and, optionally, query keywords; Then, a list of the identifiers and the number of times each of them appears in the test program. EXTRA CREDIT: Display a list of the invalid identifiers in the program, if any exist; Source Oracle.com. (2015). Varialbles. Retrieved 47, 2017, from The Java Tutorials: https://docs.oracle.com/javase/tutorial/javautsandbolts/variables.html Programming Assignment 5 -Java Identifier Parser Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assistance from the instructor). Project Description Variables in a computer program are programmer-defined and sere as a named location in memory. Selecting good identifiers helps with the human understanding and maintainability of source code. But there are restrictions imposed on identifiers by the Java language. These rules and conventions are summarized here: Variable names are case-sensitive. A variable's name can be any legal identifier -an unlimited- length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character"_". The convention, however, is to always begin your variable names with a letter, not "$" or"_". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it's technically legal to begin your variable's name with"_", this practice is discouraged. White space is not permitted Subsequent characters may be letters, digits, dollar signs, or underscore characters. Conventions (and common sense) apply to this rule as well. When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases, it will also make your code self-documenting; fields named cadence, speed, and gear, for example, are much more intuitive than abbreviated versions, such as s,c, and g. Also, keep in mind that the name you choose must not be a .If the name you choose consists of only one word, spell that word in all lowercase letters. If it consists of more than one word, capitalize the first letter of each subsequent word. The names gearRatio and currentGear are prime examples of this convention. If your variable stores a constant value, such as static final int NUM GEARS- 6, the convention changes slightly, capitalizing every letter and separating subsequent words with the underscore character. By convention, the underscore character is never used elsewhere. (Oracle.com, 2015) A compiler must examine tokens in a program and decide whether they are reserved words in the Java language or valid identifiers defined by the user. Design a program that reads a Java source code file and makes a list of all the valid Java identifiers along with the number of occurrences of each identifier in the source code. It should display any invalid identifiers that exist in the program, too. To do this, you should make use of a Hash Map data structure. The Hash Map will hold all the identifiers that you find in the Java program and the number of times the identifier appears in the source code file. In addition, your program will need a data structure containing all the Java reserved words and operators for efficient searching, optionally this structure may include the query language keywords. Write Java code that will create an AVL tree of the reserved words in the Java language, operators, and the query language keywords (if included in the input file) using the BRIDGES bridges.base.BinTreeElement class. (We are using the BinTreeElement for the AVL Tree, rather than the bridges. base.AVLTreeElementK, E> class, to align better with the AVL Tree code used in our textbook.) After you create the AVL tree of reserved words, write code to visualize this tree in BRIDGES A listing of reserved words, operators, and, query language keywords (if included in the input file) is to be read from a single input file. Both the name of the keyword file and the name of the source code file to be analyzed are supplied as command line arguments. The first argument is the keyword file and the second argument is the source code to be checked. Both files are plain text format, regardless of the extension. Whenever your program encounters a token in the source code file, after verifying that the token does not violate the rules for the characters shown above, it should search the binary search tree of reserved words. If the token is not found, then search the HashMap of identifiers. If the token is not in the HashMap, add it. If the token appears in the identifier HashMap, increment the frequency counter for that entry Your main program file should be named Project5.java Use object-oriented program design for this project. Follow style and documenting examples given in class for earlier projects. Each file must begin with a comment block with your name, program name, course number and due date. The block must also include the purpose, input, and output of the program. Upload a compressed folder containing Blackboard. Remember to remove package statements from each file. Do not include the test files that you may have created files of your program to the assignment link in Input Your program must be able to retrieve the names of the input files from the command line. The first argument is the keyword file name and the second is the name of the source code file to be parsed for identifiers. If command line arguments are missing, prompt the user to enter the missing file name(s). Output Your program will display the URL for the visualization of the tree containing the Java reserved words, operators, and, optionally, query keywords; Then, a list of the identifiers and the number of times each of them appears in the test program. EXTRA CREDIT: Display a list of the invalid identifiers in the program, if any exist; Source Oracle.com. (2015). Varialbles. Retrieved 47, 2017, from The Java Tutorials: https://docs.oracle.com/javase/tutorial/javautsandbolts/variables.html

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started