annotate src/tokenizer.cpp @ 71:dd21c8e13074

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