-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTokenList.h
43 lines (32 loc) · 900 Bytes
/
TokenList.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
#pragma once
#include "Token.h"
using namespace std;
class TokenList{
public:
vector<Token> tokens;
TokenList(){}
TokenList(const string&);
Token current() const;
Token next(const int i = 1) const;
bool has_current() const;
bool has_next(const int i = 1) const;
void advance();
size_t size() const;
bool is_statement_start() const;
friend ostream& operator<<(ostream& os, const TokenList& token_list){
os << "[";
for(const Token& token : token_list){
os << endl << " " << token;
}
os << endl << "]";
return os;
}
Token& operator[](const int);
using iterator = vector<Token>::const_iterator;
iterator begin() const noexcept;
iterator end() const noexcept;
private:
void add(string, int, int);
Token find_token(string&, int, int) const;
int index = 0;
};