fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include <errno.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <sys/mman.h>
  11. #include <sys/wait.h>
  12. %}
  13.  
  14. %%
  15. [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
  16. [0-9]+ { printf("Number: %s\n", yytext); }
  17. [=+\-*/] { printf("Operator: %s\n", yytext); }
  18. . { printf("Symbol: %s\n", yytext); }
  19. %%
  20.  
  21. int main() {
  22. char *test_input = "x = 10 + y;"; // Hardcoded Input
  23. printf("Processing: %s\n", test_input);
  24. yy_scan_string(test_input); // Pass input to Lex
  25. yylex();
  26. return 0;
  27. }
  28.  
  29.  
Success #stdin #stdout #stderr 0.02s 6964KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/E3bbjR/prog:2:1: Syntax error: Operator expected
ERROR: /home/E3bbjR/prog:28:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit