Mercurial > dnsbl
comparison src/tokenizer.h @ 143:ecb40aa3eaa5 stable-5-23
require two periods for ip addresses
author | carl |
---|---|
date | Tue, 10 Oct 2006 19:12:16 -0700 |
parents | 99049fdc7320 |
children | c7fc218686f5 |
comparison
equal
deleted
inserted
replaced
142:b82e00146672 | 143:ecb40aa3eaa5 |
---|---|
1 /* | |
2 | |
3 Copyright (c) 2006 Carl Byington - 510 Software Group, released under | |
4 the GPL version 2 or any later version at your choice available at | |
5 http://www.fsf.org/licenses/gpl.txt | |
6 | |
7 */ | |
8 | |
1 #ifndef tokenizer_include | 9 #ifndef tokenizer_include |
2 #define tokenizer_include | 10 #define tokenizer_include |
3 | 11 |
4 #include <fstream> | 12 #include <fstream> |
5 #include <list> | 13 #include <list> |
9 | 17 |
10 | 18 |
11 using namespace std; | 19 using namespace std; |
12 | 20 |
13 struct ltstr { | 21 struct ltstr { |
14 bool operator()(char* s1, char* s2) const { | 22 bool operator()(char* s1, char* s2) const { |
15 return strcmp(s1, s2) < 0; | 23 return strcmp(s1, s2) < 0; |
16 } | 24 } |
17 }; | 25 }; |
18 | 26 |
19 typedef list<ifstream *> stream_list; | 27 typedef list<ifstream *> stream_list; |
20 typedef list<char *> string_list; | 28 typedef list<char *> string_list; |
21 typedef set<char *, ltstr> string_set; | 29 typedef set<char *, ltstr> string_set; |
22 typedef list<int> line_list; | 30 typedef list<int> line_list; |
23 | 31 |
24 class TOKEN { | 32 class TOKEN { |
25 stream_list streams; | 33 stream_list streams; |
26 string_list filenames; | 34 string_list filenames; |
27 string_set filenamess; | 35 string_set filenamess; |
28 line_list linenumbers; | 36 line_list linenumbers; |
29 string_list pending_tokens; | 37 string_list pending_tokens; |
30 string_set *include_files; | 38 string_set *include_files; |
31 bool pushed; | 39 bool pushed; |
32 u_char pushed_char; | 40 u_char pushed_char; |
33 | 41 |
34 void pop(); | 42 void pop(); |
35 bool next_char(u_char &c); | 43 bool next_char(u_char &c); |
36 void push_char(u_char c); | 44 void push_char(u_char c); |
37 | 45 |
38 public: | 46 public: |
39 TOKEN(char *fn, string_set *includes); | 47 TOKEN(char *fn, string_set *includes); |
40 ~TOKEN(); | 48 ~TOKEN(); |
41 bool include(char *fn); | 49 bool include(char *fn); |
42 char *next(); // return next token | 50 char *next(); // return next token |
43 int nextint(); | 51 int nextint(); |
44 void skipeol(); // skip to eol | 52 void skipeol(); // skip to eol |
45 void push(char *token) {pending_tokens.push_front(token);}; | 53 void push(char *token) {pending_tokens.push_front(token);}; |
46 char *cur_fn() {return filenames.front();}; | 54 char *cur_fn() {return filenames.front();}; |
47 int cur_line() {return linenumbers.front();}; | 55 int cur_line() {return linenumbers.front();}; |
48 void token_error(const char *err); | 56 void token_error(const char *err); |
49 void token_error(const char *fmt, int d, const char *s); | 57 void token_error(const char *fmt, int d, const char *s); |
50 void token_error(const char *fmt, const char *t, const char *h); | 58 void token_error(const char *fmt, const char *t, const char *h); |
51 void token_error(const char *want, const char *have); | 59 void token_error(const char *want, const char *have); |
52 void token_error(); | 60 void token_error(); |
53 }; | 61 }; |
54 | 62 |
55 #endif | 63 #endif |