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