/** * Stephanie Taylor * Spring 2026 * CS333 * * Read one line at a time from the command line and identify patterns * This intends to demo how precedence works, in terms of which pattern * is matched. * * flex -o demo_precedence.yy.c demo_precedence.yy * gcc -o demo_precedence demo_precedence.yy.c -ll How rules are chosen: - If rule A matches more letters than another rule B, rule A will be used - If rule A and rule B match the same string, then the rule that comes first in the list of rules will be used. Tested with abc (matches Rule 1) abcd (matches Rule 2) abbbbc (matches Rule 1) abbbbbbcd (abbbbbbc matched by Rule 1, d not matched) */ %% ab*c printf( "Matched Rule 1: %s\n", yytext ); abcd printf( "Matched Rule 2: %s\n", yytext ); %% int main( int argc, char *argv[] ) { yylex(); // a function of flex that read input till it is exhausted return 0; }