/* File........ spamfinder2.lex * Contents.... SEG2106 - LAB-3 part 2 E-mail Search parser Craig Campbell - 50111 Paul M. Baillot 2273596 */ /* compilation: * flex parser3.lex * gcc -o parser3.exe lexyy.c */ /* ---------------- Definitions space ----------------- */ %option noyywrap %{ #include #include #include #include int address = 0; %} SUBJECT [0-9a-zA-Z]+([\.]{0,1}[0-9a-zA-Z]+)* AT [@] NAMEADDRESS [a-zA-Z]+[0-9a-zA-Z]*([\.]{0,1}([a-zA-Z]+[0-9a-zA-Z]*))* IPADDRESS [0-9]{1,3}([\.]{1}[0-9]{1,3}){3} EMAIL {SUBJECT}{AT}{1,1}({NAMEADDRESS}|{IPADDRESS}) DIGIT [0-9]+ STUDENT_ID [u|s]{DIGIT}{6,7} /* ------------------- Rules space -------------------- */ %% {EMAIL} { ++address; printf( " the match was a valid e-mail address %s \n",yytext); } \n { } . { } %% /* ----------------- User code space ------------------ */ main() { printf("Hit ^Z followed by enter to finish\n"); yylex(); printf("--- The total number of valid Addresses is = : %d\n", address); }