160623Sbostic %{ 260623Sbostic /*- 3*62124Sbostic * Copyright (c) 1993 4*62124Sbostic * The Regents of the University of California. All rights reserved. 560623Sbostic * 660623Sbostic * This code is derived from software contributed to Berkeley by 760623Sbostic * Paul Borman at Krystal Technologies. 860623Sbostic * 960623Sbostic * %sccs.include.redist.c% 1060623Sbostic */ 1160623Sbostic 1260623Sbostic #ifndef lint 13*62124Sbostic static char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 06/06/93"; 1460623Sbostic #endif /* not lint */ 1560623Sbostic 1660623Sbostic #include <ctype.h> 1760623Sbostic #include <stdio.h> 1860623Sbostic #include <stdlib.h> 1960623Sbostic 2060623Sbostic #include "ldef.h" 2160623Sbostic #include "y.tab.h" 2260623Sbostic %} 2360623Sbostic 2460623Sbostic ODIGIT [0-7] 2560623Sbostic DIGIT [0-9] 2660623Sbostic XDIGIT [0-9a-fA-F] 2760623Sbostic W [\t\n\r ] 2860623Sbostic 2960623Sbostic %% 3060623Sbostic \'.\' { yylval.rune = yytext[1]; 3160623Sbostic return(RUNE); } 3260623Sbostic 3360623Sbostic '\\a' { yylval.rune = '\a'; 3460623Sbostic return(RUNE); } 3560623Sbostic '\\b' { yylval.rune = '\b'; 3660623Sbostic return(RUNE); } 3760623Sbostic '\\f' { yylval.rune = '\f'; 3860623Sbostic return(RUNE); } 3960623Sbostic '\\n' { yylval.rune = '\n'; 4060623Sbostic return(RUNE); } 4160623Sbostic '\\r' { yylval.rune = '\r'; 4260623Sbostic return(RUNE); } 4360623Sbostic '\\t' { yylval.rune = '\t'; 4460623Sbostic return(RUNE); } 4560623Sbostic '\\v' { yylval.rune = '\v'; 4660623Sbostic return(RUNE); } 4760623Sbostic 4860623Sbostic 0x{XDIGIT}+ { yylval.rune = strtol(yytext, 0, 16); 4960623Sbostic return(RUNE); } 5060623Sbostic 0{ODIGIT}+ { yylval.rune = strtol(yytext, 0, 8); 5160623Sbostic return(RUNE); } 5260623Sbostic {DIGIT}+ { yylval.rune = strtol(yytext, 0, 10); 5360623Sbostic return(RUNE); } 5460623Sbostic 5560623Sbostic 5660623Sbostic MAPLOWER { return(MAPLOWER); } 5760623Sbostic MAPUPPER { return(MAPUPPER); } 5860623Sbostic TODIGIT { return(DIGITMAP); } 5960623Sbostic INVALID { return(INVALID); } 6060623Sbostic 6160623Sbostic ALPHA { yylval.i = _A|_R|_G; return(LIST); } 6260623Sbostic CONTROL { yylval.i = _C; return(LIST); } 6360623Sbostic DIGIT { yylval.i = _D|_R|_G; return(LIST); } 6460623Sbostic GRAPH { yylval.i = _G|_R; return(LIST); } 6560623Sbostic LOWER { yylval.i = _L|_R|_G; return(LIST); } 6660623Sbostic PUNCT { yylval.i = _P|_R|_G; return(LIST); } 6760623Sbostic SPACE { yylval.i = _S; return(LIST); } 6860623Sbostic UPPER { yylval.i = _U|_R|_G; return(LIST); } 6960623Sbostic XDIGIT { yylval.i = _X|_R|_G; return(LIST); } 7060623Sbostic BLANK { yylval.i = _B; return(LIST); } 7160623Sbostic PRINT { yylval.i = _R; return(LIST); } 7260623Sbostic IDEOGRAM { yylval.i = _I|_R|_G; return(LIST); } 7360623Sbostic SPECIAL { yylval.i = _T|_R|_G; return(LIST); } 7460623Sbostic PHONOGRAM { yylval.i = _Q|_R|_G; return(LIST); } 7560623Sbostic 7660623Sbostic VARIABLE[\t ] { static char vbuf[1024]; 7760623Sbostic char *v = vbuf; 7860623Sbostic while ((*v = input()) && *v != '\n') 7960623Sbostic ++v; 8060623Sbostic if (*v) { 8160623Sbostic unput(*v); 8260623Sbostic *v = 0; 8360623Sbostic } 8460623Sbostic yylval.str = vbuf; 8560623Sbostic return(VARIABLE); 8660623Sbostic } 8760623Sbostic 8860623Sbostic ENCODING { return(ENCODING); } 8960623Sbostic 9060623Sbostic \".*\" { char *e = yytext + 1; 9160623Sbostic yylval.str = e; 9260623Sbostic while (*e && *e != '"') 9360623Sbostic ++e; 9460623Sbostic *e = 0; 9560623Sbostic return(STRING); } 9660623Sbostic 9760623Sbostic \<|\(|\[ { return(LBRK); } 9860623Sbostic 9960623Sbostic \>|\)|\] { return(RBRK); } 10060623Sbostic 10160623Sbostic \- { return(THRU); } 10260623Sbostic \.\.\. { return(THRU); } 10360623Sbostic 10460623Sbostic \: { return(':'); } 10560623Sbostic 10660623Sbostic {W}+ ; 10760623Sbostic 10860623Sbostic ^\#.*\n ; 10960623Sbostic \/\* { char lc = 0; 11060623Sbostic do { 11160623Sbostic while ((lc) != '*') 11260623Sbostic if ((lc = input()) == 0) 11360623Sbostic break; 11460623Sbostic } while((lc = input()) != '/'); 11560623Sbostic } 11660623Sbostic 11760623Sbostic \\$ ; 11860623Sbostic . { printf("Lex is skipping '%s'\n", yytext); } 11960623Sbostic %% 12060623Sbostic 12160623Sbostic #if !defined(yywrap) 12260623Sbostic yywrap() 12360623Sbostic { 12460623Sbostic return(1); 12560623Sbostic } 12660623Sbostic #endif 127