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