Home | History | Annotate | Line # | Download | only in mklocale
lex.l revision 1.5
      1  1.5     uwe /*	$NetBSD: lex.l,v 1.5 2003/01/27 01:22:10 uwe 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.2  itojun  * 3. All advertising materials mentioning features or use of this software
     20  1.2  itojun  *    must display the following acknowledgement:
     21  1.2  itojun  *	This product includes software developed by the University of
     22  1.2  itojun  *	California, Berkeley and its contributors.
     23  1.2  itojun  * 4. Neither the name of the University nor the names of its contributors
     24  1.2  itojun  *    may be used to endorse or promote products derived from this software
     25  1.2  itojun  *    without specific prior written permission.
     26  1.2  itojun  *
     27  1.2  itojun  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28  1.2  itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29  1.2  itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30  1.2  itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31  1.2  itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32  1.2  itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33  1.2  itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34  1.2  itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35  1.2  itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36  1.2  itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37  1.2  itojun  * SUCH DAMAGE.
     38  1.2  itojun  */
     39  1.2  itojun 
     40  1.4      tv #if HAVE_CONFIG_H
     41  1.4      tv #include "config.h"
     42  1.4      tv #endif
     43  1.4      tv 
     44  1.2  itojun #include <sys/cdefs.h>
     45  1.3  itojun #if defined(LIBC_SCCS) && !defined(lint)
     46  1.2  itojun #if 0
     47  1.2  itojun static char sccsid[] = "@(#)lex.l	8.1 (Berkeley) 6/6/93";
     48  1.2  itojun #else
     49  1.5     uwe __RCSID("$NetBSD: lex.l,v 1.5 2003/01/27 01:22:10 uwe Exp $");
     50  1.2  itojun #endif
     51  1.3  itojun #endif /* LIBC_SCCS and not lint */
     52  1.2  itojun 
     53  1.2  itojun #if !defined(__FreeBSD__)
     54  1.2  itojun #define _BSD_RUNE_T_    int
     55  1.2  itojun #define _BSD_CT_RUNE_T_ rune_t
     56  1.2  itojun #include "runetype.h"
     57  1.5     uwe #else  /* __FreeBSD__ */
     58  1.5     uwe #define _DONT_USE_CTYPE_INLINE_
     59  1.2  itojun #include <ctype.h>
     60  1.2  itojun #endif
     61  1.2  itojun #include <stdio.h>
     62  1.2  itojun #include <stdlib.h>
     63  1.2  itojun 
     64  1.2  itojun #include "ldef.h"
     65  1.2  itojun #include "yacc.h"
     66  1.2  itojun 
     67  1.2  itojun int yylex __P((void));
     68  1.2  itojun %}
     69  1.2  itojun 
     70  1.2  itojun ODIGIT	[0-7]
     71  1.2  itojun DIGIT	[0-9]
     72  1.2  itojun XDIGIT	[0-9a-fA-F]
     73  1.2  itojun W	[\t\n\r ]
     74  1.2  itojun 
     75  1.2  itojun %%
     76  1.2  itojun \'.\'				{ yylval.rune = (unsigned char)yytext[1];
     77  1.2  itojun 				  return(RUNE); }
     78  1.2  itojun 
     79  1.2  itojun '\\a'				{ yylval.rune = '\a';
     80  1.2  itojun 				  return(RUNE); }
     81  1.2  itojun '\\b'				{ yylval.rune = '\b';
     82  1.2  itojun 				  return(RUNE); }
     83  1.2  itojun '\\f'				{ yylval.rune = '\f';
     84  1.2  itojun 				  return(RUNE); }
     85  1.2  itojun '\\n'				{ yylval.rune = '\n';
     86  1.2  itojun 				  return(RUNE); }
     87  1.2  itojun '\\r'				{ yylval.rune = '\r';
     88  1.2  itojun 				  return(RUNE); }
     89  1.2  itojun '\\t'				{ yylval.rune = '\t';
     90  1.2  itojun 				  return(RUNE); }
     91  1.2  itojun '\\v'				{ yylval.rune = '\v';
     92  1.2  itojun 				  return(RUNE); }
     93  1.2  itojun 
     94  1.2  itojun 0x{XDIGIT}+			{ yylval.rune = strtol(yytext, 0, 16);
     95  1.2  itojun 				  return(RUNE); }
     96  1.2  itojun 0{ODIGIT}+			{ yylval.rune = strtol(yytext, 0, 8);
     97  1.2  itojun 				  return(RUNE); }
     98  1.2  itojun {DIGIT}+			{ yylval.rune = strtol(yytext, 0, 10);
     99  1.2  itojun 				  return(RUNE); }
    100  1.2  itojun 
    101  1.2  itojun 
    102  1.2  itojun MAPLOWER			{ return(MAPLOWER); }
    103  1.2  itojun MAPUPPER			{ return(MAPUPPER); }
    104  1.2  itojun TODIGIT				{ return(DIGITMAP); }
    105  1.2  itojun INVALID				{ return(INVALID); }
    106  1.2  itojun 
    107  1.2  itojun ALPHA				{ yylval.i = _CTYPE_A|_CTYPE_R|_CTYPE_G;
    108  1.2  itojun 				  return(LIST); }
    109  1.2  itojun CONTROL				{ yylval.i = _CTYPE_C;
    110  1.2  itojun 				  return(LIST); }
    111  1.2  itojun DIGIT				{ yylval.i = _CTYPE_D|_CTYPE_R|_CTYPE_G;
    112  1.2  itojun 				  return(LIST); }
    113  1.2  itojun GRAPH				{ yylval.i = _CTYPE_G|_CTYPE_R;
    114  1.2  itojun 				  return(LIST); }
    115  1.2  itojun LOWER				{ yylval.i = _CTYPE_L|_CTYPE_R|_CTYPE_G;
    116  1.2  itojun 				  return(LIST); }
    117  1.2  itojun PUNCT				{ yylval.i = _CTYPE_P|_CTYPE_R|_CTYPE_G;
    118  1.2  itojun 				  return(LIST); }
    119  1.2  itojun SPACE				{ yylval.i = _CTYPE_S;
    120  1.2  itojun 				  return(LIST); }
    121  1.2  itojun UPPER				{ yylval.i = _CTYPE_U|_CTYPE_R|_CTYPE_G;
    122  1.2  itojun 				  return(LIST); }
    123  1.2  itojun XDIGIT				{ yylval.i = _CTYPE_X|_CTYPE_R|_CTYPE_G;
    124  1.2  itojun 				  return(LIST); }
    125  1.2  itojun BLANK				{ yylval.i = _CTYPE_B;
    126  1.2  itojun 				  return(LIST); }
    127  1.2  itojun PRINT				{ yylval.i = _CTYPE_R;
    128  1.2  itojun 				  return(LIST); }
    129  1.2  itojun IDEOGRAM			{ yylval.i = _CTYPE_I|_CTYPE_R|_CTYPE_G;
    130  1.2  itojun 				  return(LIST); }
    131  1.2  itojun SPECIAL				{ yylval.i = _CTYPE_T|_CTYPE_R|_CTYPE_G;
    132  1.2  itojun 				  return(LIST); }
    133  1.2  itojun PHONOGRAM			{ yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G;
    134  1.2  itojun 				  return(LIST); }
    135  1.2  itojun SWIDTH0				{ yylval.i = _CTYPE_SW0; return(LIST); }
    136  1.2  itojun SWIDTH1				{ yylval.i = _CTYPE_SW1; return(LIST); }
    137  1.2  itojun SWIDTH2				{ yylval.i = _CTYPE_SW2; return(LIST); }
    138  1.2  itojun SWIDTH3				{ yylval.i = _CTYPE_SW3; return(LIST); }
    139  1.2  itojun 
    140  1.2  itojun VARIABLE[\t ]			{ static char vbuf[1024];
    141  1.2  itojun 				  char *v = vbuf;
    142  1.2  itojun 				  while ((*v = input()) && *v != '\n')
    143  1.2  itojun 					++v;
    144  1.2  itojun                                   if (*v) {
    145  1.2  itojun 					unput(*v);
    146  1.2  itojun 					*v = 0;
    147  1.2  itojun 				  }
    148  1.2  itojun 				  yylval.str = vbuf;
    149  1.2  itojun 				  return(VARIABLE);
    150  1.2  itojun 				}
    151  1.2  itojun 
    152  1.2  itojun CHARSET				{ return(CHARSET); }
    153  1.2  itojun 
    154  1.2  itojun ENCODING			{ return(ENCODING); }
    155  1.2  itojun 
    156  1.2  itojun \".*\"				{ char *e = yytext + 1;
    157  1.2  itojun 				  yylval.str = e;
    158  1.2  itojun 				  while (*e && *e != '"')
    159  1.2  itojun 					++e;
    160  1.2  itojun 				  *e = 0;
    161  1.2  itojun 				  return(STRING); }
    162  1.2  itojun 
    163  1.2  itojun \<|\(|\[			{ return(LBRK); }
    164  1.2  itojun 
    165  1.2  itojun \>|\)|\]			{ return(RBRK); }
    166  1.2  itojun 
    167  1.2  itojun \-				{ return(THRU); }
    168  1.2  itojun \.\.\.				{ return(THRU); }
    169  1.2  itojun 
    170  1.2  itojun \:				{ return(':'); }
    171  1.2  itojun 
    172  1.2  itojun {W}+				;
    173  1.2  itojun 
    174  1.2  itojun ^\#.*\n				;
    175  1.2  itojun \/\*				{ char lc = 0;
    176  1.2  itojun 				  do {
    177  1.2  itojun 				    while ((lc) != '*')
    178  1.2  itojun 					if ((lc = input()) == 0)
    179  1.2  itojun 					    break;
    180  1.2  itojun 				  } while((lc = input()) != '/');
    181  1.2  itojun 				}
    182  1.2  itojun 
    183  1.2  itojun \\$				;
    184  1.2  itojun .				{ printf("Lex is skipping '%s'\n", yytext); }
    185  1.2  itojun %%
    186  1.2  itojun 
    187  1.2  itojun #if	!defined(yywrap)
    188  1.2  itojun int
    189  1.2  itojun yywrap()
    190  1.2  itojun {
    191  1.2  itojun 	return(1);
    192  1.2  itojun }
    193  1.2  itojun #endif
    194