1// re2c $INPUT -o $OUTPUT 2#define NULL ((char*) 0) 3#define YYCTYPE char 4#define YYCURSOR p 5#define YYLIMIT p 6#define YYMARKER q 7#define YYFILL(n) 8 9#include <stdio.h> 10 11char *scan281(char *p) 12{ 13 char *q; 14start: 15/*!re2c 16 17 ( "adsl" | "adslppp" | "bdsl" | "cdsl" | "dslgw4pool" | "dslppp" | "edsl" | "fdsl" | "ldsl" | "pool" | "pppdsl" | "premiumC" | "vdsl" | "xsttldsl") [0-9a-k\-]+ ".".+ ".uswest.net" 18 { 19 return "dsl"; 20 } 21 22 ( "dhcp" | "dorms" | "rh" ).* "-" [0-9]+ "-" [0-9]+ "." .+ ".resnet.pitt.edu" 23 { 24 return "resnet"; 25 } 26 27 [0-9]+ "-" [0-9]+ "-" [0-9]+ "-" [0-9]+ "." ("dhcp" | .* "modem" | "bothell") .* ".washington.edu" 28 { 29 return "edu"; 30 } 31 32 [\001-\377] 33 { 34 goto start; 35 } 36 37 [\000] 38 { 39 return NULL; 40 } 41*/ 42} 43 44int main(int argc, char **argv) 45{ 46 int n = 0; 47 char *largv[2]; 48 49 if (argc < 2) 50 { 51 argc = 2; 52 argv = largv; 53 argv[1] = "D-128-208-46-51.dhcp4.washington.edu"; 54 } 55 while(++n < argc) 56 { 57 char *res = scan281(argv[n]); 58 printf("%s\n", res ? res : "<NULL>"); 59 } 60 return 0; 61} 62