Find Jobs
Hire Freelancers

Create a lexical analyzer in Java

$10-30 USD

In Progress
Posted over 7 years ago

$10-30 USD

Paid on delivery
1. In this project you will create a lexical analyzer in Java that identifies the following tokens in any string of characters. PLUS: + MINUS: - TIMES: * DIVIDE: / ASSIGNMENT: = LEFTPAREN: ( RIGHTPAREN: ) SEMICOLON: ; INTEGER: sequence of 1 or more digits FLOAT: sequence of digits with one decimal point. There must be at least one digit before and after the decimal point KEYWORD: read, write (lower-case letters) IDENTIFIER: lower-case letter followed by zero or more lower-case letters or digits Your lexical analyzer should find the tokens in an input string and print a token list that labels the tokens as to their type and value in the order found. The exact format of the input and output is listed below in item 3. If your program finds an unidentified character or any other error it should print a useful message (character and position number of the char) and exit the program. Notes: a. You must use the algorithm on the attached pseudocode. b. Do not assume that there are spaces separating any of the tokens c. To find an identifier read as many characters as possible. For example readme is not “read” + “me” it is “readme” For example x1=6 “x1” not “x” followed by an integer. It is “x1” d. To find a number read as many digits as possible. For example “2345” is the number 2345. e. The input string does not have to be a syntactically correct program. Your syntax analyzer should work on any string. It should never crash. If an error is detected it should gracefully exit with your won error message, printing only those tokens it has recognized up to the detected error. 2. Use object oriented programming (in Java) to develop your program. Create a class called LexAnalyzer. Create a main program that inputs the string to be analyzed, creates LexAnalyzer object and then calls the method prints the tokens as follows: String s = ″ x = 12.78 ; y = apple + 5 * orange;z=3*(4 * y) ″ ; [login to view URL](“Input String: “ + s); LexAnalyzer lex = new LexAnalyzer(s); [login to view URL](); 3. A typical test case should look like this: public static void main (String[] args) { String s=″ first = 5.62 ; z1=8*( 34 + art2b) read ″; [login to view URL](“Input String: “ + s); LexAnalyzer lex = new LexAnalyzer(s); [login to view URL]( “Token List”); [login to view URL]() ; } The output of the test case should look like this: Input String: first = 5.62 ; z1=8*( 34 + art2b) read Token List IDENTIFIER first ASSIGNMENT FLOAT 5.62 SEMICOLON IDENTIFIER z1 ASSIGNMENT INTEGER 8 TIMES LEFTPAREN INTEGER 34 PLUS IDENTIFIER art2b RIGHTPAREN KEYWORD read 4. Test your program thoroughly. Test good and bad strings, not just the examples below. Your instructor will run your program on a set of test cases which will not be known to you. At least 50% of your grade will be based on how well your program runs on the instructor test cases. 5. Submit your [login to view URL] program to Moodle on Sept 22 by 7:30 am. Your program must be named [login to view URL] and meet the conditions of the project. See attached for pseudocode needed and an outline of the program. 6. Hand in in class on Sept 22: (stapled together in this order) a. Title Page with course , project number, date and your name b. [login to view URL] source code c. Results for your program run on these test cases. Label test cases. Hand in the results of these test cases. //Test Case 1 ″x = 12.78 ; y = apple + 5 * orange;z=3*(4 * y) “ //Test Case 2 – ″read write 34 +5.678 -789.001 goodread+-* ″ //Test Case 3 – ″ int y = 7 ; double z = 78.01 ″ //Test Case 4 - ″ qwerty := 1234″ //Test Case 5 - ″ total is 23. dollars ″ //Test Case 6 - ″x = art2.1b″ //Test Case 7: ″   ″ //This is not an error. You should print EMPTY TOKEN LIST
Project ID: 11568287

About the project

2 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
We have a 1000+ employee in our company. So we can do any kind of project based on all languages and all stream...... We have 3 years+ experience employees for all stream especially C Programming, Javascript,html,php,java, android platform. So don't fear anything as soon as possible…. We are heartily welcome our projects.... ...................................................thank you..........................................................
$25 USD in 2 days
0.0 (1 review)
0.0
0.0
2 freelancers are bidding on average $50 USD for this job
User Avatar
Hello. It is really easy project, it's possible to complete it in few hours of pure working time.
$23 USD in 1 day
4.9 (489 reviews)
6.5
6.5
User Avatar
Hello there It is my great honor to apply for this vacant job. I am very hardworking and can work effectively as fast as I can. I have excellent skills in JAVA, C++, C#, OPPs, HTML5, CSS3, JS, AJAX, JQYERY, React.js, ANGULAR.JS, BACKBONE.JS, BOOTSTRAP, PHP,Wordpress, ASP.NET, MVC, Web Research and Microsoft Office and I have enough experience with different kinds of tasks as you can see in my "Work History", most of the time I gave my clients a great results.I have fast internet connection at home, have my own pc to use anytime and have own space to work. I can work fulltime and will focus to this project. I can follow instructions very well and will deliver the project on time. It is a pleasure if ever you will message me for an interview. I can work as soon as possible. Thanks and more power. MOHSAN IJAZ
$77 USD in 1 day
5.0 (3 reviews)
1.8
1.8

About the client

Flag of UNITED STATES
northridge, United States
5.0
11
Payment method verified
Member since Nov 10, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759) & Freelancer Online India Private Limited (CIN U93000HR2011FTC043854)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.