Reputation: 716
input to lexer
abc gef4 44jdjd ghghg
x
ererete
xyzzz
55k
hello wold
33
my rules
rule1 [0-9]+[a-zA-Z]+
rule2 [x-z]
rule3 .*
{rule1} { printf("%s \n", yytext); }
{rule2} { printf("%s \n", yytext); }
{rule3} { // prints nothing }
output :-
x
55k
I cannot understand the output ? Can someone please help me.
Upvotes: 1
Views: 108
Reputation: 8361
The first character of the input neither matches rule1 nor rule2. Instead rule3 eats input up to the end of line. The same happens on line 3, 4, 6, and 7. You probably want a less greedy rule3, i.e. one that doesn't consume the spaces:
[^ \t\n]* /* Do nothing */
Then 44jdjd is being found by rule1.
Upvotes: 3