Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
59 changes: 44 additions & 15 deletions ext/racc/com/headius/racc/Cparse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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");
Expand All @@ -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);
}

Expand Down