Home | History | Annotate | Line # | Download | only in mklocale
      1  1.20  dholland /*	$NetBSD: lex.l,v 1.20 2016/09/03 05:56:59 dholland 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.20  dholland __RCSID("$NetBSD: lex.l,v 1.20 2016/09/03 05:56:59 dholland Exp $");
     46   1.2    itojun #endif
     47  1.10  christos #endif /* not lint */
     48   1.2    itojun 
     49   1.2    itojun #include <stdio.h>
     50   1.2    itojun #include <stdlib.h>
     51   1.2    itojun 
     52  1.16   tnozaki #include "citrus_namespace.h"
     53  1.16   tnozaki #include "citrus_bcs.h"
     54  1.14   tnozaki 
     55  1.18   tnozaki #include "runetype_file.h"
     56  1.17   tnozaki 
     57   1.2    itojun #include "ldef.h"
     58   1.2    itojun #include "yacc.h"
     59   1.2    itojun 
     60  1.19     sevan int yylex(void);
     61   1.2    itojun %}
     62   1.2    itojun 
     63   1.2    itojun ODIGIT	[0-7]
     64   1.2    itojun DIGIT	[0-9]
     65   1.2    itojun XDIGIT	[0-9a-fA-F]
     66   1.2    itojun W	[\t\n\r ]
     67   1.2    itojun 
     68   1.2    itojun %%
     69   1.2    itojun \'.\'				{ yylval.rune = (unsigned char)yytext[1];
     70   1.2    itojun 				  return(RUNE); }
     71   1.2    itojun 
     72   1.2    itojun '\\a'				{ yylval.rune = '\a';
     73   1.2    itojun 				  return(RUNE); }
     74   1.2    itojun '\\b'				{ yylval.rune = '\b';
     75   1.2    itojun 				  return(RUNE); }
     76   1.2    itojun '\\f'				{ yylval.rune = '\f';
     77   1.2    itojun 				  return(RUNE); }
     78   1.2    itojun '\\n'				{ yylval.rune = '\n';
     79   1.2    itojun 				  return(RUNE); }
     80   1.2    itojun '\\r'				{ yylval.rune = '\r';
     81   1.2    itojun 				  return(RUNE); }
     82   1.2    itojun '\\t'				{ yylval.rune = '\t';
     83   1.2    itojun 				  return(RUNE); }
     84   1.2    itojun '\\v'				{ yylval.rune = '\v';
     85   1.2    itojun 				  return(RUNE); }
     86   1.2    itojun 
     87  1.14   tnozaki 0x{XDIGIT}+			{ yylval.rune = _bcs_strtoul(yytext, 0, 16);
     88   1.2    itojun 				  return(RUNE); }
     89  1.14   tnozaki 0{ODIGIT}+			{ yylval.rune = _bcs_strtoul(yytext, 0, 8);
     90   1.2    itojun 				  return(RUNE); }
     91  1.14   tnozaki {DIGIT}+			{ yylval.rune = _bcs_strtoul(yytext, 0, 10);
     92   1.2    itojun 				  return(RUNE); }
     93   1.2    itojun 
     94   1.2    itojun 
     95   1.2    itojun MAPLOWER			{ return(MAPLOWER); }
     96   1.2    itojun MAPUPPER			{ return(MAPUPPER); }
     97   1.2    itojun TODIGIT				{ return(DIGITMAP); }
     98   1.2    itojun INVALID				{ return(INVALID); }
     99   1.2    itojun 
    100   1.8  tshiozak ALPHA				{ yylval.i = _RUNETYPE_A|_RUNETYPE_R|_RUNETYPE_G;
    101   1.2    itojun 				  return(LIST); }
    102   1.8  tshiozak CONTROL				{ yylval.i = _RUNETYPE_C;
    103   1.2    itojun 				  return(LIST); }
    104   1.8  tshiozak DIGIT				{ yylval.i = _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G;
    105   1.2    itojun 				  return(LIST); }
    106   1.8  tshiozak GRAPH				{ yylval.i = _RUNETYPE_G|_RUNETYPE_R;
    107   1.2    itojun 				  return(LIST); }
    108   1.8  tshiozak LOWER				{ yylval.i = _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G;
    109   1.2    itojun 				  return(LIST); }
    110   1.8  tshiozak PUNCT				{ yylval.i = _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G;
    111   1.2    itojun 				  return(LIST); }
    112   1.8  tshiozak SPACE				{ yylval.i = _RUNETYPE_S;
    113   1.2    itojun 				  return(LIST); }
    114   1.8  tshiozak UPPER				{ yylval.i = _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G;
    115   1.2    itojun 				  return(LIST); }
    116   1.8  tshiozak XDIGIT				{ yylval.i = _RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G;
    117   1.2    itojun 				  return(LIST); }
    118   1.8  tshiozak BLANK				{ yylval.i = _RUNETYPE_B;
    119   1.2    itojun 				  return(LIST); }
    120   1.8  tshiozak PRINT				{ yylval.i = _RUNETYPE_R;
    121   1.2    itojun 				  return(LIST); }
    122   1.8  tshiozak IDEOGRAM			{ yylval.i = _RUNETYPE_I|_RUNETYPE_R|_RUNETYPE_G;
    123   1.2    itojun 				  return(LIST); }
    124   1.8  tshiozak SPECIAL				{ yylval.i = _RUNETYPE_T|_RUNETYPE_R|_RUNETYPE_G;
    125   1.2    itojun 				  return(LIST); }
    126   1.8  tshiozak PHONOGRAM			{ yylval.i = _RUNETYPE_Q|_RUNETYPE_R|_RUNETYPE_G;
    127   1.2    itojun 				  return(LIST); }
    128   1.8  tshiozak SWIDTH0				{ yylval.i = _RUNETYPE_SW0; return(LIST); }
    129   1.8  tshiozak SWIDTH1				{ yylval.i = _RUNETYPE_SW1; return(LIST); }
    130   1.8  tshiozak SWIDTH2				{ yylval.i = _RUNETYPE_SW2; return(LIST); }
    131   1.8  tshiozak SWIDTH3				{ yylval.i = _RUNETYPE_SW3; return(LIST); }
    132   1.2    itojun 
    133   1.2    itojun VARIABLE[\t ]			{ static char vbuf[1024];
    134   1.2    itojun 				  char *v = vbuf;
    135   1.2    itojun 				  while ((*v = input()) && *v != '\n')
    136   1.2    itojun 					++v;
    137   1.2    itojun                                   if (*v) {
    138   1.2    itojun 					unput(*v);
    139   1.2    itojun 					*v = 0;
    140   1.2    itojun 				  }
    141   1.2    itojun 				  yylval.str = vbuf;
    142   1.2    itojun 				  return(VARIABLE);
    143   1.2    itojun 				}
    144   1.2    itojun 
    145   1.2    itojun CHARSET				{ return(CHARSET); }
    146   1.2    itojun 
    147   1.2    itojun ENCODING			{ return(ENCODING); }
    148   1.2    itojun 
    149   1.2    itojun \".*\"				{ char *e = yytext + 1;
    150   1.2    itojun 				  yylval.str = e;
    151   1.2    itojun 				  while (*e && *e != '"')
    152   1.2    itojun 					++e;
    153   1.2    itojun 				  *e = 0;
    154   1.2    itojun 				  return(STRING); }
    155   1.2    itojun 
    156   1.2    itojun \<|\(|\[			{ return(LBRK); }
    157   1.2    itojun 
    158   1.2    itojun \>|\)|\]			{ return(RBRK); }
    159   1.2    itojun 
    160   1.2    itojun \-				{ return(THRU); }
    161   1.2    itojun \.\.\.				{ return(THRU); }
    162   1.2    itojun 
    163   1.2    itojun \:				{ return(':'); }
    164   1.2    itojun 
    165   1.2    itojun {W}+				;
    166   1.2    itojun 
    167   1.2    itojun ^\#.*\n				;
    168   1.2    itojun \/\*				{ char lc = 0;
    169   1.2    itojun 				  do {
    170   1.2    itojun 				    while ((lc) != '*')
    171   1.2    itojun 					if ((lc = input()) == 0)
    172   1.2    itojun 					    break;
    173   1.2    itojun 				  } while((lc = input()) != '/');
    174   1.2    itojun 				}
    175   1.2    itojun 
    176   1.2    itojun \\$				;
    177   1.2    itojun .				{ printf("Lex is skipping '%s'\n", yytext); }
    178   1.2    itojun %%
    179   1.2    itojun 
    180   1.2    itojun #if	!defined(yywrap)
    181   1.2    itojun int
    182  1.20  dholland yywrap(void)
    183   1.2    itojun {
    184   1.2    itojun 	return(1);
    185   1.2    itojun }
    186   1.2    itojun #endif
    187