Question: Creating 3 Java Files Basic.java must contain main. 1) There must be only one argument (args) and if there are none or more than 1,

Creating 3 Java Files

Basic.java must contain main.

1) There must be only one argument (args) and if there are none or more than 1, an error message must be printed and the program exits

2) That one argument will be considered a filename

3) Use File.ReadAllLines to read all of the lines from the file that is denoted by filename

4) Instantiate one instance of your Lexer class for each line from ReadAllLines

5) Parse each line using the lex method of the Lexer class

5) Take the list of tokens from lex and concatenate it to a single list. If lex throws an exception you must catch the exception, print that there was an exception, and lex the next line

6) Print each token out once the lexing is complete

Token.java

1) Must contain a Token class that is made up of an instance of an enum and a value string

2)Must be a public accessor for both the enum and the value string but the variables have to be private

3) You can use whatever constructors you want

4) The enum must be defined as containing values appropriate to what we will be processing

5) The definition of the enum should be public, but the instance inside Token must be private

6) Create an appropriate ToString overload

Lexer.java

1)Must contain a lex method that accepts a single string and returns a collection (array or list) of Tokens

2)Must use one or more state machines to iterate over the input string and create appropriate Tokens

3)Any character not allowed by your state machines should throw an exception

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!