yacc-misc.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #! /bin/sh
  2. # Copyright (C) 2001-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Some simple tests of ylwrap functionality.
  17. required='cc yacc'
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_CC
  21. AC_PROG_YACC
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. bin_PROGRAMS = foo bar
  26. foo_SOURCES = parse.y foo.c
  27. bar_SOURCES = bar.y foo.c
  28. END
  29. # First parser.
  30. cat > parse.y << 'END'
  31. %{
  32. int yylex () { return 0; }
  33. void yyerror (char *s) {}
  34. %}
  35. %%
  36. foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  37. END
  38. # Second parser.
  39. cat > bar.y << 'END'
  40. %{
  41. int yylex () { return 0; }
  42. void yyerror (char *s) {}
  43. %}
  44. %%
  45. fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  46. END
  47. cat > foo.c << 'END'
  48. int main (void)
  49. {
  50. return 0;
  51. }
  52. END
  53. $ACLOCAL
  54. $AUTOCONF
  55. $AUTOMAKE -a
  56. test -f ylwrap
  57. mkdir sub
  58. cd sub
  59. ../configure
  60. $MAKE
  61. grep '^#.*/sub/\.\./' bar.c && exit 1
  62. grep '^#.*/sub/\.\./' parse.c && exit 1
  63. # Make distclean must not erase bar.c nor parse.c (by GNU standards) ...
  64. $MAKE distclean
  65. test -f bar.c
  66. test -f parse.c
  67. # ... but maintainer-clean should.
  68. ../configure
  69. $MAKE maintainer-clean
  70. test ! -e bar.c
  71. test ! -e parse.c
  72. :