fork download
  1. %{
  2. // Declarations section: You can declare variables, include header files, etc.
  3. #include <stdio.h>
  4. %}
  5.  
  6. %%
  7. // Rules section: Specify your patterns and corresponding actions.
  8.  
  9. [0-9]+ { printf("Number: %s\n", yytext); }
  10. [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
  11. \n { /* ignore newlines */ }
  12. [ \t]+ { /* ignore whitespace */ }
  13. . { printf("Unknown character: %s\n", yytext); }
  14.  
  15. %%
  16. // Code section: The main function and other C code go here.
  17.  
  18. int main(void) {
  19. yylex(); // Calls the lexical analyzer
  20. return 0;
  21. }
  22.  
  23. int yywrap() {
  24. return 1;
  25. }
  26.  
Success #stdin #stdout #stderr 0.02s 6932KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ciIWK8/prog:2:4: Syntax error: Operator expected
ERROR: /home/ciIWK8/prog:3:1: Syntax error: Operator expected
ERROR: /home/ciIWK8/prog:9:54: Syntax error: Unbalanced operator
ERROR: /home/ciIWK8/prog:13:65: Syntax error: Unexpected `;' before `}'
ERROR: /home/ciIWK8/prog:25:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit