dnl CF_LEX_STATES version: 7 updated: 2020/01/05 20:03:16
dnl -------------
dnl Check if the lex/flex program accepts states, i.e., %s and %x.  Older
dnl implementations do not support these.
dnl
dnl $1 = optional parameter for number of states needed
AC_DEFUN([CF_LEX_STATES],[
AC_MSG_CHECKING(if $LEX supports states)

cf_lex_statemax=ifelse($1,,32,$1)
cf_lex_statenum=0
cf_lex_states_s=
cf_lex_states_x=

cf_lex_states=no
while test $cf_lex_statenum -lt $cf_lex_statemax
do
cf_lex_statenum=`expr $cf_lex_statenum + 1`
cf_lex_states_s="$cf_lex_states_s S$cf_lex_statenum"
cf_lex_states_x="$cf_lex_states_x X$cf_lex_statenum"
cat >conftest.l <<CF_EOF
%s $cf_lex_states_s
%x $cf_lex_states_x
%%
%%
nothing	ECHO;
CF_EOF
	cf_lex_states="$LEX conftest.l 1>&AC_FD_CC"
	if AC_TRY_EVAL(cf_lex_states); then
		if test $cf_lex_statenum = $cf_lex_statemax; then
			cf_lex_states=yes
			break
		else
			cf_lex_states=$cf_lex_statenum
		fi
	else
		break
	fi
done
AC_MSG_RESULT($cf_lex_states)
rm -rf conftest.* $LEX_OUTPUT_ROOT.c
if test "$cf_lex_states" = no ; then
	AC_MSG_WARN(Your $LEX program does not support POSIX states.  Get flex.)
fi
])dnl
