Ask Java Expert


Home >> Java

Scanning represents a common class of algorithms that is widely used by programmers. In this assignment you will write a scanner. The project will utilize your knowledge of finite state machines and text files.

Scanners process test by translating a stream of input characters into tokens. Each token represents a contiguous group of characters. For example, the scanner in a compiler would input the following line of Java

  while (myInt > 1000)

and discover the following six tokens:

1) the keyword while

2) the left paren

3) the variable name myInt

4) the less than symbol

5) the integer 1000

6) the right paren

Write a scanner that translates logical expressions. There are many different notations for logical expressions. For example, Java uses the constants "true" and "false", while philosophers often abbreviate these as "T" and "F" and Boolean algebraists use "1" and "0". Your scanner is going to produce logical expressions in a compact form that uses one symbol per constant and one symbol per operator. Below is a table of all of the allowable output symbol tokens, and associated logical semantics, for your scanner.

Token

Meaning

T

logical value of TRUE

F

logical value of FALSE

~

NOT operator

^

AND operator

V

inclusive OR operator

x

exclusive or (XOR) operator

IMPLIES operator

=

EQUIVALENCE operator

(

a left paren

)

a right paren

?

this symbol denotes a syntax error

The program needs to be more flexible in the acceptable form of the syntax that is translated. FOr example, unlimited blanks are permitted (but not required) before, after or between tokens. No blanks will result in the output. The permissible input tokens prior to translation are explained below:

TRUE value -- any unsigned integer with an odd value

FALSE value -- any unsigned integer with an even value

NOT -- # 

!

AND -- &

*

OR --  +

XOR -- <>

!=

IMPLIES --     =>

any string of zero or more consecutive dashes (-) followed by a > symbol

EQUIVALENCE --      =

==

left paren -     (

right paren --   )

 

Note that all of the preceding notations are used in some settings for the associated tokens, but these particular tokens were selected in order to work better with FSMs. Anything other than what was described should be considered incorrect syntax and result in a ? symbol for a token.

You will be graded largely on how effectively you utilize a finite state machine and the associated table-driven code to solve this problem. You should view the problem as an FSM that scans one character at a time in order to transition from state to state. Each state transition has one of three associated actions:

1) add another token to the output string

2) read another character

3) add another token to the output string AND read another character.

Since the "add another token" action does not always add the same token, it is helpful to view your FSM as using three, rather than two, tables -- namely, a next state table, an action table and an output token table. Also, when building these tables you can take advantage of the fact that all valid input characters fall in the range from a blank to the greater than character.

Your final submission also needs to follow these guidelines:

1) You are reuired to submit a graphical representation (states with labeled arcs) to describe your FSM.

2) The FSM tables must be read from a text file that is included with your src folder files when you submit the program.

3) The input string to be tokenized must be read from a text file and you must use a JFileChooser object to allow the user to select this input file.

4) The output sequence of tokens must be displayed in a JFrame that pops upt when your program completes the scan.

Java, Programming

  • Category:- Java
  • Reference No.:- M91089256

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As