yytext and yyleng
In lex if you want to find out of what text the scanner matches for a given patten the variable yytext returns the string matched and yylength conatins the length of the match.
[0-9]+ { printf("Gotta a number:%s of %d digits\n",yytext,yyleng); }
$./compileandrun.sh
123213
Gotta a number:123213 of 6 digits

0 Comments:
Post a Comment
<< Home