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