02 Lex Rules
Match Real Numbers¶
digit [0-9]
sign [+|-]
%%
{sign}?{digit}+(\.{digit}+)? printf("Matched real no: %s of length: %d", yytext, yyleng);
%%
Conflict Resolution¶
Different Rules¶
Similar Rules¶
Warning: Rule not matched
letter [a-z A-Z]
digit [0-9]
%%
{letter}({letter}|{digit})* printf("Matched id");
{letter}+ printf("Matched word");
%%
Match word immediately followed by number¶
letter [a-z A-Z]
word {letter}+
digit [0-9]
%%
{word}/{digit} printf("Found word %s followed by number ", yytext);
%%