Page 1 of 1 File Input Assignment Assignment objective: Begin implementing a lexical analyzer by first writing the code to read from a text file one line at a time and printing each line one character...

1 answer below »
Attached are the instructions for the the assignment in the pdf and C++ files that would be used for the assignment.


Page 1 of 1 File Input Assignment Assignment objective: Begin implementing a lexical analyzer by first writing the code to read from a text file one line at a time and printing each line one character at a time. Design: 1. Download the files Assignment1.cpp, LexicalAnalyzer.cpp, LexicalAnalyzer.h provided along with this assignment in Blackboard and include them in your project. 2. The file Assignment1.cpp is the driver code for the assignment. The main function receives, via the command line argument, the name of the text file that the lexical analyzer processes. The main function contains a loop to call the lexical analyzer’s getChar method to get the next character and print it out. The loop terminates when the lexical analyzer method isEOF returns true. You cannot modify any of the code in this file. 3. LexicalAnalyzer is the lexical analyzer’s class. Right now, the lexical analyzer is not complete, with only the methods to read from a text file. Remember, a source code program file for a programming language is just a text file. Implement the code for the methods: isEOF(), getChar(), and readNextLine() by adding the necessary code to the files LexicalAnalyzer.cpp and LexicalAnalyzer.h. You cannot change any of the code that is already in those files, but you can add code anywhere within those two files. But, you must declare private, all the data members you add to the lexical analyzer class by adding them under private: in the file LexicalAnalyzer.h, and you do not need to add any methods to the lexical analyzer class in this assignment. 4. The isEOF() method returns true when the lexical analyzer reaches the end of the text file; otherwise the method returns false. 5. The getChar() method returns the next character from the current line stored in the lexical analyzer. When this method attempts to get the next character after the last character (newline character) on the line, then this method calls the readNextLine() method. 6. The readNextLine() method attempts to read only the next line from the text file and storing the line as a string within the lexical analyzer. The readNextLine() method needs to recognize when it reaches the end of the file when attempting to read the next line of the text file. 7. The lexical analyzer stores (within itself) the position number (within the current line) of the character returned by the last call to the getChar() method. The lexical analyzer also stores (within itself) the character returned by the last call to the getChar() method. 8. The command to launch your program, assuming test.txt contains several lines of text and the name of the executable code of your program is a.out, is: a.out test.txt 9. Do NOT type any comments in your program. If you do a good job of programming, then it will be easy for me to determine the task of your code.
Answered 4 days AfterFeb 23, 2022

Answer To: Page 1 of 1 File Input Assignment Assignment objective: Begin implementing a lexical analyzer by...

Arun Shankar answered on Feb 27 2022
119 Votes
The plates will still shift
and the clouds will still spew.
The sun will slowly rise
and the moon
will follow too.
Life’s beauty will continue
to flourish all around,
but now you are gone,
these birds have no sound.
And my heart does not beat.
It is still inside my chest.
My tears keep on...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here