]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSShared/dnsextd_lexer.l
mDNSResponder-212.1.tar.gz
[apple/mdnsresponder.git] / mDNSShared / dnsextd_lexer.l
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16
17 Change History (most recent first):
18
19 $Log: dnsextd_lexer.l,v $
20 Revision 1.6 2008/07/18 17:40:46 cheshire
21 Removed redundant definition of "YY_NO_UNPUT" (not needed now that we use "%option nounput" instead)
22
23 Revision 1.5 2008/06/24 18:32:26 mcguire
24 <rdar://problem/6024542> flex producing .c files that result in warnings
25
26 Revision 1.4 2007/05/25 20:01:43 cheshire
27 <rdar://problem/5226767> /usr/bin/flex failures prevent mDNSResponder from building
28 Only define "int yylineno" on flex 2.5.4 and earlier
29
30 Revision 1.3 2006/08/14 23:24:56 cheshire
31 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
32
33 Revision 1.2 2006/07/06 20:41:14 cheshire
34 <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
35 Use derived filename "dnsextd_parser.h" instead of "dnsextd_parser.y.h"
36
37 Revision 1.1 2006/07/06 00:09:05 cheshire
38 <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
39
40 */
41
42 %{
43 #include <string.h>
44 #include <stdio.h>
45 #include "dnsextd_parser.h"
46
47
48 extern YYSTYPE yylval;
49
50 /* Mac OS X 10.4 has flex version 2.5.4, which doesn't define yylineno for us */
51 /* Mac OS X 10.5 has flex version 2.5.33, which does define yylineno */
52 #if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION <= 4
53 int yylineno = 1;
54 #endif
55
56 int yylex(void);
57
58 static char*
59 StripQuotes
60 (
61 const char * string
62 )
63 {
64 char * dup;
65
66 dup = strdup( string + 1);
67
68 dup[ strlen( dup ) - 1 ] = '\0';
69
70 return dup;
71 }
72
73
74 %}
75
76 %option nounput
77 %%
78
79 options return OPTIONS;
80 listen-on return LISTEN_ON;
81 nameserver return NAMESERVER;
82 port return PORT;
83 address return ADDRESS;
84 llq return LLQ;
85 public return PUBLIC;
86 private return PRIVATE;
87 key return KEY;
88 allow-update return ALLOWUPDATE;
89 allow-query return ALLOWQUERY;
90 algorithm return ALGORITHM;
91 secret return SECRET;
92 zone return ZONE;
93 type return TYPE;
94 allow return ALLOW;
95 \{ return OBRACE;
96 \} return EBRACE;
97 ; return SEMICOLON;
98 IN return IN;
99 \* yylval.string = strdup(yytext); return WILDCARD;
100 [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ yylval.string = strdup(yytext); return DOTTED_DECIMAL_ADDRESS;
101 [0123456789]+ yylval.number = atoi(yytext); return NUMBER;
102 [a-zA-Z0-9]+(\.[a-zA-Z0-9]+)* yylval.string = strdup(yytext); return HOSTNAME;
103 [a-zA-Z0-9\.]+([a-zA-Z0-9\.]+)* yylval.string = strdup(yytext); return DOMAINNAME;
104 \"([^"\\\r\n]*(\\.[^"\\\r\n]*)*)\" yylval.string = StripQuotes(yytext); return QUOTEDSTRING;
105 [\/][\/].* /* ignore C++ style comments */;
106 \n yylineno++; /* ignore EOL */;
107 [ \t]+ /* ignore whitespace */;
108 %%