fork download
  1. %{
  2. #include <stdio.h>
  3. #include <string.h>
  4. int addr = 1000;
  5. char dtype[10];
  6. %}
  7.  
  8. %%
  9. (int|float|char) { strcpy(dtype, yytext); }
  10. [a-zA-Z_][a-zA-Z0-9_]* { printf("%s\t%s\t%d\n", yytext, dtype, addr); addr += 4; }
  11. [=,;0-9 \t\n]+ ;
  12. %%
  13. int main() {
  14. printf("Enter declaration: ");
  15. yylex();
  16. return 0;
  17. }
  18. int yywrap(){ return 1; }
  19.  
  20.  
Success #stdin #stdout #stderr 0.03s 6816KB
stdin
int a=5, b; float c;
stdout
Standard output is empty
stderr
ERROR: /home/z5xq96/prog:19:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Can't ignore goal at this port
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit