madvice

identifier.l

Nov 19th, 2025
80
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | Source Code | 0 0
  1. letter          [A-Za-z]
  2. digit           [0-9]
  3.  
  4. %{
  5.     #include <stdio.h>
  6. %}
  7.  
  8. %%
  9.  
  10.     /*An identifier starts with a letter followed by 0 or more letters or digits*/
  11.  
  12. {letter}({letter}|{digit})*         { printf("identifier scanned: %s\n", yytext); }
  13. .                                   {  }
  14. \n                                  {  }
  15.  
  16. %%
  17.  
  18. int yywrap() {
  19.     return 1;
  20. }
  21.  
  22.  
  23. int main()
  24. {
  25.     yylex();
  26. }
  27.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment