annotate src/tokenizer.h @ 71:dd21c8e13074

start coding on new config syntax
author carl
date Sat, 09 Jul 2005 19:24:41 -0700
parents
children 2b369f7db7bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
1 #include <fstream>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
2 #include <list>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
3 #include <set>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
6 using namespace std;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
8 struct ltstr {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
9 bool operator()(char* s1, char* s2) const {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
10 return strcmp(s1, s2) < 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
11 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
12 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
13
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
14 typedef list<ifstream *> stream_list;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
15 typedef list<char *> string_list;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
16 typedef set<char *, ltstr> string_set;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
17 typedef list<int> line_list;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
18
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
19 class TOKEN {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
20 stream_list streams;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
21 string_list filenames;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
22 string_set filenamess;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
23 line_list linenumbers;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
24 string_list pending_tokens;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
25 string_set *include_files;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
26 bool pushed;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
27 u_char pushed_char;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
28
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
29 void pop();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
30 bool next_char(u_char &c);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
31 void push_char(u_char c);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
32
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
33 public:
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
34 TOKEN(char *fn, string_set *includes);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
35 ~TOKEN();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
36 bool include(char *fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
37 char *next(); // return next token
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
38 int nextint();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
39 void skipeol(); // skip to eol
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
40 void push(char *token) {pending_tokens.push_front(token);};
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
41 char *cur_fn() {return filenames.front();};
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
42 int cur_line() {return linenumbers.front();};
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
43 void token_error(const char *err);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
44 void token_error(const char *fmt, int d, const char *s);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
45 void token_error(const char *fmt, const char *t, const char *h);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
46 void token_error(const char *token, const char *have);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
47 void token_error();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
48 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
49