fork download
  1. %{
  2. #include <stdio.h>
  3. int yywrap(); // function declaration
  4. %}
  5.  
  6. %%
  7. (bool|int|float) { printf("Keyword\n"); }
  8. [0-9]+(\.[0-9]+)? { printf("Constant\n"); }
  9. [.,;'""]+ { printf("Punctuation Char\n"); }
  10. [!@#$%^&*()]+ { printf("Special Char\n"); }
  11. [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier\n"); }
  12. [ \t\n]+ { /* ignore spaces, tabs, and newlines */ }
  13. . { /* ignore any other characters */ }
  14. %%
  15.  
  16. int yywrap() {
  17. return 1;
  18. }
  19.  
  20. int main() {
  21. printf("Enter your code (Ctrl+D to stop):\n");
  22. yylex(); // start lexical analysis
  23. return 0;
  24. }
  25.  
Success #stdin #stdout #stderr 0.03s 6916KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/z4GMyO/prog:2:1: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit