lex.l revision 16017
1131320Sdas%{ 2131320Sdas/*- 3131320Sdas * Copyright (c) 1993 4131320Sdas * The Regents of the University of California. All rights reserved. 5131320Sdas * 6131320Sdas * This code is derived from software contributed to Berkeley by 7131320Sdas * Paul Borman at Krystal Technologies. 8131320Sdas * 9131320Sdas * Redistribution and use in source and binary forms, with or without 10131320Sdas * modification, are permitted provided that the following conditions 11131320Sdas * are met: 12131320Sdas * 1. Redistributions of source code must retain the above copyright 13131320Sdas * notice, this list of conditions and the following disclaimer. 14131320Sdas * 2. Redistributions in binary form must reproduce the above copyright 15131320Sdas * notice, this list of conditions and the following disclaimer in the 16131320Sdas * documentation and/or other materials provided with the distribution. 17131320Sdas * 3. All advertising materials mentioning features or use of this software 18131320Sdas * must display the following acknowledgement: 19131320Sdas * This product includes software developed by the University of 20131320Sdas * California, Berkeley and its contributors. 21131320Sdas * 4. Neither the name of the University nor the names of its contributors 22131320Sdas * may be used to endorse or promote products derived from this software 23131320Sdas * without specific prior written permission. 24131320Sdas * 25131320Sdas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26131320Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27131320Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28131320Sdas * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29131320Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30131320Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31131320Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32131320Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33131320Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34131320Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35131320Sdas * SUCH DAMAGE. 36131320Sdas */ 37131320Sdas 38131320Sdas#ifndef lint 39131320Sdasstatic char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 6/6/93"; 40131320Sdas#endif /* not lint */ 41131320Sdas 42131320Sdas#include <ctype.h> 43131320Sdas#include <stdio.h> 44131320Sdas#include <stdlib.h> 45131320Sdas 46131320Sdas#include "ldef.h" 47131320Sdas#include "yacc.tab.h" 48131320Sdas%} 49131320Sdas 50131320SdasODIGIT [0-7] 51131320SdasDIGIT [0-9] 52131320SdasXDIGIT [0-9a-fA-F] 53131320SdasW [\t\n\r ] 54131320Sdas 55131320Sdas%% 56\'.\' { yylval.rune = yytext[1]; 57 return(RUNE); } 58 59'\\a' { yylval.rune = '\a'; 60 return(RUNE); } 61'\\b' { yylval.rune = '\b'; 62 return(RUNE); } 63'\\f' { yylval.rune = '\f'; 64 return(RUNE); } 65'\\n' { yylval.rune = '\n'; 66 return(RUNE); } 67'\\r' { yylval.rune = '\r'; 68 return(RUNE); } 69'\\t' { yylval.rune = '\t'; 70 return(RUNE); } 71'\\v' { yylval.rune = '\v'; 72 return(RUNE); } 73 740x{XDIGIT}+ { yylval.rune = strtol(yytext, 0, 16); 75 return(RUNE); } 760{ODIGIT}+ { yylval.rune = strtol(yytext, 0, 8); 77 return(RUNE); } 78{DIGIT}+ { yylval.rune = strtol(yytext, 0, 10); 79 return(RUNE); } 80 81 82MAPLOWER { return(MAPLOWER); } 83MAPUPPER { return(MAPUPPER); } 84TODIGIT { return(DIGITMAP); } 85INVALID { return(INVALID); } 86 87ALPHA { yylval.i = _A|_R|_G; return(LIST); } 88CONTROL { yylval.i = _C; return(LIST); } 89DIGIT { yylval.i = _D|_R|_G; return(LIST); } 90GRAPH { yylval.i = _G|_R; return(LIST); } 91LOWER { yylval.i = _L|_R|_G; return(LIST); } 92PUNCT { yylval.i = _P|_R|_G; return(LIST); } 93SPACE { yylval.i = _S; return(LIST); } 94UPPER { yylval.i = _U|_R|_G; return(LIST); } 95XDIGIT { yylval.i = _X|_R|_G; return(LIST); } 96BLANK { yylval.i = _B; return(LIST); } 97PRINT { yylval.i = _R; return(LIST); } 98IDEOGRAM { yylval.i = _I|_R|_G; return(LIST); } 99SPECIAL { yylval.i = _T|_R|_G; return(LIST); } 100PHONOGRAM { yylval.i = _Q|_R|_G; return(LIST); } 101 102VARIABLE[\t ] { static char vbuf[1024]; 103 char *v = vbuf; 104 while ((*v = input()) && *v != '\n') 105 ++v; 106 if (*v) { 107 unput(*v); 108 *v = 0; 109 } 110 yylval.str = vbuf; 111 return(VARIABLE); 112 } 113 114ENCODING { return(ENCODING); } 115 116\".*\" { char *e = yytext + 1; 117 yylval.str = e; 118 while (*e && *e != '"') 119 ++e; 120 *e = 0; 121 return(STRING); } 122 123\<|\(|\[ { return(LBRK); } 124 125\>|\)|\] { return(RBRK); } 126 127\- { return(THRU); } 128\.\.\. { return(THRU); } 129 130\: { return(':'); } 131 132{W}+ ; 133 134^\#.*\n ; 135\/\* { char lc = 0; 136 do { 137 while ((lc) != '*') 138 if ((lc = input()) == 0) 139 break; 140 } while((lc = input()) != '/'); 141 } 142 143\\$ ; 144. { printf("Lex is skipping '%s'\n", yytext); } 145%% 146 147#if !defined(yywrap) 148yywrap() 149{ 150 return(1); 151} 152#endif 153