Blob


1 /* -*- mode: fundamental; indent-tabs-mode: t; -*- */
2 %{
4 /*
5 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
20 #include <err.h>
21 #include <errno.h>
23 #include "gmid.h"
25 #include "y.tab.h"
27 %}
29 %x COMMENT
30 %x STRING
32 %%
34 <INITIAL># BEGIN(COMMENT);
35 <COMMENT>.*\n yylineno++; BEGIN(INITIAL);
37 <INITIAL>\" BEGIN(STRING);
38 <STRING>[^"]*\" {
39 if ((yylval.str = strdup(yytext)) == NULL)
40 err(1, "strdup");
41 yylval.str[strlen(yylval.str)-1] = '\0'; /* remove the closing quote */
42 BEGIN(INITIAL);
43 return TSTRING;
44 }
46 [0-9]+ {
47 yylval.num = parse_portno(yytext);
48 return TNUM;
49 }
51 off yylval.num = 0; return TBOOL;
52 on yylval.num = 1; return TBOOL;
54 alias return TALIAS;
55 auto return TAUTO;
56 block return TBLOCK;
57 ca return TCA;
58 cert return TCERT;
59 cgi return TCGI;
60 chroot return TCHROOT;
61 client return TCLIENT;
62 default return TDEFAULT;
63 entrypoint return TENTRYPOINT;
64 env return TENV;
65 fastcgi return TFASTCGI;
66 index return TINDEX;
67 ipv6 return TIPV6;
68 key return TKEY;
69 lang return TLANG;
70 location return TLOCATION;
71 log return TLOG;
72 mime return TMIME;
73 port return TPORT;
74 prefork return TPREFORK;
75 protocols return TPROTOCOLS;
76 require return TREQUIRE;
77 return return TRETURN;
78 root return TROOT;
79 server return TSERVER;
80 spawn return TSPAWN;
81 strip return TSTRIP;
82 tcp return TTCP;
83 type return TTYPE;
84 user return TUSER;
86 [{}] return *yytext;
88 \n yylineno++;
90 [ \f\r\t\v]+ ;
92 . yyerror("unexpected character: %c", *yytext); exit(1);
94 %%
96 int
97 yywrap(void)
98 {
99 return 1;