lex.l revision 1.1.2.1 1 %{
2 /*-
3 * Copyright (c) 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Paul Borman at Krystal Technologies.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 */
37
38 #ifndef lint
39 #ifndef __NetBSD__
40 static char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 6/6/93";
41 #endif
42 #endif /* not lint */
43
44 #if !defined(__FreeBSD__)
45 #define _BSD_RUNE_T_ int
46 #define _BSD_CT_RUNE_T_ _rune_t
47 #include "runetype.h"
48 #define _A ___A
49 #define _C ___C
50 #define _D ___D
51 #define _G ___G
52 #define _L ___L
53 #define _P ___P
54 #define _S ___S
55 #define _U ___U
56 #define _X ___X
57 #define _B ___B
58 #define _R ___R
59 #define _I ___I
60 #define _T ___T
61 #define _Q ___Q
62 #define _SWM ___SWM
63 #define _SWS ___SWS
64 #define _SW0 ___SW0
65 #define _SW1 ___SW1
66 #define _SW2 ___SW2
67 #define _SW3 ___SW3
68 #else
69 #include <ctype.h>
70 #endif
71 #include <stdio.h>
72 #include <stdlib.h>
73
74 #include "ldef.h"
75 #include "y.tab.h"
76
77 int yylex __P((void));
78 %}
79
80 ODIGIT [0-7]
81 DIGIT [0-9]
82 XDIGIT [0-9a-fA-F]
83 W [\t\n\r ]
84
85 %%
86 \'.\' { yylval.rune = (unsigned char)yytext[1];
87 return(RUNE); }
88
89 '\\a' { yylval.rune = '\a';
90 return(RUNE); }
91 '\\b' { yylval.rune = '\b';
92 return(RUNE); }
93 '\\f' { yylval.rune = '\f';
94 return(RUNE); }
95 '\\n' { yylval.rune = '\n';
96 return(RUNE); }
97 '\\r' { yylval.rune = '\r';
98 return(RUNE); }
99 '\\t' { yylval.rune = '\t';
100 return(RUNE); }
101 '\\v' { yylval.rune = '\v';
102 return(RUNE); }
103
104 0x{XDIGIT}+ { yylval.rune = strtol(yytext, 0, 16);
105 return(RUNE); }
106 0{ODIGIT}+ { yylval.rune = strtol(yytext, 0, 8);
107 return(RUNE); }
108 {DIGIT}+ { yylval.rune = strtol(yytext, 0, 10);
109 return(RUNE); }
110
111
112 MAPLOWER { return(MAPLOWER); }
113 MAPUPPER { return(MAPUPPER); }
114 TODIGIT { return(DIGITMAP); }
115 INVALID { return(INVALID); }
116
117 ALPHA { yylval.i = _A|_R|_G; return(LIST); }
118 CONTROL { yylval.i = _C; return(LIST); }
119 DIGIT { yylval.i = _D|_R|_G; return(LIST); }
120 GRAPH { yylval.i = _G|_R; return(LIST); }
121 LOWER { yylval.i = _L|_R|_G; return(LIST); }
122 PUNCT { yylval.i = _P|_R|_G; return(LIST); }
123 SPACE { yylval.i = _S; return(LIST); }
124 UPPER { yylval.i = _U|_R|_G; return(LIST); }
125 XDIGIT { yylval.i = _X|_R|_G; return(LIST); }
126 BLANK { yylval.i = _B; return(LIST); }
127 PRINT { yylval.i = _R; return(LIST); }
128 IDEOGRAM { yylval.i = _I|_R|_G; return(LIST); }
129 SPECIAL { yylval.i = _T|_R|_G; return(LIST); }
130 PHONOGRAM { yylval.i = _Q|_R|_G; return(LIST); }
131 SWIDTH0 { yylval.i = _SW0; return(LIST); }
132 SWIDTH1 { yylval.i = _SW1; return(LIST); }
133 SWIDTH2 { yylval.i = _SW2; return(LIST); }
134 SWIDTH3 { yylval.i = _SW3; return(LIST); }
135
136 VARIABLE[\t ] { static char vbuf[1024];
137 char *v = vbuf;
138 while ((*v = input()) && *v != '\n')
139 ++v;
140 if (*v) {
141 unput(*v);
142 *v = 0;
143 }
144 yylval.str = vbuf;
145 return(VARIABLE);
146 }
147
148 CHARSET { return(CHARSET); }
149
150 ENCODING { return(ENCODING); }
151
152 \".*\" { char *e = yytext + 1;
153 yylval.str = e;
154 while (*e && *e != '"')
155 ++e;
156 *e = 0;
157 return(STRING); }
158
159 \<|\(|\[ { return(LBRK); }
160
161 \>|\)|\] { return(RBRK); }
162
163 \- { return(THRU); }
164 \.\.\. { return(THRU); }
165
166 \: { return(':'); }
167
168 {W}+ ;
169
170 ^\#.*\n ;
171 \/\* { char lc = 0;
172 do {
173 while ((lc) != '*')
174 if ((lc = input()) == 0)
175 break;
176 } while((lc = input()) != '/');
177 }
178
179 \\$ ;
180 . { printf("Lex is skipping '%s'\n", yytext); }
181 %%
182
183 #if !defined(yywrap)
184 int
185 yywrap()
186 {
187 return(1);
188 }
189 #endif
190