annotate src/tokenizer.h @ 303:50666a411bb1

Added tag stable-6-0-44 for changeset 52430ef70440
author Carl Byington <carl@five-ten-sg.com>
date Mon, 13 Oct 2014 20:54:34 -0700
parents 82886d4dd71f
children 5209e92b4885
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
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
9 using namespace std;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
10
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
11 struct ltstr {
214
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
12 bool operator()(const char* s1, const char* s2) const {
213
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
13 return strcmp(s1, s2) < 0;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
14 }
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
15 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
16
214
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
17 typedef list<ifstream *> stream_list;
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
18 typedef list<const char *> string_list;
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
19 typedef set<const char *, ltstr> string_set;
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
20 typedef list<int> line_list;
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
21
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
22 class TOKEN {
213
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
23 stream_list streams;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
24 string_list filenames;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
25 string_set filenamess;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
26 line_list linenumbers;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
27 string_list pending_tokens;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
28 string_set *include_files;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
29 bool pushed;
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
30 u_char pushed_char;
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
31
213
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
32 void pop();
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
33 bool next_char(u_char &c);
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
34 void push_char(u_char c);
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
35
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
36 public:
214
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
37 TOKEN(const char *fn, string_set *includes);
213
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
38 ~TOKEN();
214
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
39 bool include(const char *fn);
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
40 const char *next(); // return next token
213
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
41 int nextint();
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
42 void skipeol(); // skip to eol
214
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
43 void push(const char *token) {pending_tokens.push_front(token);};
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
44 const char *cur_fn() {return filenames.empty() ? "" : filenames.front();};
82886d4dd71f Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents: 213
diff changeset
45 int cur_line() {return linenumbers.empty() ? 0 : linenumbers.front();};
213
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
46 void token_error(const char *err);
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
47 void token_error(const char *fmt, int d, const char *s);
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
48 void token_error(const char *fmt, const char *t, const char *h);
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
49 void token_error(const char *want, const char *have);
44ffef730bc4 cleanup tokenizer differences with other projects, update tld list
Carl Byington <carl@five-ten-sg.com>
parents: 152
diff changeset
50 void token_error();
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
51 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
52