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