Question: Hello. I'm working on an assignment for my class but I need help trying to solve this. So far I'm using as a base and
Hello. I'm working on an assignment for my class but I need help trying to solve this. So far I'm using as a base and reference for my code:
eLists.txt X C++ main.cpp X #include #include #include using namespace std; int main() { ifstream inFile; / /FilePath string filePath; cout > filePath; inFile . open (filePath) ;| if (!inFile . is_open () ) { cout . These operators are for plus, subtract, multiply, divide, remainder, assignment, left parenthesis, right parenthesis, equality, and greater than operations. They have the following tokens, respectively: PLUS, MINUS, MULT, DIV, REM, ASSOP, LPAREN, RPAREN, EQUAL, GTHAN. 7. The semicolon and comma characters are terminals with the following tokens: SEMICOL, COMMA. 8. A comment is defined by all the characters following the exclamation mark "#" to the end of the line. A comment does not overlap one line. A recognized comment is ignored and does not have a token. 9. White spaces are skipped. However, white spaces between tokens are used to improve readability and can be used as a one way to delimit tokens. 10. An error will be denoted by the ERR token. 11. End of file will be denoted by the DONE token.\f\f4. If the program cannot open a filename that is given, the program should print on a new line the message "CANNOT OPEN THE FILE (arg,", where {arg} is the filename given, and it should stop running. 5. If getNextToken function returns ERR, the program should print "Error in line N ( flexeme) )", where N is the line number of the token in the input file and lexeme is its corresponding lexeme, and then it should stop running. For example, a file that contains an invalid real constant, as 15., in line 1 of the file, the program should print the message: Error in line 1 (15.) 6. The program should repeatedly call getNextToken until it returns DONE or ERR. If it returns DONE, the program prints summary information, then handles the flags in the following order: -intconst, -fconst, -strconst and -idents. The summary information are as follows: Lines : L Tokens : N Where L is the number of input lines and N is the number of tokens (not counting DONE). If L is zero, no further lines are printed. 7. If the -v option is present, the program should print each token as it is read and recognized, one token per line. The output format for the token is the token name in all capital letters (for example, the token LPAREN should be printed out as the string LPAREN. In the case of the tokens IDENT, ICONST, FCONST, and SCONST, the token name should be followed by a space and the lexeme in parentheses. For example, if the identifier "circle" and a string literal "The center of the circle through these points is" are recognized, the -v output for them would be: IDENT (circle) SCONST (The center of the circle through these points is) 8. The -strconst option should cause the program to print the label STRINGS: on a line by itself, followed by every unique string constant found, one string per line without double quotes, in alphabetical order. If there are no SCONSTs in the input, then nothing is printed. 9. The -iconsts option should cause the program to print the label INTEGERS: on a line by itself, followed by every unique integer constant found, one integer per line, in numeric order. If there are no ICONSTs in the input, then nothing is printed. 10. The -fconst option should cause the program to print the label FLOATS: on a line by itself, followed by every unique real constant found, one real number per line, in numeric order. If there are no RCONSTs in the input, then nothing is printed.11. The -ident option should cause the program to print the label IDENTIFIERS: followed by a comma-separated list of every identifier found, in alphabetical order. If there are no IDENTs in the input, then nothing is printed. Note: You are provided by a set of 20 testing files associated with Programming Assignment 1. Vocareum automatic grading will be based on these testing files. You may use them to check and test your implementation. These are available in compressed archive "PAl Test Cases.zip" on Canvas assignment. The testing case of each file is defined in the Grading table below
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
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 Programming Questions!