From 47104c1df8261ed41f61f34f29591bccacaac147 Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 5 Jan 2008 21:05:44 +0000 Subject: [PATCH] Fixes for ruby 1.9. git-svn-id: http://svn.complang.org/ragel/trunk@379 052ea7fc-9027-0410-9066-f65837a77df0 --- rlgen-ruby/ruby-tabcodegen.cpp | 10 +++++----- test/atoi1.rl | 2 +- test/atoi2.rl | 2 +- test/cond1.rl | 6 +++--- test/langtrans_ruby.sh | 2 +- test/langtrans_ruby.txl | 3 ++- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rlgen-ruby/ruby-tabcodegen.cpp b/rlgen-ruby/ruby-tabcodegen.cpp index b979682..42fd479 100644 --- a/rlgen-ruby/ruby-tabcodegen.cpp +++ b/rlgen-ruby/ruby-tabcodegen.cpp @@ -158,7 +158,7 @@ void RubyTabCodeGen::COND_TRANSLATE() for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { CondSpace *condSpace = csi; - out << " when " << condSpace->condSpaceId << ":" ; + out << " when " << condSpace->condSpaceId << " then" ; out << " _widec = " << KEY(condSpace->baseKey) << "+ (" << GET_KEY() << " - " << KEY(keyOps->minKey) << ")\n"; @@ -447,7 +447,7 @@ std::ostream &RubyTabCodeGen::FROM_STATE_ACTION_SWITCH() /* Write out referenced actions. */ if ( act->numFromStateRefs > 0 ) { /* Write the case label, the action */ - out << " when " << act->actionId << ":\n"; + out << " when " << act->actionId << " then\n"; ACTION( out, act, 0, false ); } } @@ -464,7 +464,7 @@ std::ostream &RubyTabCodeGen::TO_STATE_ACTION_SWITCH() /* Write out referenced actions. */ if ( act->numToStateRefs > 0 ) { /* Write the case label, the action and the case break. */ - out << "when " << act->actionId << "\n"; + out << "when " << act->actionId << " then\n"; ACTION( out, act, 0, false ); } } @@ -480,7 +480,7 @@ std::ostream &RubyTabCodeGen::EOF_ACTION_SWITCH() /* Write out referenced actions. */ if ( act->numEofRefs > 0 ) { /* Write the case label, the action and the case break. */ - out << "when " << act->actionId << ":\n"; + out << "when " << act->actionId << " then\n"; ACTION( out, act, 0, true ); } } @@ -496,7 +496,7 @@ std::ostream &RubyTabCodeGen::ACTION_SWITCH() /* Write out referenced actions. */ if ( act->numTransRefs > 0 ) { /* Write the case label, the action and the case break. */ - out << "when " << act->actionId << ":\n"; + out << "when " << act->actionId << " then\n"; ACTION( out, act, 0, false ); } } diff --git a/test/atoi1.rl b/test/atoi1.rl index 60fc959..ea706c8 100644 --- a/test/atoi1.rl +++ b/test/atoi1.rl @@ -19,7 +19,7 @@ neg = false; } action add_digit { - val = val * 10 + (fc - '0'); + val = val * 10 + (fc - 48); } action finish { diff --git a/test/atoi2.rl b/test/atoi2.rl index e16380a..923e88f 100644 --- a/test/atoi2.rl +++ b/test/atoi2.rl @@ -20,7 +20,7 @@ neg = false; } action add_digit { - val = val * 10 + (fc - '0'); + val = val * 10 + (fc - 48); } action finish { diff --git a/test/cond1.rl b/test/cond1.rl index 620ea5e..8d6796a 100644 --- a/test/cond1.rl +++ b/test/cond1.rl @@ -16,9 +16,9 @@ bool k; action two { prints " two\n";} action three { prints " three\n";} - action seti { if ( fc == '0' ) i = false; else i = true; } - action setj { if ( fc == '0' ) j = false; else j = true; } - action setk { if ( fc == '0' ) k = false; else k = true; } + action seti { if ( fc == 48 ) i = false; else i = true; } + action setj { if ( fc == 48 ) j = false; else j = true; } + action setk { if ( fc == 48 ) k = false; else k = true; } action break {fbreak;} diff --git a/test/langtrans_ruby.sh b/test/langtrans_ruby.sh index 3caa660..ab3282b 100755 --- a/test/langtrans_ruby.sh +++ b/test/langtrans_ruby.sh @@ -74,7 +74,7 @@ END { cat << EOF inp.each { |str| - run_machine(str) + run_machine(str.unpack("c*")) } EOF diff --git a/test/langtrans_ruby.txl b/test/langtrans_ruby.txl index 5c1ce1a..6acfb5a 100644 --- a/test/langtrans_ruby.txl +++ b/test/langtrans_ruby.txl @@ -258,7 +258,8 @@ function alStmtToRuby4d AlStmt [action_lang_stmt] 'print_token '; replace [repeat ruby_lang_stmt] by - 'print '( 'data '[tokstart..tokend-1] ') '; + '_m = 'data '[tokstart..tokend-1] '; + 'print '( '_m '. 'pack '( '"c*" ') ') '; end function function alStmtToRuby5 AlStmt [action_lang_stmt] -- 2.7.4