yacc-bison-skeleton-cxx.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # Test to make sure bison + bison's C++ skeleton + C++ works.
  17. # For Automake bug#7648 and PR automake/491.
  18. required='c++ bison'
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CXX
  22. AC_PROG_YACC
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am << 'END'
  26. bin_PROGRAMS = zardoz
  27. zardoz_SOURCES = zardoz.yy foo.cc
  28. # This is required even with %defines in zardoz.yy.
  29. AM_YFLAGS = -d
  30. BUILT_SOURCES = zardoz.hh
  31. EXTRA_DIST = stack.hh location.hh position.hh
  32. END
  33. cat > zardoz.yy << 'END'
  34. %skeleton "lalr1.cc"
  35. %defines
  36. %locations
  37. %union
  38. {
  39. int ival;
  40. };
  41. %{
  42. int yylex (yy::parser::semantic_type *yylval,
  43. yy::parser::location_type *yylloc);
  44. %}
  45. %%
  46. start : /* empty */
  47. %%
  48. int
  49. yylex (yy::parser::semantic_type *yylval,
  50. yy::parser::location_type *yylloc)
  51. {
  52. return 0;
  53. }
  54. void
  55. yy::parser::error(const yy::parser::location_type&, const std::string&)
  56. {
  57. return;
  58. }
  59. END
  60. cat > foo.cc << 'END'
  61. #include "zardoz.hh"
  62. int
  63. main(int argc, char** argv)
  64. {
  65. yy::parser my_parser;
  66. return my_parser.parse ();
  67. }
  68. END
  69. $ACLOCAL
  70. $AUTOCONF
  71. $AUTOMAKE -a
  72. # Try a VPATH build first.
  73. mkdir build
  74. cd build
  75. ../configure YACC='bison -y'
  76. $MAKE
  77. cd ..
  78. # Now try an in-tree build.
  79. ./configure YACC='bison -y'
  80. $MAKE
  81. # Check that distribution is self-contained, and do not require
  82. # bison to be built.
  83. yl_distcheck YACC=false DISTCHECK_CONFIGURE_FLAGS='YACC=false'
  84. :