-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer.h
executable file
·58 lines (40 loc) · 1.42 KB
/
lexer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* lexer.h
* Benjamin Ferid Issa
* February 8th 2017
*
* Based on files provided by Dr. Frank Jones, Computer Science Department, Brigham Young University
*/
#ifndef LEXER_H
#define LEXER_H
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include "state.h"
#include "token.h"
class state;
class lexer
{
public:
//returns the results of performing lexical annalysis on a vector of characters
std::vector<token*>* analyze(std::vector<char>* Input);
//prints the resulst of lexical analysis to stdout
static void printAnalysis(std::vector<token*>* Tokens);
//a utility method to get a vector of type char from a text file
static std::vector<char>* fileToVectorOfChars(std::string FileName);
//method for setting the new state of an active state machine
void setState(state* State);
void increaseLineCount();
bool at_eof = false; //Returns true if we hit the end of the file.
lexer();//make the constructor private to prevent instantiation of the class...
private:
void runMachine(std::vector<char>* Input, int Index);
void findkeywords(std::vector<char>* Input, int Index, token*& newToken);
void findopenended(std::vector<char>* Input, int Index, token*& newToken);
int LineCount;
//the lexer will act as the context manager for its state machines, we need
//a pointer to the current state
state* m_currentState;
};
#endif