annotate src/tokenizer.cpp @ 81:db85c53e3d90

start coding on new config syntax
author carl
date Sun, 17 Jul 2005 07:34:28 -0700
parents 1142e46be550
children 91c27c00048f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
1 /*
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
2
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
3 Copyright (c) 2004 Carl Byington - 510 Software Group, released under
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
4 the GPL version 2 or any later version at your choice available at
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
5 http://www.fsf.org/licenses/gpl.txt
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
6
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
7 */
e6a2d0be7c5e start coding on new config syntax
carl
parents: 71
diff changeset
8
74
b7449114ebb0 start coding on new config syntax
carl
parents: 73
diff changeset
9 #include "dnsbl.h"
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
10
73
2b369f7db7bf start coding on new config syntax
carl
parents: 72
diff changeset
11 static char* tokenizer_version="$Id$";
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
12
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
13 enum state {s_init,
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
14 s_token,
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
15 s_string,
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
16 s_ignore, // whitespace
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
17 s_eol, // ignore to eol
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
18 end_state,
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
19
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
20 s_term, // token terminator
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
21 s_single,
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
22 s_string1, // first " of string
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
23 s_string2, // last " of string
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
24 s_slash, // possible start of ignore to eol
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
25 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
26
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
27 typedef state PARSE[end_state];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
28
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
29 static PARSE parse_table[256] = {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
30 // s_init s_token s_string s_ignore s_eol
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
31 { s_single, s_term, s_string, s_single, s_eol, }, // 0x00
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
32 { s_single, s_term, s_string, s_single, s_eol, }, // 0x01
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
33 { s_single, s_term, s_string, s_single, s_eol, }, // 0x02
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
34 { s_single, s_term, s_string, s_single, s_eol, }, // 0x03
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
35 { s_single, s_term, s_string, s_single, s_eol, }, // 0x04
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
36 { s_single, s_term, s_string, s_single, s_eol, }, // 0x05
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
37 { s_single, s_term, s_string, s_single, s_eol, }, // 0x06
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
38 { s_single, s_term, s_string, s_single, s_eol, }, // 0x07
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
39 { s_single, s_term, s_string, s_single, s_eol, }, // 0x08
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
40 { s_ignore, s_term, s_string, s_ignore, s_eol, }, // 0x09 <tab>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
41 { s_ignore, s_term, s_string2, s_ignore, s_ignore, }, // 0x0a <lf>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
42 { s_single, s_term, s_string, s_single, s_eol, }, // 0x0b
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
43 { s_single, s_term, s_string, s_single, s_eol, }, // 0x0c
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
44 { s_ignore, s_term, s_string2, s_ignore, s_eol, }, // 0x0d <cr>
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
45 { s_single, s_term, s_string, s_single, s_eol, }, // 0x0e
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
46 { s_single, s_term, s_string, s_single, s_eol, }, // 0x0f
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
47 { s_single, s_term, s_string, s_single, s_eol, }, // 0x10
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
48 { s_single, s_term, s_string, s_single, s_eol, }, // 0x11 xon char
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
49 { s_single, s_term, s_string, s_single, s_eol, }, // 0x12
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
50 { s_single, s_term, s_string, s_single, s_eol, }, // 0x13 xoff char
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
51 { s_single, s_term, s_string, s_single, s_eol, }, // 0x14
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
52 { s_single, s_term, s_string, s_single, s_eol, }, // 0x15
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
53 { s_single, s_term, s_string, s_single, s_eol, }, // 0x16
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
54 { s_single, s_term, s_string, s_single, s_eol, }, // 0x17
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
55 { s_single, s_term, s_string, s_single, s_eol, }, // 0x18
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
56 { s_single, s_term, s_string, s_single, s_eol, }, // 0x19
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
57 { s_single, s_term, s_string, s_single, s_eol, }, // 0x1a
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
58 { s_single, s_term, s_string, s_single, s_eol, }, // 0x1b
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
59 { s_single, s_term, s_string, s_single, s_eol, }, // 0x1c
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
60 { s_single, s_term, s_string, s_single, s_eol, }, // 0x1d
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
61 { s_single, s_term, s_string, s_single, s_eol, }, // 0x1e
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
62 { s_single, s_term, s_string, s_single, s_eol, }, // 0x1f
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
63 { s_ignore, s_term, s_string, s_ignore, s_eol, }, // 0x20 space
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
64 { s_single, s_term, s_string, s_single, s_eol, }, // 0x21 !
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
65 { s_string1, s_term, s_string2, s_string1, s_eol, }, // 0x22 "
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
66 { s_eol, s_term, s_string, s_eol, s_eol, }, // 0x23 #
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
67 { s_single, s_term, s_string, s_single, s_eol, }, // 0x24 $
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
68 { s_single, s_term, s_string, s_single, s_eol, }, // 0x25 %
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
69 { s_single, s_term, s_string, s_single, s_eol, }, // 0x26 &
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
70 { s_single, s_term, s_string, s_single, s_eol, }, // 0x27 '
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
71 { s_single, s_term, s_string, s_single, s_eol, }, // 0x28 (
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
72 { s_single, s_term, s_string, s_single, s_eol, }, // 0x29 )
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
73 { s_single, s_term, s_string, s_single, s_eol, }, // 0x2A *
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
74 { s_single, s_token, s_string, s_single, s_eol, }, // 0x2B +
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
75 { s_single, s_term, s_string, s_single, s_eol, }, // 0x2C ,
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
76 { s_single, s_token, s_string, s_single, s_eol, }, // 0x2D -
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
77 { s_single, s_token, s_string, s_single, s_eol, }, // 0x2E .
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
78 { s_slash, s_token, s_string, s_slash, s_eol, }, // 0x2F /
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
79 { s_token, s_token, s_string, s_token, s_eol, }, // 0x30 0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
80 { s_token, s_token, s_string, s_token, s_eol, }, // 0x31 1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
81 { s_token, s_token, s_string, s_token, s_eol, }, // 0x32 2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
82 { s_token, s_token, s_string, s_token, s_eol, }, // 0x33 3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
83 { s_token, s_token, s_string, s_token, s_eol, }, // 0x34 4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
84 { s_token, s_token, s_string, s_token, s_eol, }, // 0x35 5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
85 { s_token, s_token, s_string, s_token, s_eol, }, // 0x36 6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
86 { s_token, s_token, s_string, s_token, s_eol, }, // 0x37 7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
87 { s_token, s_token, s_string, s_token, s_eol, }, // 0x38 8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
88 { s_token, s_token, s_string, s_token, s_eol, }, // 0x39 9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
89 { s_single, s_term, s_string, s_single, s_eol, }, // 0x3A :
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
90 { s_single, s_term, s_string, s_single, s_eol, }, // 0x3B ;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
91 { s_single, s_term, s_string, s_single, s_eol, }, // 0x3C <
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
92 { s_single, s_token, s_string, s_single, s_eol, }, // 0x3D =
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
93 { s_single, s_term, s_string, s_single, s_eol, }, // 0x3E >
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
94 { s_single, s_term, s_string, s_single, s_eol, }, // 0x3F ?
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
95 { s_single, s_token, s_string, s_single, s_eol, }, // 0x40 @
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
96 { s_token, s_token, s_string, s_token, s_eol, }, // 0x41 A
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
97 { s_token, s_token, s_string, s_token, s_eol, }, // 0x42 B
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
98 { s_token, s_token, s_string, s_token, s_eol, }, // 0x43 C
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
99 { s_token, s_token, s_string, s_token, s_eol, }, // 0x44 D
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
100 { s_token, s_token, s_string, s_token, s_eol, }, // 0x45 E
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
101 { s_token, s_token, s_string, s_token, s_eol, }, // 0x46 F
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
102 { s_token, s_token, s_string, s_token, s_eol, }, // 0x47 G
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
103 { s_token, s_token, s_string, s_token, s_eol, }, // 0x48 H
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
104 { s_token, s_token, s_string, s_token, s_eol, }, // 0x49 I
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
105 { s_token, s_token, s_string, s_token, s_eol, }, // 0x4A J
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
106 { s_token, s_token, s_string, s_token, s_eol, }, // 0x4B K
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
107 { s_token, s_token, s_string, s_token, s_eol, }, // 0x4C L
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
108 { s_token, s_token, s_string, s_token, s_eol, }, // 0x4D M
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
109 { s_token, s_token, s_string, s_token, s_eol, }, // 0x4E N
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
110 { s_token, s_token, s_string, s_token, s_eol, }, // 0x4F O
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
111 { s_token, s_token, s_string, s_token, s_eol, }, // 0x50 P
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
112 { s_token, s_token, s_string, s_token, s_eol, }, // 0x51 Q
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
113 { s_token, s_token, s_string, s_token, s_eol, }, // 0x52 R
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
114 { s_token, s_token, s_string, s_token, s_eol, }, // 0x53 S
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
115 { s_token, s_token, s_string, s_token, s_eol, }, // 0x54 T
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
116 { s_token, s_token, s_string, s_token, s_eol, }, // 0x55 U
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
117 { s_token, s_token, s_string, s_token, s_eol, }, // 0x56 V
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
118 { s_token, s_token, s_string, s_token, s_eol, }, // 0x57 W
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
119 { s_token, s_token, s_string, s_token, s_eol, }, // 0x58 X
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
120 { s_token, s_token, s_string, s_token, s_eol, }, // 0x59 Y
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
121 { s_token, s_token, s_string, s_token, s_eol, }, // 0x5A Z
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
122 { s_single, s_term, s_string, s_single, s_eol, }, // 0x5B [
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
123 { s_single, s_term, s_string, s_single, s_eol, }, // 0x5C backslash
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
124 { s_single, s_term, s_string, s_single, s_eol, }, // 0x5D ]
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
125 { s_single, s_term, s_string, s_single, s_eol, }, // 0x5E ^
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
126 { s_single, s_token, s_string, s_single, s_eol, }, // 0x5F _
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
127 { s_single, s_term, s_string, s_single, s_eol, }, // 0x60 `
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
128 { s_token, s_token, s_string, s_token, s_eol, }, // 0x61 a
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
129 { s_token, s_token, s_string, s_token, s_eol, }, // 0x62 b
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
130 { s_token, s_token, s_string, s_token, s_eol, }, // 0x63 c
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
131 { s_token, s_token, s_string, s_token, s_eol, }, // 0x64 d
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
132 { s_token, s_token, s_string, s_token, s_eol, }, // 0x65 e
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
133 { s_token, s_token, s_string, s_token, s_eol, }, // 0x66 f
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
134 { s_token, s_token, s_string, s_token, s_eol, }, // 0x67 g
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
135 { s_token, s_token, s_string, s_token, s_eol, }, // 0x68 h
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
136 { s_token, s_token, s_string, s_token, s_eol, }, // 0x69 i
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
137 { s_token, s_token, s_string, s_token, s_eol, }, // 0x6A j
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
138 { s_token, s_token, s_string, s_token, s_eol, }, // 0x6B k
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
139 { s_token, s_token, s_string, s_token, s_eol, }, // 0x6C l
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
140 { s_token, s_token, s_string, s_token, s_eol, }, // 0x6D m
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
141 { s_token, s_token, s_string, s_token, s_eol, }, // 0x6E n
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
142 { s_token, s_token, s_string, s_token, s_eol, }, // 0x6F o
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
143 { s_token, s_token, s_string, s_token, s_eol, }, // 0x70 p
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
144 { s_token, s_token, s_string, s_token, s_eol, }, // 0x71 q
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
145 { s_token, s_token, s_string, s_token, s_eol, }, // 0x72 r
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
146 { s_token, s_token, s_string, s_token, s_eol, }, // 0x73 s
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
147 { s_token, s_token, s_string, s_token, s_eol, }, // 0x74 t
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
148 { s_token, s_token, s_string, s_token, s_eol, }, // 0x75 u
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
149 { s_token, s_token, s_string, s_token, s_eol, }, // 0x76 v
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
150 { s_token, s_token, s_string, s_token, s_eol, }, // 0x77 w
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
151 { s_token, s_token, s_string, s_token, s_eol, }, // 0x78 x
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
152 { s_token, s_token, s_string, s_token, s_eol, }, // 0x79 y
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
153 { s_token, s_token, s_string, s_token, s_eol, }, // 0x7A z
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
154 { s_single, s_term, s_string, s_single, s_eol, }, // 0x7B {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
155 { s_single, s_term, s_string, s_single, s_eol, }, // 0x7C |
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
156 { s_single, s_term, s_string, s_single, s_eol, }, // 0x7D }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
157 { s_single, s_term, s_string, s_single, s_eol, }, // 0x7E ~
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
158 { s_single, s_term, s_string, s_single, s_eol, }, // 0x7f
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
159 { s_single, s_term, s_string, s_single, s_eol, }, // 0x80
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
160 { s_single, s_term, s_string, s_single, s_eol, }, // 0x81
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
161 { s_single, s_term, s_string, s_single, s_eol, }, // 0x82
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
162 { s_single, s_term, s_string, s_single, s_eol, }, // 0x83
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
163 { s_single, s_term, s_string, s_single, s_eol, }, // 0x84
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
164 { s_single, s_term, s_string, s_single, s_eol, }, // 0x85
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
165 { s_single, s_term, s_string, s_single, s_eol, }, // 0x86
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
166 { s_single, s_term, s_string, s_single, s_eol, }, // 0x87
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
167 { s_single, s_term, s_string, s_single, s_eol, }, // 0x88
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
168 { s_single, s_term, s_string, s_single, s_eol, }, // 0x89
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
169 { s_single, s_term, s_string, s_single, s_eol, }, // 0x8a
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
170 { s_single, s_term, s_string, s_single, s_eol, }, // 0x8b
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
171 { s_single, s_term, s_string, s_single, s_eol, }, // 0x8c
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
172 { s_single, s_term, s_string, s_single, s_eol, }, // 0x8d
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
173 { s_single, s_term, s_string, s_single, s_eol, }, // 0x8e
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
174 { s_single, s_term, s_string, s_single, s_eol, }, // 0x8f
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
175 { s_single, s_term, s_string, s_single, s_eol, }, // 0x90
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
176 { s_single, s_term, s_string, s_single, s_eol, }, // 0x91
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
177 { s_single, s_term, s_string, s_single, s_eol, }, // 0x92
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
178 { s_single, s_term, s_string, s_single, s_eol, }, // 0x93
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
179 { s_single, s_term, s_string, s_single, s_eol, }, // 0x94
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
180 { s_single, s_term, s_string, s_single, s_eol, }, // 0x95
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
181 { s_single, s_term, s_string, s_single, s_eol, }, // 0x96
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
182 { s_single, s_term, s_string, s_single, s_eol, }, // 0x97
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
183 { s_single, s_term, s_string, s_single, s_eol, }, // 0x98
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
184 { s_single, s_term, s_string, s_single, s_eol, }, // 0x99
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
185 { s_single, s_term, s_string, s_single, s_eol, }, // 0x9a
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
186 { s_single, s_term, s_string, s_single, s_eol, }, // 0x9b
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
187 { s_single, s_term, s_string, s_single, s_eol, }, // 0x9c
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
188 { s_single, s_term, s_string, s_single, s_eol, }, // 0x9d
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
189 { s_single, s_term, s_string, s_single, s_eol, }, // 0x9e
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
190 { s_single, s_term, s_string, s_single, s_eol, }, // 0x9f
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
191 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
192 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
193 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
194 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
195 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
196 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
197 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
198 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
199 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
200 { s_single, s_term, s_string, s_single, s_eol, }, // 0xa9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
201 { s_single, s_term, s_string, s_single, s_eol, }, // 0xaa
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
202 { s_single, s_term, s_string, s_single, s_eol, }, // 0xab
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
203 { s_single, s_term, s_string, s_single, s_eol, }, // 0xac
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
204 { s_single, s_term, s_string, s_single, s_eol, }, // 0xad
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
205 { s_single, s_term, s_string, s_single, s_eol, }, // 0xae
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
206 { s_single, s_term, s_string, s_single, s_eol, }, // 0xaf
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
207 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
208 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
209 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
210 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
211 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
212 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
213 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
214 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
215 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
216 { s_single, s_term, s_string, s_single, s_eol, }, // 0xb9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
217 { s_single, s_term, s_string, s_single, s_eol, }, // 0xba
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
218 { s_single, s_term, s_string, s_single, s_eol, }, // 0xbb
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
219 { s_single, s_term, s_string, s_single, s_eol, }, // 0xbc
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
220 { s_single, s_term, s_string, s_single, s_eol, }, // 0xbd
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
221 { s_single, s_term, s_string, s_single, s_eol, }, // 0xbe
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
222 { s_single, s_term, s_string, s_single, s_eol, }, // 0xbf
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
223 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
224 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
225 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
226 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
227 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
228 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
229 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
230 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
231 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
232 { s_single, s_term, s_string, s_single, s_eol, }, // 0xc9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
233 { s_single, s_term, s_string, s_single, s_eol, }, // 0xca
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
234 { s_single, s_term, s_string, s_single, s_eol, }, // 0xcb
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
235 { s_single, s_term, s_string, s_single, s_eol, }, // 0xcc
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
236 { s_single, s_term, s_string, s_single, s_eol, }, // 0xcd
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
237 { s_single, s_term, s_string, s_single, s_eol, }, // 0xce
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
238 { s_single, s_term, s_string, s_single, s_eol, }, // 0xcf
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
239 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
240 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
241 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
242 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
243 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
244 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
245 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
246 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
247 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
248 { s_single, s_term, s_string, s_single, s_eol, }, // 0xd9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
249 { s_single, s_term, s_string, s_single, s_eol, }, // 0xda
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
250 { s_single, s_term, s_string, s_single, s_eol, }, // 0xdb
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
251 { s_single, s_term, s_string, s_single, s_eol, }, // 0xdc
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
252 { s_single, s_term, s_string, s_single, s_eol, }, // 0xdd
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
253 { s_single, s_term, s_string, s_single, s_eol, }, // 0xde
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
254 { s_single, s_term, s_string, s_single, s_eol, }, // 0xdf
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
255 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
256 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
257 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
258 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
259 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
260 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
261 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
262 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
263 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
264 { s_single, s_term, s_string, s_single, s_eol, }, // 0xe9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
265 { s_single, s_term, s_string, s_single, s_eol, }, // 0xea
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
266 { s_single, s_term, s_string, s_single, s_eol, }, // 0xeb
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
267 { s_single, s_term, s_string, s_single, s_eol, }, // 0xec
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
268 { s_single, s_term, s_string, s_single, s_eol, }, // 0xed
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
269 { s_single, s_term, s_string, s_single, s_eol, }, // 0xee
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
270 { s_single, s_term, s_string, s_single, s_eol, }, // 0xef
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
271 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf0
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
272 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf1
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
273 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf2
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
274 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf3
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
275 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf4
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
276 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf5
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
277 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf6
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
278 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf7
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
279 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf8
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
280 { s_single, s_term, s_string, s_single, s_eol, }, // 0xf9
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
281 { s_single, s_term, s_string, s_single, s_eol, }, // 0xfa
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
282 { s_single, s_term, s_string, s_single, s_eol, }, // 0xfb
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
283 { s_single, s_term, s_string, s_single, s_eol, }, // 0xfc
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
284 { s_single, s_term, s_string, s_single, s_eol, }, // 0xfd
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
285 { s_single, s_term, s_string, s_single, s_eol, }, // 0xfe
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
286 { s_single, s_term, s_string, s_single, s_eol, }, // 0xff
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
287 };
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
288
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
289
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
290 TOKEN::TOKEN(char *fn, string_set *includes) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
291 pushed = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
292 include_files = includes;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
293 include(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
294 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
295
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
296
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
297 TOKEN::~TOKEN() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
298 while (!streams.empty()) pop();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
299 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
300
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
301
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
302 void TOKEN::pop() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
303 ifstream *is = streams.front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
304 char *fn = filenames.front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
305 streams.pop_front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
306 filenames.pop_front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
307 filenamess.erase(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
308 linenumbers.pop_front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
309 is->close();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
310 delete is;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
311 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
312
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
313
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
314 void TOKEN::push_char(u_char c) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
315 pushed = true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
316 pushed_char = c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
317 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
318
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
319
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
320 bool TOKEN::next_char(u_char &uc) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
321 if (pushed) {
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
322 uc = (u_char)tolower((char)pushed_char);
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
323 pushed = false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
324 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
325 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
326 while (!streams.empty() && streams.front()->eof()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
327 pop();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
328 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
329 if (streams.empty()) return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
330 ifstream *is = streams.front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
331 uc = (u_char)is->get();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
332 if (is->eof()) return next_char(uc);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
333 if (uc == (u_char)'\n') {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
334 int &line = linenumbers.front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
335 line++;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
336 }
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
337 uc = (u_char)tolower((char)uc);
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
338 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
339 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
340
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
341
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
342 bool TOKEN::include(char *fn) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
343 string_set::iterator i = filenamess.find(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
344 if (i != filenamess.end()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
345 my_syslog("redundant or recursive include file detected");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
346 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
347 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
348 ifstream *is = new ifstream;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
349 is->open(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
350 if (is->fail()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
351 char buf[1000];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
352 snprintf(buf, sizeof(buf), "include file %s not found", fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
353 token_error(buf);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
354 return false;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
355 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
356 string_set &inc = *include_files;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
357 inc.insert(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
358 streams.push_front(is);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
359 filenames.push_front(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
360 filenamess.insert(fn);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
361 linenumbers.push_front(1);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
362 return true;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
363 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
364
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
365
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
366 char *TOKEN::next() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
367 if (!pending_tokens.empty()) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
368 char *t = pending_tokens.front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
369 pending_tokens.pop_front();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
370 return t;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
371 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
372 if (streams.empty()) return NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
373 const int PENDING_LIMIT = 1000;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
374 static u_char buffer[PENDING_LIMIT];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
375 int count = 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
376 state st = s_init;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
377 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
378 if (count == (PENDING_LIMIT-1)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
379 token_error("token too long");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
380 break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
381 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
382 if (st >= end_state) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
383 token_error("finite state machine error");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
384 break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
385 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
386 u_char c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
387 if (!next_char(c)) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
388 st = parse_table[c][st];
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
389 switch (st) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
390 case s_string:
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
391 case s_token: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
392 buffer[count++] = c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
393 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
394
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
395 case s_term: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
396 push_char(c);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
397 st = s_init;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
398 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
399
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
400 case s_string1: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
401 st = s_string;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
402 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
403
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
404 case s_string2: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
405 st = s_init;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
406 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
407
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
408 case s_single: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
409 buffer[count++] = c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
410 st = s_init;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
411 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
412
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
413 case s_ignore:
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
414 case s_eol: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
415 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
416
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
417
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
418 case s_slash: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
419 buffer[count++] = c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
420 if (next_char(c)) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
421 if (c == (u_char)'/') {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
422 // start of ignore to eol on //
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
423 count--;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
424 st = s_eol;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
425 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
426 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
427 // not a // token, just return this single /
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
428 push_char(c);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
429 st = s_init;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
430 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
431 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
432 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
433 // cannot get another char
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
434 st = s_init;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
435 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
436 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
437
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
438 default: {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
439 token_error();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
440 token_error("unknown state %d %s \n", st, " ");
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
441 } break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
442 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
443 if (st == s_init) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
444 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
445
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
446 buffer[count] = '\0';
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
447 if (count == 0) return NULL;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
448 char *t = register_string((char*)buffer);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
449 if (t == token_include) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
450 char *f = next(); // should be file name
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
451 char *s = next(); // should be semicolon
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
452 if (s == token_semi) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
453 include(f);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
454 return next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
455 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
456 else {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
457 push(s);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
458 push(f);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
459 return t;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
460 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
461 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
462 return t;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
463 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
464
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
465
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
466 int TOKEN::nextint() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
467 char *t = next();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
468 char *e;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
469 long i = strtol(t, &e, 10);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
470 if (*e != '\0') {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
471 token_error("integer", t);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
472 return 0;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
473 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
474 return (int)i;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
475 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
476
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
477
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
478 void TOKEN::skipeol() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
479 while (true) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
480 u_char c;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
481 if (!next_char(c)) break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
482 if (c == (u_char)'\n') break;
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
483 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
484 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
485
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
486
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
487 void TOKEN::token_error(const char *err) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
488 token_error();
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
489 printf("%s \n", err);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
490 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
491
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
492
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
493 void TOKEN::token_error(const char *fmt, int d, const char *s) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
494 printf(fmt, d, s);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
495 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
496
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
497
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
498 void TOKEN::token_error(const char *fmt, const char *t, const char *h) {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
499 if (!h) h = "null";
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
500 printf(fmt, t, h);
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
501 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
502
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
503
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
504 void TOKEN::token_error(const char *want, const char *have) {
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
505 token_error();
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
506 token_error("expecting %s, found %s \n", want, have);
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
507 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
508
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
509
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
510 void TOKEN::token_error() {
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
511 token_error("syntax error at line %d in file %s -- ", cur_line(), cur_fn());
75
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
512 line_list::iterator j = linenumbers.begin();
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
513 string_list::iterator i = filenames.begin();
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
514 for (; i!=filenames.end(); i++,j++) {
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
515 if (i != filenames.begin()) {
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
516 char *fn = (*i);
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
517 int li = (*j);
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
518 token_error("\n included from line %d in file %s -- ", li, fn);
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
519 }
1142e46be550 start coding on new config syntax
carl
parents: 74
diff changeset
520 }
71
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
521 }
dd21c8e13074 start coding on new config syntax
carl
parents:
diff changeset
522