%{
#include <stdio.h>
#include <stdlib.h>
%}

/* 
   This pattern matches a basic email address:
   - One or more letters, digits, dots, underscores, percent signs, plus or minus signs,
   - Followed by an '@',
   - Then one or more letters, digits, dots or hyphens,
   - Followed by a dot and at least two letters.
   Note: Email syntax can be complex; this regex covers many common cases.
*/
%%
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$  {
    printf("Valid email address: %s\n", yytext);
    exit(0);
}

^.*$  {
    printf("Invalid email address: %s\n", yytext);
    exit(1);
}
%%

int main(void)
{
    yylex();
    return 0;
}
