#ifndef _CONFIG_H
#define _CONFIG_H
-/* Compilers. */
+/* Programs. */
#undef GDC
#undef GOBJC
#undef CXX
#undef CC
#undef JAVAC
#undef TXL
+#undef RUBY
#endif /* _CONFIG_H */
PACKAGE_BUGREPORT=
ac_unique_file="ragel/main.cpp"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_PARSERS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX SET_MAKE RAGEL GPERF KELBT GDC GOBJC JAVAC TXL LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_PARSERS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX SET_MAKE RAGEL GPERF KELBT GDC GOBJC JAVAC TXL RUBY LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
fi
+# Extract the first word of "ruby", so it can be a program name with args.
+set dummy ruby; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_RUBY+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$RUBY"; then
+ ac_cv_prog_RUBY="$RUBY" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RUBY="ruby"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+RUBY=$ac_cv_prog_RUBY
+if test -n "$RUBY"; then
+ echo "$as_me:$LINENO: result: $RUBY" >&5
+echo "${ECHO_T}$RUBY" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test -n "$RUBY"; then
+ cat >>confdefs.h <<_ACEOF
+#define RUBY $RUBY
+_ACEOF
+
+fi
+
ac_config_files="$ac_config_files Makefile common/Makefile ragel/Makefile redfsm/Makefile rlcodegen/Makefile rlgen-java/Makefile rlgen-ruby/Makefile doc/Makefile test/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
s,@GOBJC@,$GOBJC,;t t
s,@JAVAC@,$JAVAC,;t t
s,@TXL@,$TXL,;t t
+s,@RUBY@,$RUBY,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
AC_DEFINE_UNQUOTED(TXL,$TXL)
fi
+dnl Check for Ruby.
+AC_CHECK_PROG(RUBY, ruby, ruby)
+if test -n "$RUBY"; then
+ AC_DEFINE_UNQUOTED(RUBY,$RUBY)
+fi
+
dnl write output files
AC_OUTPUT(Makefile common/Makefile ragel/Makefile redfsm/Makefile rlcodegen/Makefile rlgen-java/Makefile rlgen-ruby/Makefile doc/Makefile test/Makefile)
--- /dev/null
+#
+# @LANG: ruby
+# @ALLOW_GENFLAGS: -T0
+#
+
+neg = false
+val = 0
+
+%%{
+ machine atoi1_java;
+ alphtype byte;
+ action begin {
+ neg = false;
+ val = 0;
+ }
+ action see_neg {
+ neg = true;
+ }
+ action add_digit {
+ val = val * 10 + (fc - "0"[0]);
+ }
+ action finish {
+ val = -1 * val if neg
+ }
+ action print {
+ puts val;
+ }
+ atoi = (('-' @ see_neg | '+') ? (digit @ add_digit) +) > begin % finish;
+ main := atoi '\n' @ print;
+}%%
+
+%% write data;
+
+def run_machine( data )
+ p = 0;
+ pe = data.length
+ cs = 0
+ cs = 0
+ val = 0;
+ neg = false;
+
+ %% write init;
+ %% write exec;
+ %% write eof;
+ if cs >= atoi1_java_first_final
+ puts "ACCEPT"
+ else
+ puts "FAIL"
+ end
+end
+
+inp = [
+ "1\n",
+ "12\n",
+ "222222\n",
+ "+2123\n",
+ "213 3213\n",
+ "-12321\n",
+ "--123\n",
+ "-99\n",
+ " -3000\n",
+]
+
+inp.each { |str| run_machine(str) }
+
+=begin _____OUTPUT_____
+1
+ACCEPT
+12
+ACCEPT
+222222
+ACCEPT
+2123
+ACCEPT
+FAIL
+-12321
+ACCEPT
+FAIL
+-99
+ACCEPT
+FAIL
+=end _____OUTPUT_____
g)
allow_generated="true"
;;
- C|D|J)
+ C|D|J|R)
langflags="$langflags -$opt"
;;
esac
[ -z "$minflags" ] && minflags="-n -m -l -e"
[ -z "$genflags" ] && genflags="-T0 -T1 -F0 -F1 -G0 -G1 -G2"
-[ -z "$langflags" ] && langflags="-C -D -J"
+[ -z "$langflags" ] && langflags="-C -D -J -R"
shift $((OPTIND - 1));
d_compiler=`sed '/^#define GDC/s/#define GDC *//p;d' $config`
java_compiler=`sed '/#define JAVAC/s/#define JAVAC *//p;d' $config`
txl_engine=`sed '/^#define TXL/s/#define TXL *//p;d' $config`
+ruby_engine=`sed '/^#define RUBY/s/#define RUBY *//p;d' $config`
function test_error
{
lang_opt=-J;
cflags=""
;;
+ ruby)
+ codegen=../rlgen-ruby/rlgen-ruby;
+ code_suffix=rb;
+ compiler=$ruby_engine
+ lang_opt=-R;
+ cflags=""
+ ;;
indep)
# If we have no compiler for the source program then skip it.
[ -z "$txl_engine" ] && continue
allow_genflags=`sed '/@ALLOW_GENFLAGS:/s/^.*: *//p;d' $test_case`
[ -z "$allow_genflags" ] && allow_genflags="-T0 -T1 -F0 -F1 -G0 -G1 -G2"
+
for min_opt in $minflags; do
for gen_opt in $genflags; do
echo "$allow_minflags" | grep -e $min_opt >/dev/null || continue
out_args=""
[ $lang != java ] && out_args="-o ${binary}";
- echo "$compiler ${cflags} ${out_args} ${code_src}"
- if ! $compiler ${cflags} ${out_args} ${code_src}; then
- test_error;
+ # Ruby doesn't need to be compiled.
+ if [ $lang != ruby ]; then
+ echo "$compiler ${cflags} ${out_args} ${code_src}"
+ if ! $compiler ${cflags} ${out_args} ${code_src}; then
+ test_error;
+ fi
fi
if [ "$compile_only" != "true" ]; then
exec_cmd=./$binary
[ $lang = java ] && exec_cmd="java $root"
-
+ [ $lang = ruby ] && exec_cmd="ruby ${code_src}"
+
$exec_cmd 2>&1 > $output;
if diff $expected_out $output > /dev/null; then
echo "passed";