1 dnl userv - language.i4
2 dnl definition of the configuration language, used for tokens.h and lexer.l
4 dnl userv is copyright Ian Jackson and other contributors.
5 dnl See README for full authorship information.
7 dnl This is free software; you can redistribute it and/or modify it
8 dnl under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 3 of the License, or
10 dnl (at your option) any later version.
12 dnl This program is distributed in the hope that it will be useful, but
13 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 dnl General Public License for more details.
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
21 dnl 1,2,4: sections of token enum list
26 define(`makename',`translit(``$1'',`-_')')
28 define(`hasvalistype',`pushdef(`odiv',divnum)dnl
30 format(``%-50s'',`toki_$1=')`$2',
32 format(``%-30s'',`tokv_$1=')`$3|toki_$1',
33 divert(odiv)popdef(`odiv')')
35 define(`cautotoki',eval(`0x1'))
36 define(`cautotokt',eval(`0x1000'))
38 define(`autovalistype',`hasvalistype(`$1',format(``0x%08x'',cautotoki),`$2')`'define(`cautotoki',incr(cautotoki))')
40 define(`autovaldeftype',`pushdef(`odiv',divnum)divert(4)dnl
41 format(``%-25s'',`tokt_$1=')format(``0x%08x'',cautotokt),
42 divert(odiv)popdef(`odiv')define(`cautotokt',eval(cautotokt`*2'))')
44 define(`nametypelexpatexec',`
45 autovalistype(`$1',`$2')
46 pushdef(`odiv',divnum)divert(3)dnl
47 `$3 { $4'`return tokv_$1; }'
48 divert(odiv)popdef(`odiv')')
50 define(`wordtypelexexec',
51 `nametypelexpatexec(`word_'makename(`$1'),`$2|tokr_word',`$1',`$3')')
54 autovaldeftype(`directive')
55 autovaldeftype(`controlstart')
56 autovaldeftype(`controlend')
57 autovaldeftype(`exception')
58 autovaldeftype(`parmcondition')
59 autovaldeftype(`condop')
60 autovaldeftype(`parameter')
61 autovaldeftype(`number')
62 autovaldeftype(`fdrange')
63 autovaldeftype(`logfacility')
64 autovaldeftype(`loglevel')
65 autovaldeftype(`readwrite')
66 autovaldeftype(`string')
67 autovaldeftype(`execmode')
68 autovaldeftype(`ehandlemode')
69 autovaldeftype(`lookupquotemode')
70 autovaldeftype(`builtinservice')
71 autovaldeftype(`misc')
72 autovaldeftype(`internal')
74 dnl simple isdirectives
75 define(`isdirectivefn',`dnl
76 wordtypelexexec(`$1',`tokt_directive$3',`lr_dir= $2; $4')dnl
77 pushdef(`odiv',divnum)
78 divert(odiv)popdef(`odiv')')
79 define(`isdirective',`isdirectivefn(`$1',`df_'makename(`$1'),`$2')')
80 define(`isdirectiveinternal',`isdirectivefn(`$1',`dfi_'makename(`$1'),
82 define(`isexecmode',`isdirective(`$1',`|tokt_execmode')')
83 define(`isehandlemode',`isdirective(`$1',`|tokt_ehandlemode')')
84 define(`islookupquotemode',`isdirectivefn(`$1',`dfg_lookupquotemode',
85 `|tokt_lookupquotemode')')
86 define(`isfdwant',`isdirectivefn(`$1',`dfg_fdwant',`',
87 `lr_fdwant_readwrite=$2; ')')
88 define(`isflagpair',`isdirectivefn(`$1',`dfg_setflag',`',
89 `lr_flag= &'makename(`$1')`; lr_flagval= 1; ')
90 isdirectivefn(`no-$1',`dfg_setflag',`',
91 `lr_flag= &'makename(`$1')`; lr_flagval= 0; ')')
92 dnl `reset' is also a builtin service
94 dnl `execute' is also a builtin service
95 isexecmode(`execute-from-directory')
96 isexecmode(`execute-from-path')
97 isexecmode(`execute-builtin')
98 isehandlemode(`errors-to-stderr')
99 isehandlemode(`errors-to-syslog')
100 isehandlemode(`errors-to-file')
101 islookupquotemode(`include-lookup-quote-old')
102 islookupquotemode(`include-lookup-quote-new')
103 isfdwant(`require-fd',`1')
104 isfdwant(`allow-fd',`0')
105 isfdwant(`null-fd',`0')
106 isfdwant(`reject-fd',`-1')
107 isfdwant(`ignore-fd',`-1')
108 isflagpair(`set-environment')
109 isflagpair(`suppress-args')
110 isflagpair(`disconnect-hup')
112 isdirective(`user-rcfile')
113 isdirective(`include')
114 isdirectivefn(`include-ifexist',`df_include')
115 isdirective(`include-lookup')
116 isdirectivefn(`include-lookup-all',`df_includelookup')
117 isdirective(`include-directory')
118 isdirective(`message')
119 isdirectivefn(`_include-sysconfig',`df_include',`|tokt_internal')
120 isdirectiveinternal(`_include-user-rcfile')
121 isdirectiveinternal(`_include-client-config')
123 dnl quit and eof are each a directive _and_ an exception
124 dnl as separate tokens. A true end of file is returned by yylex
125 dnl as the exception. The directive (word) tokens are
126 dnl tokv_word_{eof,quit}; the exceptions are tokv_{eof,quit}.
130 dnl control construct starters
131 define(`iscontrolstart',
132 `isdirective(`$1',`|tokt_controlstart')')
134 iscontrolstart(`catch-quit')
135 iscontrolstart(`errors-push')
137 dnl control construct enders
138 define(`iscontrolend',
139 `wordtypelexexec(`$1',`tokt_controlend$3',
140 `lr_controlend= tokv_word_'makename(`$2')`; ')')
141 iscontrolend(`elif', `if', `|tokt_controlstart')
142 iscontrolend(`else', `if', `|tokt_controlstart')
143 iscontrolend(`fi', `if')
144 iscontrolend(`hctac', `catch-quit')
145 iscontrolend(`srorre', `errors-push')
148 define(`isparmcondition',`wordtypelexexec(`$1',`tokt_parmcondition',
149 `lr_parmcond= pcf_'makename(`$1')`; ')')
150 isparmcondition(`glob')
151 isparmcondition(`range')
152 isparmcondition(`grep')
155 define(`builtininlist',`
156 pushdef(`odiv',divnum)divert(5)dnl
158 divert(odiv)popdef(`odiv')')
161 define(`isbuiltinservice',
162 `wordtypelexexec(`$1',`tokt_builtinservice$3',
163 `lr_bispa= bispa_'makename(`$2')`; lr_bisexec= bisexec_'makename(`$1')`; $5')
164 builtininlist(`$1',`$4')')
165 isbuiltinservice(`environment',`none')
166 isbuiltinservice(`parameter',`parameter',`',` <parameter>')
167 isbuiltinservice(`version',`none')
168 isbuiltinservice(`toplevel',`none')
169 isbuiltinservice(`override',`none')
170 isbuiltinservice(`shutdown',`none')
172 dnl builtin services that are also directive names
173 define(`isdirectivebuiltinservice',
174 `isbuiltinservice(`$1',`$2',`|tokt_directive$3',`$4',
175 `lr_dir= df_'makename(`$1')`; ')')
176 isdirectivebuiltinservice(`reset',`none')
177 isdirectivebuiltinservice(`execute',`none',`|tokt_execmode')
179 isbuiltinservice(`help',`none')
182 define(`isparameter',`wordtypelexexec(`$1',`tokt_parameter',
183 `lr_parameter= pf_'makename(`$1')`; ')')
184 isparameter(`service')
185 isparameter(`calling-user')
186 isparameter(`calling-group')
187 isparameter(`calling-user-shell')
188 isparameter(`service-user')
189 isparameter(`service-group')
190 isparameter(`service-user-shell')
193 define(`isloglevellexpat',
194 `nametypelexpatexec(`syslog_$1',`tokt_loglevel|tokr_word',`$2',
195 `lr_loglevel= LOG_'translit(``$1'',`a-z',`A-Z')`; ')')
196 define(`isloglevel',`isloglevellexpat(`$1',`$1')')
200 isloglevellexpat(`warning',`warn(ing)?')
201 isloglevel(`err')dnl also the word error, which has dual meaning (below)
204 isloglevellexpat(`emerg',`emerg|panic')
206 dnl syslog facilities
207 define(`islogfacilitylexpat',
208 `nametypelexpatexec(`syslog_$1',`tokt_logfacility|tokr_word',`$2',
209 `lr_logfacility= LOG_'translit(``$1'',`a-z',`A-Z')`; ')')
210 define(`islogfacility',`islogfacilitylexpat(`$1',`$1')')
211 islogfacilitylexpat(`authpriv',`auth(priv)?|security')
212 islogfacility(`cron')
213 islogfacility(`daemon')
214 islogfacilitylexpat(`kern',`kern(el)?')
216 islogfacility(`mail')
217 islogfacility(`news')
218 islogfacility(`syslog')
219 islogfacility(`user')
220 islogfacility(`uucp')
221 islogfacility(`local0')
222 islogfacility(`local1')
223 islogfacility(`local2')
224 islogfacility(`local3')
225 islogfacility(`local4')
226 islogfacility(`local5')
227 islogfacility(`local6')
228 islogfacility(`local7')
230 dnl misc. word-like things
231 wordtypelexexec(`read',`tokt_readwrite',`')
232 wordtypelexexec(`write',`tokt_readwrite',`')
234 dnl small nonnegative integers and fd ranges
235 dnl some of these have two tokt_ bits set, because they can be several things.
236 autovalistype(`ordinal', `tokt_number|tokt_fdrange|tokr_word')
237 autovalistype(`fdrange', `tokt_fdrange|tokr_punct')
238 autovalistype(`fdstoend', `tokt_fdrange|tokr_punct')
239 nametypelexpatexec(`dollar',`tokt_misc|tokr_punct',`\$',`')
242 wordtypelexexec(`$1',`tokt_fdrange',` lr_max= lr_min= $2; ')')
243 singlefd(`stdin',`0');
244 singlefd(`stdout',`1');
245 singlefd(`stderr',`2');
248 autovalistype(`lwsp', `tokt_misc|tokr_nonstring')
249 autovalistype(`newline', `tokt_misc|tokr_nonstring')
250 autovalistype(`barestring', `tokt_string|tokr_string')
251 autovalistype(`quotedstring', `tokt_string|tokr_string')
253 dnl exceptions - NB that there are also tokv_word_{eof,quit}
254 dnl - see above, near the directives.
255 autovalistype(`eof', `tokt_exception|tokr_nonstring')
256 autovalistype(`quit', `tokt_exception|tokr_nonstring')
257 autovalistype(`error', `tokt_exception|tokr_nonstring')
259 define(`iscondop',`nametypelexpatexec(`$2',`tokt_condop|tokr_punct',`$1',`')')
260 iscondop(`\(',`openparen')
261 iscondop(`\)',`closeparen')
266 dnl words that could be two things
267 wordtypelexexec(`error',`tokt_directive|tokt_loglevel',
268 `lr_dir= df_error; lr_loglevel= LOG_ERR; ')