Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Lexical analyzer code in java

23/11/2021 Client: muhammad11 Deadline: 2 Day

Lexical Analyzer Assignment

Implement a lexical analyzer for the assignment statement language called ada21s.

LexicalAnalyzer is the main class of the lexical analyzer. You must declare private, all the data members of the LexicalAnalyzer class. You must declare private, all the methods in the LexicalAnalyzer class, except for the constructor and the method getToken. The constructor has one parameter, a string, which contains the filename of the ada21s program source code file the lexical analyzer processes. The getToken method returns the next token in the ada21s program source code file. You can create any additional classes for your lexical analyzer, as needed.

2. Download the files Symbol.java and Token.java provided below The file Symbol.java contains the enumerated type which includes the token symbols for all lexemes in ada21s. The file Token.java contains the Token class used by the getToken method of the LexicalAnalyzer class to return a token which consists of three values: the token symbol, a string if the token is an identifier, and an integer if the token is a numerical literal. You cannot modify any of the code in these two files. (token.java and symbol.java are below

3. Page 3 lists the table of the lexemes for ada21s. All lexemes (except for identifier, numerical literal, not a lexeme, and end of input) are individual lexemes consisting of the character string listed in the Lexeme column and their corresponding token symbol listed in the Token Symbol column. For example, the lexeme :=corresponds to the token symbol BECOMES. A description of the other four lexemes are given below.

4. An identifier lexeme starts with a letter and the remaining characters are either letters or digits. The length of an identifier is capped at 20 characters and the lexical analyzer ignores any additional letters and digits. Identifier lexemes are case sensitive; which means, for example, Count and count are two different identifier names and therefore, two different identifiers.

5. A numerical literal lexeme consists only of digits. The length of a numerical literal is capped at 10 digits and the lexical analyzer ignores any additional digits.

6. The not a lexeme lexeme is a single character lexeme for any character not found in any of the other lexemes of the ada21s language as well as for characters which are not the first character in any of the other lexemes in the ada21s language. The lexical analyzer returns the NAL token symbol for the not a lexeme lexeme. For example, the lexical analyzer returns the NAL token symbol for the ~ character. Another example where the lexical analyzer returns the NAL token symbol is the = character. It is found in the := lexeme but is not the first character in any of the other lexemes in the ada21s language.

7. The lexical analyzer returns the end of input lexeme when it reaches the end of the ada21s program source code file.

8. Create a driver class and make the name of the driver class Assignment1 containing only one method:

public static void main(String args[]). The main method receives, via the command line arguments, the name of the ada21s program source code file that your lexical analyzer processes. The main method itself is fairly short containing a loop to call the lexical analyzer’s getToken method to get the next token and print it out to a text file called output1.txt with each token printed on a separate line. The command to launch your program, assuming example1.ada21s contains an ada21s program, is: java Assignment1 example1.ada21s

9. You must declare public each class you create which means you define each class in its own file.

10. You must declare private all the data members in every class you create.

11. You cannot use extends in this assignment to extend any class.

12. Tip: Make your program as modular as possible, not placing all your code in one .java file. You can create as many classes as you need in addition to the classes described above. Methods being reasonably small follow the guidance that "A function does one thing and does it well." You will lose a lot of points for code readability if you don’t make your program as modular as possible. But, do not go overboard on creating classes and methods. Your common sense guides your creation of classes and methods.

13. Do NOT use your own packages in your program. If you see the keyword package on the top line of any of your .java files then you created a package. Create every .java file in the src folder of your Eclipse project, if you’re using Eclipse.

14. Do NOT use any graphical user interface code in your program!

Pls add some comment so I can understand it

Token.java

public class Token

{

private Symbol sym;

private String id;

private long num;

public Token(Symbol s, String i, long n)

{

sym = s;

id = i;

num = n;

}

public Symbol getSym()

{

return sym;

}

public String getId()

{

return id;

}

public long getNum()

{

return num;

}

public void setSym(Symbol s)

{

sym = s;

}

public void setId(String i)

{

id = i;

}

public void setNum(long n)

{

num = n;

}

public String toString()

{

return ("Symbol: " + sym + ", id: " + id + ", num: " + num);

}

}

Symbol.java

public enum Symbol
{
IDENT, NUMLIT, LPAREN, RPAREN, POSTINC, POSTDEC,
MULT, DIV, MOD, PLUS, MINUS, SLL, SRA, SRL,
BITAND, BITXOR, BITOR, BECOMES, SEMICOLON,
NAL, EOI
}

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Finance Master
Coursework Help Online
Engineering Help
Smart Homework Helper
Finance Professor
Quick Finance Master
Writer Writer Name Offer Chat
Finance Master

ONLINE

Finance Master

As per my knowledge I can assist you in writing a perfect Planning, Marketing Research, Business Pitches, Business Proposals, Business Feasibility Reports and Content within your given deadline and budget.

$37 Chat With Writer
Coursework Help Online

ONLINE

Coursework Help Online

After reading your project details, I feel myself as the best option for you to fulfill this project with 100 percent perfection.

$42 Chat With Writer
Engineering Help

ONLINE

Engineering Help

I am a professional and experienced writer and I have written research reports, proposals, essays, thesis and dissertations on a variety of topics.

$21 Chat With Writer
Smart Homework Helper

ONLINE

Smart Homework Helper

I will provide you with the well organized and well research papers from different primary and secondary sources will write the content that will support your points.

$47 Chat With Writer
Finance Professor

ONLINE

Finance Professor

I am a professional and experienced writer and I have written research reports, proposals, essays, thesis and dissertations on a variety of topics.

$27 Chat With Writer
Quick Finance Master

ONLINE

Quick Finance Master

This project is my strength and I can fulfill your requirements properly within your given deadline. I always give plagiarism-free work to my clients at very competitive prices.

$33 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

ECE Journal due in 24 hours - How to win capsim simulation - How to find the volume of an irregular shape - Moore marshall solicitors cumbernauld - Convert ppmv to mg/m3 - Peacock dove eagle owl - Isuzu australia limited - Difference between fluid transport and fluid power system - Into the wild discussion - Forest development the indian way - Odd todd and even steven template - 6.4 kw in amps - Art essay questions - Infrastructure Project Phase 1 - Milani inc acquired 10 percent of seida corporation - Adat score for carer allowance - Ids gmbh analysis and reporting services - Maldon chronicle newspaper - Suzanne sataline new york times - Interlake high school football - Astronomers estimate that a galaxy contains - Reactions and rates phet answers - Introduction to history - Elysium of the blue sky sheet music - Microsoft publisher vs indesign - Pandit bhagwat dayal sharma university of health sciences - To tell the truth heinrich heine analysis - Cultural considerations presentation - Vitamin c analysis lab calculations - External Factor Evaluation (EFE) and Competitive Profile Matrix (CPM) - Mafs 912 f if 2.6 answers - Wk7 DQ1 Discussion Question 1 – CLO 1, CLO 2, CLO 3, CLO 4, CLO 5, CLO 6, CLO 7, CLO 8 - Business - In the hall of the mountain king instruments - Msts patch 1.4 download - Data migration cutover plan - Purpose of julius caesar - Dr scott fairbairn orthopaedic surgeon - Philippians 3 13 14 - 89.1 dmz mobile circuit mp3 download - Armor gorilla relocation specialist reviews - Which system was known as the "congregate and silent" system? - Tiger tails boarding shutterfly - Average toe length graph - Example of a thesis statement of a short story - Purdue powerpoint template - Business finance acc501 assignment no 01 - Week. 5 project - Never seen the rain - The most exciting event in my life essay - In bennis's definition of leadership the word subordinate seems to - Write Analysis of a KM consulting report 3 pages - Oh my darling clementine history - Sensonics smell test answer key - Value stream mapping involves understanding which of the following - Literature for composition 11th edition pdf free - Measure of Success - King midas comprehension questions - Consumer unit wiring diagram - Write response - BMGT 100 Paper - Bhatti chulo price in nepal - NURS6003 Week 5 Assignment - Morrisons distribution centre swan valley - Australian sport in the 1960s - Why I want to be a Nurse - What body cavity is the knee in - Discussion: Involuntary Group Members - Papa cambridge igcse chemistry - Moment of inertia of right triangular plate - Keller williams lead generation pdf - Subway fort dodge ia 50501 - D1 d2 d3 d4 situational leadership - Bedding parts of a bed - Bachelor of business administration in hospitality management - BUS Analytics II - Joan miller advertising agency - Hp rp5 model 5810 - Is longchamp a luxury brand - Rule of six walter murch - What is a best cost provider strategy - Nissan integrated iso 14000 standards in its manufacturing plants - Jackstone game rules philippines - Unit III Case Study - Trevor noah james comey youtube - Understanding your college experience strategies for success 2nd edition - ^Inter CAST LOVe Marriage +91-7023339183 PRoblem solution MOLviji - Assignment 1 - COMS 301 - VT #6 - 5 5 indirect proof and inequalities in one triangle answers - Convert hz to kva - Discussion - Gap model of service quality - Excel: Short-Term Finance - Law class Unit 1 discussion - Research Paper - Elliptic curve cryptography tutorial - Ethics discovering right and wrong 6th edition pdf - Umuc last day to drop - Hobbycraft permanent adhesive spray