-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.h
More file actions
59 lines (47 loc) · 939 Bytes
/
tokenizer.h
File metadata and controls
59 lines (47 loc) · 939 Bytes
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
59
#ifndef TOKENIZER_H
#define TOKENIZER_H
#include <string>
#include <queue>
#include "token.h"
#include "tokenlist.h"
class Tokenizer {
private:
enum class TokenizeState {
START,
READ_LINE_CONTINUE,
READ_KEYWORD_OR_IDENT,
READ_YARN_LITERAL,
READ_NUMBR_LITERAL,
READ_NUMBAR_LITERAL
};
enum class CharType {
LETTER,
DIGIT,
MINUS,
UNDERSCORE,
PERIOD,
DOUBLE_QUOTE,
YARN_ESCAPE,
YARN_NEWLINE,
YARN_TAB,
EXCLAMATION,
QUESTION,
SPACE,
LINE_DELIMITER,
UNKNOWN
};
static CharType GetCharType( char );
static TokenType GetTokenType( const std::string & );
void AddToken( Token );
void AddSimpleToken( TokenType, bool = false );
public:
Tokenizer();
bool Tokenize( std::string );
inline TokenList &GetTokens() { return tokens_; }
private:
bool inMultiLineComment_;
bool continueCurrentLine_;
bool addLineDelimiter_;
TokenList tokens_;
};
#endif