annotate src/tokenizer.h @ 24:7d599c9b7d65

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