chiark / gitweb /
Initial CVS checkin.
[userv.git] / lexer.l.m4
1 dnl  userv - lexer.l.m4
2 dnl  lexer, passed through m4 with defs from langauge.i4
3 /*
4  *   Copyright (C)1996-1997 Ian Jackson
5  *  
6  *   This is free software; you can redistribute it and/or modify it
7  *   under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *  
11  *   This program is distributed in the hope that it will be useful, but
12  *   WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *   General Public License for more details.
15  *  
16  *   You should have received a copy of the GNU General Public License
17  *   along with userv; if not, write to the Free Software
18  *   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 %{
22 include(language.i4)
23
24 #include <syslog.h>
25 #include <assert.h>
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <ctype.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <pwd.h>
32 #include <grp.h>
33 #include <fnmatch.h>
34 #include <limits.h>
35 #include <dirent.h>
36 #include <sys/stat.h>
37 #include <time.h>
38
39 #include "config.h"
40 #include "common.h"
41 #include "daemon.h"
42 #include "lib.h"
43 #include "tokens.h"
44
45 #define HYPHEN '-'
46
47 static int lineno, atnewline, notedreferer;
48 static int dequote(char *inplace);
49 %}
50 %option noyywrap
51 %%
52
53 dnl simple words
54 undivert(3)
55 changequote({*,*})
56 {*
57 [\ \t]+                 return tokv_lwsp;
58 [\ \t]*\n               atnewline= 1; lineno++; return tokv_newline;
59 [\ \t]*\#[^\n]*\n       atnewline= 1; lineno++; return tokv_newline;
60 [\ \t]*\#[^\n]*         atnewline= 0; parseerrprint("missing newline at eof after comment"); return tokv_error;
61 [^\ \t\n]+              atnewline= 0; return tokv_barestring;
62 <<EOF>>                 return tokv_eof;
63 \"([^\\\"\n]|\\[a-z]|\\[0-9]{3}|\\x[0-9a-f]{2}|\\[:punct:]|\\[ \t]*\n)*\" return dequote(yytext);
64 \".*                    atnewline= 0; parseerrprint("misquoted or unterminated string"); return tokv_error;
65 *}
66 changequote(`,')
67 %%
68 `
69 #include "parser.c"
70 '
71 divert(-1)
72 undivert
73