annotate src/tokenizer.h @ 11:1b7813f588ba stable-1-0-1

fix type in config file
author Carl Byington <carl@five-ten-sg.com>
date Fri, 17 May 2013 13:29:14 -0700
parents 0aa1171aebd2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /*
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 Copyright (c) 2007 Carl Byington - 510 Software Group, released under
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 the GPL version 3 or any later version at your choice available at
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 http://www.gnu.org/licenses/gpl-3.0.txt
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 */
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 using namespace std;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 struct ltstr {
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 bool operator()(const char* s1, const char* s2) const {
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 return strcmp(s1, s2) < 0;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 }
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 };
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 typedef list<ifstream *> stream_list;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 typedef list<const char *> string_list;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 typedef set<const char *, ltstr> string_set;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 typedef list<int> line_list;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 class TOKEN {
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 stream_list streams;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 string_list filenames;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 string_set filenamess;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 line_list linenumbers;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 string_list pending_tokens;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 string_set *include_files;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 bool pushed;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 u_char pushed_char;
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 void pop();
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 bool next_char(u_char &c);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 void push_char(u_char c);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 public:
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 TOKEN(const char *fn, string_set *includes);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 ~TOKEN();
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 bool include(const char *fn);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 const char *next(); // return next token
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 int nextint();
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 void skipeol(); // skip to eol
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
43 void push(const char *token) {pending_tokens.push_front(token);};
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44 const char *cur_fn() {return filenames.empty() ? "" : filenames.front();};
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 int cur_line() {return linenumbers.empty() ? 0 : linenumbers.front();};
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 void token_error(const char *err);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 void token_error(const char *fmt, int d, const char *s);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 void token_error(const char *fmt, const char *t, const char *h);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 void token_error(const char *want, const char *have);
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 void token_error();
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 };
0aa1171aebd2 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52