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