fork download
  1. %{
  2. #include "y.tab.h"
  3. %}
  4.  
  5. %%
  6. "int" { return INT; }
  7. "while" { return WHILE; }
  8. "for" { return FOR; }
  9. "print" { return PRINT; }
  10. "def" { return DEF; }
  11. "return" { return RETURN; }
  12. [a-zA-Z_][a-zA-Z0-9_]* { yylval.str = strdup(yytext); return IDENTIFIER; }
  13. [0-9]+ { yylval.num = atoi(yytext); return NUMBER; }
  14. "{" { return LBRACE; }
  15. "}" { return RBRACE; }
  16. "(" { return LPAREN; }
  17. ")" { return RPAREN; }
  18. ";" { return SEMICOLON; }
  19. "+" | "-" | "*" | "/" { return OPERATOR; }
  20. [ \t\n]+ { /* Ignore whitespace */ }
  21. . { return yytext[0]; }
  22. %%
  23.  
Success #stdin #stdout #stderr 0.02s 7012KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/oszuc5/prog:2:1: Syntax error: Operator expected
ERROR: /home/oszuc5/prog:22:2: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit