CS代考 * Copyright (C) , 2017

* Copyright (C) , 2017
* Do not share this file with anyone
#ifndef __LEXER__H__
#define __LEXER__H__

Copyright By PowCoder代写 加微信 powcoder

#include
#include

#include “inputbuf.h”

// ——- token types ——————-

typedef enum { END_OF_FILE = 0,
SCALAR, ARRAY, OUTPUT, PLUS, MINUS, DIV, MULT,
EQUAL, SEMICOLON,
LBRAC, RBRAC, LPAREN, RPAREN, LBRACE, RBRACE,
DOT, NUM, ID, ERROR
} TokenType;

class Token {
void Print();

std::string lexeme;
TokenType token_type;
int line_no;

class LexicalAnalyzer {
Token GetToken();
void UngetToken(int);
Token peek(int);
LexicalAnalyzer();

std::vector tokenList;
Token GetTokenMain();
int line_no;
int index;
Token tmp;
InputBuffer input;

bool SkipSpace();
int FindKeywordIndex(std::string);
Token ScanIdOrKeyword();
Token ScanNumber();

#endif //__LEXER__H__

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com