• Source
    1. %{
    2. #include stdio.h
    3. #include string.h
    4. %}
    5.  
    6. %option noyywrap
    7.  
    8. %%
    9. [a-zA-Z_][a-zA-Z0-9_] { printf(%s = Length %dn, yytext, yyleng); }
    10. [0-9]+ { printf(%s = Length %dn, yytext, yyleng); }
    11. .n ;
    12. %%
    13.  
    14. int main() {
    15. char input = abc 123 _name var42 9999;
    16. YY_BUFFER_STATE buf = yy_scan_string(input);
    17. yylex();
    18. yy_delete_buffer(buf);
    19. return 0;
    20. }
    21.