annotate src/tokenizer.h @ 209:0fc1899391b6 stable-6-0-17

use autoconf to package the standard gnu documentation
author Carl Byington <carl@five-ten-sg.com>
date Wed, 05 Mar 2008 18:18:52 -0800
parents c7fc218686f5
children 44ffef730bc4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
1 /*
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
2
152
c7fc218686f5 gpl3, block mail to recipients that cannot reply
carl
parents: 143
diff changeset
3 Copyright (c) 2007 Carl Byington - 510 Software Group, released under
c7fc218686f5 gpl3, block mail to recipients that cannot reply
carl
parents: 143
diff changeset
4 the GPL version 3 or any later version at your choice available at
c7fc218686f5 gpl3, block mail to recipients that cannot reply
carl
parents: 143
diff changeset
5 http://www.gnu.org/licenses/gpl-3.0.txt
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
6
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
7 */
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
8
73
2b369f7db7bf start coding on new config syntax
carl
parents: 71
diff changeset
9 #ifndef tokenizer_include
2b369f7db7bf start coding on new config syntax
carl
parents: 71
diff changeset
10 #define tokenizer_include
2b369f7db7bf start coding on new config syntax
carl
parents: 71
diff changeset
11
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
12 #include <fstream>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
13 #include <list>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
14 #include <set>
83
99049fdc7320 start coding on new config syntax
carl
parents: 75
diff changeset
15 #include <stdio.h>
99049fdc7320 start coding on new config syntax
carl
parents: 75
diff changeset
16 #include <ctype.h>
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
17
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
18
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
19 using namespace std;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
20
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
21 struct ltstr {
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
22 bool operator()(char* s1, char* s2) const {
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
23 return strcmp(s1, s2) < 0;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
24 }
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
25 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
26
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
27 typedef list<ifstream *> stream_list;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
28 typedef list<char *> string_list;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
29 typedef set<char *, ltstr> string_set;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
30 typedef list<int> line_list;
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
31
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
32 class TOKEN {
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
33 stream_list streams;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
34 string_list filenames;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
35 string_set filenamess;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
36 line_list linenumbers;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
37 string_list pending_tokens;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
38 string_set *include_files;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
39 bool pushed;
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
40 u_char pushed_char;
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
41
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
42 void pop();
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
43 bool next_char(u_char &c);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
44 void push_char(u_char c);
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
45
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
46 public:
143
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
47 TOKEN(char *fn, string_set *includes);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
48 ~TOKEN();
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
49 bool include(char *fn);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
50 char *next(); // return next token
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
51 int nextint();
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
52 void skipeol(); // skip to eol
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
53 void push(char *token) {pending_tokens.push_front(token);};
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
54 char *cur_fn() {return filenames.front();};
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
55 int cur_line() {return linenumbers.front();};
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
56 void token_error(const char *err);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
57 void token_error(const char *fmt, int d, const char *s);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
58 void token_error(const char *fmt, const char *t, const char *h);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
59 void token_error(const char *want, const char *have);
ecb40aa3eaa5 require two periods for ip addresses
carl
parents: 83
diff changeset
60 void token_error();
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
61 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
62
73
2b369f7db7bf start coding on new config syntax
carl
parents: 71
diff changeset
63 #endif