chiark / gitweb /
better clean
[userv.git] / language.i4
index 8d4088c..d660b27 100644 (file)
@@ -1,7 +1,7 @@
 dnl  userv - language.i4
 dnl  definition of the configuration language, used for tokens.h and lexer.l
 dnl
-dnl  Copyright (C)1996-1997 Ian Jackson
+dnl  Copyright (C)1996-1997,1999 Ian Jackson
 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
@@ -32,19 +32,19 @@ divert(2)dnl
   format(``%-30s'',`tokv_$1=')`$3|toki_$1',
 divert(odiv)popdef(`odiv')')
 
-define(`cautotoki',`01')
-define(`cautotokt',eval(`010000'))
+define(`cautotoki',eval(`0x1'))
+define(`cautotokt',eval(`0x1000'))
 
-define(`autovalistype',`hasvalistype(`$1',format(``0%03o'',cautotoki),`$2')`'define(`cautotoki',incr(cautotoki))')
+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(``0%011o'',cautotokt),
+  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'`atnewline= 0; return tokv_$1; }'
+`$3 { $4'`return tokv_$1; }'
 divert(odiv)popdef(`odiv')')
 
 define(`wordtypelexexec',
@@ -66,7 +66,9 @@ autovaldeftype(`readwrite')
 autovaldeftype(`string')
 autovaldeftype(`execmode')
 autovaldeftype(`ehandlemode')
+autovaldeftype(`builtinservice')
 autovaldeftype(`misc')
+autovaldeftype(`internal')
 
 dnl simple isdirectives
 define(`isdirectivefn',`dnl
@@ -74,7 +76,8 @@ 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'),`$2')')
+define(`isdirectiveinternal',`isdirectivefn(`$1',`dfi_'makename(`$1'),
+                                            `|tokt_internal$2')')
 define(`isexecmode',`isdirective(`$1',`|tokt_execmode')')
 define(`isehandlemode',`isdirective(`$1',`|tokt_ehandlemode')')
 define(`isfdwant',`isdirectivefn(`$1',`dfg_fdwant',`',
@@ -83,10 +86,12 @@ 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')
-isexecmode(`execute')
+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')
@@ -99,7 +104,6 @@ isflagpair(`set-environment')
 isflagpair(`suppress-args')
 isflagpair(`disconnect-hup')
 isdirective(`cd')
-isdirective(`reset')
 isdirective(`user-rcfile')
 isdirective(`include')
 isdirectivefn(`include-ifexist',`df_include')
@@ -107,7 +111,7 @@ isdirective(`include-lookup')
 isdirectivefn(`include-lookup-all',`df_includelookup')
 isdirective(`include-directory')
 isdirective(`message')
-isdirectivefn(`_include-sysconfig',`df_include')
+isdirectivefn(`_include-sysconfig',`df_include',`|tokt_internal')
 isdirectiveinternal(`_include-user-rcfile')
 isdirectiveinternal(`_include-client-config')
 
@@ -142,6 +146,33 @@ 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')`; ')')
@@ -165,7 +196,7 @@ isloglevellexpat(`warning',`warn(ing)?')
 isloglevel(`err')dnl also the word error, which has dual meaning (below)
 isloglevel(`crit')
 isloglevel(`alert')
-isloglevelexpat(`emerg',`emerg|panic')
+isloglevellexpat(`emerg',`emerg|panic')
 
 dnl syslog facilities
 define(`islogfacilitylexpat',
@@ -196,25 +227,10 @@ 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
-dnl things.
-nametypelexpatexec(`ordinal',`tokt_number|tokt_fdrange|tokr_word',`[0-9]{1,8}',
-`{ char *ep;
-   lr_min=lr_max= (int)strtoul(yytext,&ep,10);
-   assert(!*ep); }; ')
-nametypelexpatexec(`fdrange',`tokt_fdrange|tokr_punct',`[0-9]{1,8}-[0-9]{1,8}',
-`{ char *ep;
-   lr_min=(int)strtoul(yytext,&ep,10);
-   assert(*ep == HYPHEN); assert(*++ep);
-   lr_max=(int)strtoul(ep,&ep,10);
-   if (lr_max < lr_min) {
-     atnewline= 0; parseerrprint("fd range has min > max"); return tokv_error;
-   }
-   assert(!*ep); }; ')
-nametypelexpatexec(`fdstoend',`tokt_fdrange|tokr_punct',`[0-9]{1,8}-',
-`{ char *ep;
-   lr_min= (int)strtoul(yytext,&ep,10); lr_max=-1;
-   assert(*ep == HYPHEN); assert(!*++ep); }; ')
+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',`\$',`')
 
 dnl non-word things