fork download
  1. %{
  2. #include<stdio.h>
  3. %}
  4.  
  5. %%
  6.  
  7. [ \t]+ ; // Ignore spaces and tabs
  8.  
  9. #.* {
  10. printf("\nMatched Comment: %s\n", yytext); // Print when a comment is matched
  11. }
  12.  
  13. \n {
  14. printf("\nMatched Newline\n"); // Print when a newline is matched
  15. ECHO; // Print the newline as is
  16. }
  17.  
  18. %%
  19.  
  20. int main() {
  21. printf("Starting Lexical Analysis...\n");
  22. yylex(); // Start lexical analysis
  23. printf("Lexical Analysis Completed.\n");
  24. }
  25.  
  26. int yywrap() {
  27. return 1;
  28. }
  29.  
Success #stdin #stdout #stderr 0.03s 6888KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/l9SWdV/prog:28:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit