Question: Source Code: (Please if instructions can be provided because I am struggling with this problem. It is in C++ which i do not have much

Source Code: (Please if instructions can be provided because I am strugglingwith this problem. It is in C++ which i do not havemuch experience on. I only need help in part 1. Thank You)Source Code:

For the lexical analyzer, you will be provided with a description ofthe lexical syntax of the language. You will produce a lexical analysis

(Please if instructions can be provided because I am struggling with this problem. It is in C++ which i do not have much experience on. I only need help in part 1. Thank You)

For the lexical analyzer, you will be provided with a description of the lexical syntax of the language. You will produce a lexical analysis function and a program to test it. The lexical analyzer function will have the following calling signature: Token getNextToken (istream *in, int *linenumber) ; The first argument to getNextToken is a pointer to an istream that the function should read from. The second argument to getNextToken is a pointer to an integer that contains the current line number. getNextToken will update this integer every time it reads a new line. getNextToken returns a Token. A Token is a class that contains a TType, a string for the lexeme, and the line number that the token was found on. A header file, projlex.h, will be provided for you. You MUST use the provided header file. You may NOT change it. The lexical rules of the language are as follows: . The language has identifiers, which are defined to be a letter followed by zero or more letters or numbers. This will be the token IDENT. The language has integer constants, which are defined to be an optional leading dash (for a negative number), followed by one or more digits. This will be the token ICONST. iii. The language has string constants, which are a double-quoted sequence of characters, all on the same line. This will be the token SCONST. The language has reserved the keywords var, print, set, and repeat. They will be the tokens VAR, PRINT, SET, and REPEAT. The language has several single-character tokens. They are + -*:[](); which will be the tokens PLUS MINUS STAR COLON LSQ RSQ LPAREN RPAREN SC. vi. A comment is all characters from a # to the end of the line; it is ignored and is not returned as a token. NOTE that a # in the middle of an SCONST is NOT a comment! vii. Whitespace between tokens can be used for readability. It serves to delimit tokens. viii. The newline should be recognized so that lines can be counted. ix. An error will be denoted by the ERR token. X. End of file will be denoted by the DONE token. V. Note that any error detected by the lexical analyzer will result in the ERR token, with the lexeme value equal to the string recognized when the error was detected. For the lexical analyzer, you will be provided with a description of the lexical syntax of the language. You will produce a lexical analysis function and a program to test it. The lexical analyzer function will have the following calling signature: Token getNextToken (istream *in, int *linenumber) ; The first argument to getNextToken is a pointer to an istream that the function should read from. The second argument to getNextToken is a pointer to an integer that contains the current line number. getNextToken will update this integer every time it reads a new line. getNextToken returns a Token. A Token is a class that contains a TType, a string for the lexeme, and the line number that the token was found on. A header file, projlex.h, will be provided for you. You MUST use the provided header file. You may NOT change it. The lexical rules of the language are as follows: . The language has identifiers, which are defined to be a letter followed by zero or more letters or numbers. This will be the token IDENT. The language has integer constants, which are defined to be an optional leading dash (for a negative number), followed by one or more digits. This will be the token ICONST. iii. The language has string constants, which are a double-quoted sequence of characters, all on the same line. This will be the token SCONST. The language has reserved the keywords var, print, set, and repeat. They will be the tokens VAR, PRINT, SET, and REPEAT. The language has several single-character tokens. They are + -*:[](); which will be the tokens PLUS MINUS STAR COLON LSQ RSQ LPAREN RPAREN SC. vi. A comment is all characters from a # to the end of the line; it is ignored and is not returned as a token. NOTE that a # in the middle of an SCONST is NOT a comment! vii. Whitespace between tokens can be used for readability. It serves to delimit tokens. viii. The newline should be recognized so that lines can be counted. ix. An error will be denoted by the ERR token. X. End of file will be denoted by the DONE token. V. Note that any error detected by the lexical analyzer will result in the ERR token, with the lexeme value equal to the string recognized when the error was detected

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
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 Databases Questions!