Mercurial > routeflapper
comparison src/tokenizer.h @ 4:180d26aa2a17
Fedora 9 compile and const correctness.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 12 Jun 2008 17:51:33 -0700 |
parents | 48d06780cf77 |
children |
comparison
equal
deleted
inserted
replaced
3:4a81cc2da570 | 4:180d26aa2a17 |
---|---|
4 the GPL version 3 or any later version at your choice available at | 4 the GPL version 3 or any later version at your choice available at |
5 http://www.gnu.org/licenses/gpl-3.0.txt | 5 http://www.gnu.org/licenses/gpl-3.0.txt |
6 | 6 |
7 */ | 7 */ |
8 | 8 |
9 | |
10 using namespace std; | 9 using namespace std; |
11 | 10 |
12 struct ltstr { | 11 struct ltstr { |
13 bool operator()(char* s1, char* s2) const { | 12 bool operator()(const char* s1, const char* s2) const { |
14 return strcmp(s1, s2) < 0; | 13 return strcmp(s1, s2) < 0; |
15 } | 14 } |
16 }; | 15 }; |
17 | 16 |
18 typedef list<ifstream *> stream_list; | 17 typedef list<ifstream *> stream_list; |
19 typedef list<char *> string_list; | 18 typedef list<const char *> string_list; |
20 typedef set<char *, ltstr> string_set; | 19 typedef set<const char *, ltstr> string_set; |
21 typedef list<int> line_list; | 20 typedef list<int> line_list; |
22 | 21 |
23 class TOKEN { | 22 class TOKEN { |
24 stream_list streams; | 23 stream_list streams; |
25 string_list filenames; | 24 string_list filenames; |
26 string_set filenamess; | 25 string_set filenamess; |
27 line_list linenumbers; | 26 line_list linenumbers; |
28 string_list pending_tokens; | 27 string_list pending_tokens; |
29 string_set *include_files; | 28 string_set *include_files; |
30 bool pushed; | 29 bool pushed; |
31 u_char pushed_char; | 30 u_char pushed_char; |
32 | 31 |
33 void pop(); | 32 void pop(); |
34 bool next_char(u_char &c); | 33 bool next_char(u_char &c); |
35 void push_char(u_char c); | 34 void push_char(u_char c); |
36 | 35 |
37 public: | 36 public: |
38 TOKEN(char *fn, string_set *includes); | 37 TOKEN(const char *fn, string_set *includes); |
39 ~TOKEN(); | 38 ~TOKEN(); |
40 bool include(char *fn); | 39 bool include(const char *fn); |
41 char *next(); // return next token | 40 const char *next(); // return next token |
42 int nextint(); | 41 int nextint(); |
43 void skipeol(); // skip to eol | 42 void skipeol(); // skip to eol |
44 void push(char *token) {pending_tokens.push_front(token);}; | 43 void push(const char *token) {pending_tokens.push_front(token);}; |
45 const char *cur_fn() {return filenames.empty() ? "" : filenames.front();}; | 44 const char *cur_fn() {return filenames.empty() ? "" : filenames.front();}; |
46 int cur_line() {return linenumbers.empty() ? 0 : linenumbers.front();}; | 45 int cur_line() {return linenumbers.empty() ? 0 : linenumbers.front();}; |
47 void token_error(const char *err); | 46 void token_error(const char *err); |
48 void token_error(const char *fmt, int d, const char *s); | 47 void token_error(const char *fmt, int d, const char *s); |
49 void token_error(const char *fmt, const char *t, const char *h); | 48 void token_error(const char *fmt, const char *t, const char *h); |
50 void token_error(const char *want, const char *have); | 49 void token_error(const char *want, const char *have); |
51 void token_error(); | 50 void token_error(); |
52 }; | 51 }; |
53 | 52 |