ax_prog_bison_clfeatures.m4 3 KB
Newer Older
Philip Carns's avatar
Philip Carns committed
1 2 3 4 5 6 7 8 9 10 11 12 13
AC_DEFUN([AX_PROG_BISON_CLFEATURES], [
	AC_REQUIRE([AC_PROG_YACC])
	AC_REQUIRE([AC_PROG_SED])

	AC_CACHE_CHECK([if bison is the parser generator],[ax_cv_prog_bison],[
  		AS_IF([test "`echo \"$YACC\" | $SED 's,^.*\(bison\).*$,\1,'`" = "bison" ],[
			ax_cv_prog_bison=yes
    			],[
      				ax_cv_prog_bison=no
    		])
  	])

cat > conftest.y <<ACEOF
14 15 16 17
%{
    int yylex(void*);
    void yyerror(const char *s);
%}
Philip Carns's avatar
Philip Carns committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
%pure-parser
%token  FIRST_TOK
%token  LAST_TOK
%start top
%%
top: FIRST_TOK LAST_TOK
%%
ACEOF

# set up some common variables for testing:
ac_cv_prog_yacc_root="y.tab"
ac_compile_yacc='$CC -c $CFLAGS $CPPFLAGS $ac_cv_prog_yacc_root.c >&5'

HAVE_YACC_OLD_PURE=
HAVE_YACC_OLD_PUSH=
AC_MSG_CHECKING([if ${YACC} supports pure / reentrant paser features])
if $YACC -d -t -v conftest.y > /dev/null 2>&1 && eval "$ac_compile_yacc"
then
	AC_SUBST([CODES_PURE_PARSER_DEFINES], ["%pure-parser"])
	AC_MSG_RESULT([old-style])
	$3
else

cat > conftest.y <<ACEOF
42 43 44 45
%{
    int yylex(void*);
    void yyerror(const char *s);
%}
Philip Carns's avatar
Philip Carns committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
%define api.pure
%token  FIRST_TOK
%token  LAST_TOK
%start top
%%
top: FIRST_TOK LAST_TOK
%%
ACEOF

# set up some common variables for testing:
ac_cv_prog_yacc_root="y.tab"
ac_compile_yacc='$CC -c $CFLAGS $CPPFLAGS $ac_cv_prog_yacc_root.c >&5'
	if $YACC -d -t -v conftest.y > /dev/null 2>&1 && eval "$ac_compile_yacc"
	then
		AC_SUBST([CODES_PURE_PARSER_DEFINES], ["%define api.pure"])
		AC_MSG_RESULT([new-style])
		$3
	else
		AC_MSG_RESULT([feature not supported])
		BVER=`${YACC} --version | head -n 1`
		AC_MSG_WARN([${BVER} does not support pure / reentrant parser generation])
		$4
	fi
fi

cat > conftest.y <<ACEOF
72 73 74 75
%{
    int yylex(void*);
    void yyerror(const char *s);
%}
Philip Carns's avatar
Philip Carns committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
%define api.push_pull "push"
%token  FIRST_TOK
%token  LAST_TOK
%start top
%%
top: FIRST_TOK LAST_TOK
%%
ACEOF

# set up some common variables for testing:
ac_cv_prog_yacc_root="y.tab"
ac_compile_yacc='$CC -c $CFLAGS $CPPFLAGS $ac_cv_prog_yacc_root.c >&5'

AC_MSG_CHECKING([if ${YACC} supports push parser features])
if $YACC -d -t -v conftest.y > /dev/null 2>&1 && eval "$ac_compile_yacc"
then
	AC_SUBST([CODES_PUSH_PARSER_DEFINES], ["%define api.push_pull \"push\""])
	AC_MSG_RESULT([old-style])
	$3
else
 
cat > conftest.y <<ACEOF
98 99 100 101
%{
    int yylex(void*);
    void yyerror(const char *s);
%}
Philip Carns's avatar
Philip Carns committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
%define api.push-pull push
%token  FIRST_TOK
%token  LAST_TOK
%start top
%%
top: FIRST_TOK LAST_TOK
%%
ACEOF

# set up some common variables for testing:
ac_cv_prog_yacc_root="y.tab"
ac_compile_yacc='$CC -c $CFLAGS $CPPFLAGS $ac_cv_prog_yacc_root.c >&5'
	if $YACC -d -t -v conftest.y > /dev/null 2>&1 && eval "$ac_compile_yacc"
	then
		AC_SUBST([CODES_PUSH_PARSER_DEFINES], ["%define api.push-pull push"])
		AC_MSG_RESULT([new-style])
		$3
	else
		AC_MSG_RESULT([feature not supported])
		BVER=`${YACC} --version | head -n 1`
		AC_MSG_WARN([${BVER} does not support push parser generation])
		$4
	fi
fi

  AS_IF([test "$ax_cv_prog_bison" = yes],[
    :
    $1
  ],[
    :
    $2
  ])

  # cleanup bison / yacc tmp files
  rm -rf y.output y.tab.h y.tab.c y.tab.o
])