1 /*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer, 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software withough specific prior written permission 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * $Id: lex.l,v 1.7 1998/08/03 11:33:22 yokota Exp $ 29 */ 30 31 %{ 32 33 #include "lex.h" 34 35 %} 36 37 D [0-9] 38 X [0-9a-fA-F] 39 A . 40 L [OCNB] 41 42 %% 43 44 nop { return TNOP; } 45 lshift { return TLSH; } 46 rshift { return TRSH; } 47 clock { return TCLK; } 48 nlock { return TNLK; } 49 slock { return TSLK; } 50 lalt|alt { return TLALT; } 51 btab { return TBTAB; } 52 lctrl|ctrl { return TLCTR; } 53 nscr { return TNEXT; } 54 rctrl { return TRCTR; } 55 ralt { return TRALT; } 56 alock { return TALK; } 57 ashift { return TASH; } 58 meta { return TMETA; } 59 boot { return TRBT; } 60 debug { return TDBG; } 61 susp { return TSUSP; } 62 saver { return TSPSC; } 63 64 NUL|nul { number = 0; return TNUM; } 65 SOH|soh { number = 1; return TNUM; } 66 STX|stx { number = 2; return TNUM; } 67 ETX|etx { number = 3; return TNUM; } 68 EOT|eot { number = 4; return TNUM; } 69 ENQ|enq { number = 5; return TNUM; } 70 ACK|ack { number = 6; return TNUM; } 71 BEL|bel { number = 7; return TNUM; } 72 BS|bs { number = 8; return TNUM; } 73 HT|ht { number = 9; return TNUM; } 74 LF|lf|NL|nl { number = 10; return TNUM; } 75 VT|vt { number = 11; return TNUM; } 76 FF|ff|NP|np { number = 12; return TNUM; } 77 CR|cr { number = 13; return TNUM; } 78 SO|so { number = 14; return TNUM; } 79 SI|si { number = 15; return TNUM; } 80 DLE|dle { number = 16; return TNUM; } 81 DC1|dc1 { number = 17; return TNUM; } 82 DC2|dc2 { number = 18; return TNUM; } 83 DC3|dc3 { number = 19; return TNUM; } 84 DC4|dc4 { number = 20; return TNUM; } 85 NAK|nak { number = 21; return TNUM; } 86 SYN|syn { number = 22; return TNUM; } 87 ETB|etb { number = 23; return TNUM; } 88 CAN|can { number = 24; return TNUM; } 89 EM|em { number = 25; return TNUM; } 90 SUB|sub { number = 26; return TNUM; } 91 ESC|esc { number = 27; return TNUM; } 92 FS|fs { number = 28; return TNUM; } 93 GS|gs { number = 29; return TNUM; } 94 RS|rs { number = 30; return TNUM; } 95 NS|ns { number = 31; return TNUM; } 96 US|us { number = 31; return TNUM; } 97 SP|sp { number = 32; return TNUM; } 98 DEL|del { number = 127; return TNUM; } 99 100 dgra|DGRA { number = 0; return TACC; } 101 dacu|DACU { number = 1; return TACC; } 102 dcir|DCIR { number = 2; return TACC; } 103 dtil|DTIL { number = 3; return TACC; } 104 dmac|DMAC { number = 4; return TACC; } 105 dbre|DBRE { number = 5; return TACC; } 106 ddot|DDOT { number = 6; return TACC; } 107 duml|DUML { number = 7; return TACC; } 108 ddia|DDIA { number = 7; return TACC; } 109 dsla|DSLA { number = 8; return TACC; } 110 drin|DRIN { number = 9; return TACC; } 111 dced|DCED { number = 10; return TACC; } 112 dapo|DAPO { number = 11; return TACC; } 113 ddac|DDAC { number = 12; return TACC; } 114 dogo|DOGO { number = 13; return TACC; } 115 dcar|DCAR { number = 14; return TACC; } 116 117 fkey{D}({D}*) { 118 sscanf(yytext+4, "%d", &number); 119 return TFUNC; 120 } 121 scr{D}({D}*) { 122 sscanf(yytext+3, "%d", &number); 123 return TSCRN; 124 } 125 '{A}' { letter = *(yytext+1); return TLET; } 126 #({A}*) { /* ignore */ } 127 0x{X}({X}*) { sscanf(yytext, "%x", &number); return TNUM; } 128 {D}({D}*) { sscanf(yytext, "%d", &number); return TNUM; } 129 {L} { 130 if (*yytext == 'O') number = 0; 131 if (*yytext == 'C') number = 1; 132 if (*yytext == 'N') number = 2; 133 if (*yytext == 'B') number = 3; 134 return TFLAG; 135 } 136 [ \t\n] { /* ignore */ } 137 . { return *yytext; } 138