prog.c 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include"parser.tab.h"
  2. #include<unistd.h>
  3. #include<sys/types.h>
  4. #include<sys/stat.h>
  5. #include<fcntl.h>
  6. #include<stdio.h>
  7. #include<stdlib.h>
  8. extern int yyparse();
  9. int main(int argc, char **argv) {
  10. /*
  11. int input;
  12. if(argc != 2) {
  13. printf("%s <input file>");
  14. return 1;
  15. }
  16. input = open(argv[1], O_RDONLY);
  17. dup2(input, STDIN_FILENO);
  18. close(input);
  19. return yyparse();
  20. */
  21. /* We really should test that the
  22. * generated parser works with input
  23. * but it froze and I don't want to waste
  24. * time debugging that. For this test what
  25. * we care about is that it compiles and links.
  26. */
  27. void* __attribute__((unused)) dummy = (void*)yyparse;
  28. return 0;
  29. }
  30. int yywrap(void) {
  31. return 0;
  32. }
  33. int yyerror(void) {
  34. printf("Parse error\n");
  35. exit(1);
  36. }