Question: IN C + + PLEASE!!! code for lex.h: / * * lex.h * * CS 2 8 0 * Spring 2 0 2 4 *
IN C PLEASE!!!
code for lex.h:
lex.h
CS
Spring
#ifndef LEXH
#define LEXH
#include
#include
#include
using namespace std;
enum Token
keywords OR RESERVED WORDS
IF ELSE, PRINT, INTEGER, REAL,
CHARACTER, END, THEN, PROGRAM,
LEN,
identifiers
IDENT,
an integer, real, logical and string constants
ICONST, RCONST, SCONST, BCONST,
the arithmetic operators, logic operators, relational operators
PLUS, MINUS, MULT, DIV, ASSOP, EQ POW,
GTHAN, LTHAN, CAT,
Delimiters
COMMA, LPAREN, RPAREN, DOT, DCOLON, DEF,
any error returns this token
ERR,
when completed EOF return this token
DONE,
;
Class definition of LexItem
class LexItem
Token token;
string lexeme;
int lnum;
public:
LexItem
token ERR;
lnum ;
LexItemToken token, string lexeme, int line
thistoken token;
thislexeme lexeme;
thislnum line;
bool operatorconst Token token const return thistoken token;
bool operator!const Token token const return thistoken token;
Token GetToken const return token;
string GetLexeme const return lexeme;
int GetLinenum const return lnum;
;
extern ostream& operatorostream& out, const LexItem& tok;
extern LexItem idorkwconst string& lexeme, int linenum;
extern LexItem getNextTokenistream& in int& linenum;
#endif LEXH
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
