diff --git a/.travis.yml b/.travis.yml index 442c46d1..7572f0a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,23 @@ --- -after_script: -- rake travis:after -t -before_script: -- gem install hoe-travis --no-rdoc --no-ri -- rake travis:before -t +sudo: false +cache: + - bundler + - directories: + - /home/travis/.rvm/ language: ruby notifications: email: rvm: -- 1.8.7 -- 1.9.3 -- 2.0.0 -- ruby-head -script: rake travis + - 2.2.8 + - 2.3.5 + - 2.4.2 + - jruby-9.2.5.0 + - ruby-head matrix: allow_failures: - rvm: ruby-head + - rvm: jruby-9.2.5.0 +before_install: gem update --remote bundler +install: + - bundle install --retry 3 +script: ./test/run_tests.sh diff --git a/ext/racc/com/headius/racc/Cparse.java b/ext/racc/com/headius/racc/Cparse.java index 4f2a0931..e3798dfc 100644 --- a/ext/racc/com/headius/racc/Cparse.java +++ b/ext/racc/com/headius/racc/Cparse.java @@ -21,6 +21,7 @@ import org.jruby.RubyContinuation; import org.jruby.RubyFixnum; import org.jruby.RubyHash; +import org.jruby.RubyKernel; import org.jruby.RubyModule; import org.jruby.RubyNumeric; import org.jruby.RubyObject; @@ -38,6 +39,7 @@ import org.jruby.runtime.Helpers; import org.jruby.runtime.MethodIndex; import org.jruby.runtime.ObjectAllocator; +import org.jruby.runtime.Signature; import org.jruby.runtime.ThreadContext; import org.jruby.runtime.Visibility; import org.jruby.runtime.builtin.IRubyObject; @@ -247,10 +249,6 @@ private void SHIFT(ThreadContext context, int act, IRubyObject tok, IRubyObject shift(context, act, tok, val); } - private int REDUCE(ThreadContext context, int act) { - return reduce(context, act); - } - public void parse_main(ThreadContext context, IRubyObject tok, IRubyObject val, boolean resume) { Ruby runtime = context.runtime; @@ -368,7 +366,21 @@ public void parse_main(ThreadContext context, IRubyObject tok, IRubyObject val, } else if (act < 0 && act > -(this.reduce_n)) { D_puts("reduce"); - REDUCE(context, act); + { // macro REDUCE + switch (reduce(context, act)) { + case 0: /* normal */ + break; + case 1: /* yyerror */ + branch = USER_YYERROR; + continue BRANCH; + case 2: /* yyaccept */ + D_puts("u accept"); + branch = ACCEPT; + continue BRANCH; + default: + break; + } + } } else if (act == -(this.reduce_n)) { branch = ERROR; continue BRANCH; @@ -381,6 +393,7 @@ else if (act == this.shift_n) { throw runtime.newRaiseException(RaccBug, "[Cparse Bug] unknown act value " + act); } + // fall through case ERROR_RECOVERED: if (this.debug) { @@ -403,6 +416,7 @@ else if (act == this.shift_n) { call_onerror.call(context, this.parser, this.parser, this.t, val, this.vstack); } + // fall through case USER_YYERROR: if (this.errstatus == 3) { if (this.t.equals(vFINAL_TOKEN)) { @@ -478,7 +492,21 @@ else if (act == this.shift_n) { } else if (act < 0 && act > -(this.reduce_n)) { D_puts("e reduce"); - REDUCE(context, act); + { // macro REDUCE + switch (reduce(context, act)) { + case 0: /* normal */ + break; + case 1: /* yyerror */ + branch = USER_YYERROR; + continue BRANCH; + case 2: /* yyaccept */ + D_puts("u accept"); + branch = ACCEPT; + continue BRANCH; + default: + break; + } + } } else if (act == this.shift_n) { D_puts("e accept"); @@ -503,17 +531,18 @@ private void shift(ThreadContext context, int act, IRubyObject tok, IRubyObject } private int reduce(ThreadContext context, int act) { - IRubyObject code; ruleno = -act * 3; IRubyObject tag = context.runtime.newSymbol("racc_jump"); - RubyContinuation rbContinuation = new RubyContinuation(context.runtime, context.runtime.newSymbol("racc_jump")); - try { - context.pushCatch(rbContinuation.getContinuation()); - code = reduce0(context); - errstatus = assert_integer(parser.getInstanceVariable(ID_ERRSTATUS)); - } finally { - context.popCatch(); - } + IRubyObject code = RubyKernel.rbCatch19(context, this, + tag, + CallBlock19.newCallClosure(this, getMetaClass(), Signature.NO_ARGUMENTS, + new BlockCallback() { + @Override + public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) { + return reduce0(context); + } + }, context)); + errstatus = assert_integer(parser.getInstanceVariable(ID_ERRSTATUS)); return assert_integer(code); }