[BACK]Return to lex.l CVS log [TXT][DIR] Up to [local] / src / usr.bin / mklocale

Annotation of src/usr.bin/mklocale/lex.l, Revision 1.1

1.1     ! espie       1: /*     $NetBSD: lex.l,v 1.13 2003/10/27 00:12:43 lukem 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: #include <sys/cdefs.h>
        !            37:
        !            38: #include "locale/runetype.h"
        !            39: #include <stdio.h>
        !            40: #include <stdlib.h>
        !            41:
        !            42: #include "ldef.h"
        !            43: #include "yacc.h"
        !            44:
        !            45: int yylex(void);
        !            46: %}
        !            47:
        !            48: ODIGIT [0-7]
        !            49: DIGIT  [0-9]
        !            50: XDIGIT [0-9a-fA-F]
        !            51: W      [\t\n\r ]
        !            52:
        !            53: %%
        !            54: \'.\'                          { yylval.rune = (unsigned char)yytext[1];
        !            55:                                  return(RUNE); }
        !            56:
        !            57: '\\a'                          { yylval.rune = '\a';
        !            58:                                  return(RUNE); }
        !            59: '\\b'                          { yylval.rune = '\b';
        !            60:                                  return(RUNE); }
        !            61: '\\f'                          { yylval.rune = '\f';
        !            62:                                  return(RUNE); }
        !            63: '\\n'                          { yylval.rune = '\n';
        !            64:                                  return(RUNE); }
        !            65: '\\r'                          { yylval.rune = '\r';
        !            66:                                  return(RUNE); }
        !            67: '\\t'                          { yylval.rune = '\t';
        !            68:                                  return(RUNE); }
        !            69: '\\v'                          { yylval.rune = '\v';
        !            70:                                  return(RUNE); }
        !            71:
        !            72: 0x{XDIGIT}+                    { yylval.rune = strtoul(yytext, 0, 16);
        !            73:                                  return(RUNE); }
        !            74: 0{ODIGIT}+                     { yylval.rune = strtoul(yytext, 0, 8);
        !            75:                                  return(RUNE); }
        !            76: {DIGIT}+                       { yylval.rune = strtoul(yytext, 0, 10);
        !            77:                                  return(RUNE); }
        !            78:
        !            79:
        !            80: MAPLOWER                       { return(MAPLOWER); }
        !            81: MAPUPPER                       { return(MAPUPPER); }
        !            82: TODIGIT                                { return(DIGITMAP); }
        !            83: INVALID                                { return(INVALID); }
        !            84:
        !            85: ALPHA                          { yylval.i = _RUNETYPE_A|_RUNETYPE_R|_RUNETYPE_G;
        !            86:                                  return(LIST); }
        !            87: CONTROL                                { yylval.i = _RUNETYPE_C;
        !            88:                                  return(LIST); }
        !            89: DIGIT                          { yylval.i = _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G;
        !            90:                                  return(LIST); }
        !            91: GRAPH                          { yylval.i = _RUNETYPE_G|_RUNETYPE_R;
        !            92:                                  return(LIST); }
        !            93: LOWER                          { yylval.i = _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G;
        !            94:                                  return(LIST); }
        !            95: PUNCT                          { yylval.i = _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G;
        !            96:                                  return(LIST); }
        !            97: SPACE                          { yylval.i = _RUNETYPE_S;
        !            98:                                  return(LIST); }
        !            99: UPPER                          { yylval.i = _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G;
        !           100:                                  return(LIST); }
        !           101: XDIGIT                         { yylval.i = _RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G;
        !           102:                                  return(LIST); }
        !           103: BLANK                          { yylval.i = _RUNETYPE_B;
        !           104:                                  return(LIST); }
        !           105: PRINT                          { yylval.i = _RUNETYPE_R;
        !           106:                                  return(LIST); }
        !           107: IDEOGRAM                       { yylval.i = _RUNETYPE_I|_RUNETYPE_R|_RUNETYPE_G;
        !           108:                                  return(LIST); }
        !           109: SPECIAL                                { yylval.i = _RUNETYPE_T|_RUNETYPE_R|_RUNETYPE_G;
        !           110:                                  return(LIST); }
        !           111: PHONOGRAM                      { yylval.i = _RUNETYPE_Q|_RUNETYPE_R|_RUNETYPE_G;
        !           112:                                  return(LIST); }
        !           113: SWIDTH0                                { yylval.i = _RUNETYPE_SW0; return(LIST); }
        !           114: SWIDTH1                                { yylval.i = _RUNETYPE_SW1; return(LIST); }
        !           115: SWIDTH2                                { yylval.i = _RUNETYPE_SW2; return(LIST); }
        !           116: SWIDTH3                                { yylval.i = _RUNETYPE_SW3; return(LIST); }
        !           117:
        !           118: VARIABLE[\t ]                  { static char vbuf[1024];
        !           119:                                  char *v = vbuf;
        !           120:                                  while ((*v = input()) && *v != '\n')
        !           121:                                        ++v;
        !           122:                                   if (*v) {
        !           123:                                        unput(*v);
        !           124:                                        *v = 0;
        !           125:                                  }
        !           126:                                  yylval.str = vbuf;
        !           127:                                  return(VARIABLE);
        !           128:                                }
        !           129:
        !           130: CHARSET                                { return(CHARSET); }
        !           131:
        !           132: ENCODING                       { return(ENCODING); }
        !           133:
        !           134: \".*\"                         { char *e = yytext + 1;
        !           135:                                  yylval.str = e;
        !           136:                                  while (*e && *e != '"')
        !           137:                                        ++e;
        !           138:                                  *e = 0;
        !           139:                                  return(STRING); }
        !           140:
        !           141: \<|\(|\[                       { return(LBRK); }
        !           142:
        !           143: \>|\)|\]                       { return(RBRK); }
        !           144:
        !           145: \-                             { return(THRU); }
        !           146: \.\.\.                         { return(THRU); }
        !           147:
        !           148: \:                             { return(':'); }
        !           149:
        !           150: {W}+                           ;
        !           151:
        !           152: ^\#.*\n                                ;
        !           153: \/\*                           { char lc = 0;
        !           154:                                  do {
        !           155:                                    while ((lc) != '*')
        !           156:                                        if ((lc = input()) == 0)
        !           157:                                            break;
        !           158:                                  } while((lc = input()) != '/');
        !           159:                                }
        !           160:
        !           161: \\$                            ;
        !           162: .                              { printf("Lex is skipping '%s'\n", yytext); }
        !           163: %%
        !           164:
        !           165: #if    !defined(yywrap)
        !           166: int
        !           167: yywrap()
        !           168: {
        !           169:        return(1);
        !           170: }
        !           171: #endif