fork download
  1. %{
  2. #include "y.tab.h"
  3. %}
  4.  
  5. digit [0-9]
  6. id [a-zA-Z_][a-zA-Z0-9_]*
  7.  
  8. %%
  9.  
  10. "if" { return IF; }
  11. "else" { return ELSE; }
  12. "while" { return WHILE; }
  13. "read" { return READ; }
  14. "print" { return PRINT; }
  15. {id} { yylval.strval = strdup(yytext); return IDENTIFIER; }
  16. {digit}+ { yylval.numval = atoi(yytext); return NUMBER; }
  17. "/" { return DIVIDE; }
  18. "=" { return ASSIGN; }
  19. "==" { return EQUAL; }
  20. "!=" { return NOTEQUAL; }
  21. "<" { return LESS; }
  22. ">" { return GREATER; }
  23. "<=" { return LESSEQ; }
  24. ">=" { return GREATEREQ; }
  25. "{" { return LBRACE; }
  26. "}" { return RBRACE; }
  27. "(" { return LPAREN; }
  28. ")" { return RPAREN; }
  29. ";" { return SEMICOLON; }
  30. [ \t\n]+ ; // Skip whitespace
  31. . { return yytext[0]; }
  32.  
  33. %%
  34.  
  35. int yywrap() {
  36. return 1;
  37. }
  38.  
Success #stdin #stdout #stderr 0.04s 6944KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/VDkmU3/prog:2:1: Syntax error: Operator expected
ERROR: /home/VDkmU3/prog:37:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit