From fca88a69d1ed2e91383cd1783865d447bee1c53b Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sun, 26 Oct 2014 11:39:19 +0100 Subject: [PATCH] Track Ragel call stacks in the Java lexer. This will be needed for the upcoming string lexing changes. --- ext/java/org/liboga/xml/Lexer.rl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/java/org/liboga/xml/Lexer.rl b/ext/java/org/liboga/xml/Lexer.rl index a6d3327..5c440c0 100644 --- a/ext/java/org/liboga/xml/Lexer.rl +++ b/ext/java/org/liboga/xml/Lexer.rl @@ -40,6 +40,9 @@ public class Lexer extends RubyObject /* Used by Ragel to keep track of the current state. */ int act; int cs; + int top; + int lines; + int[] stack; /** * Sets up the current class in the Ruby runtime. @@ -94,12 +97,14 @@ public class Lexer extends RubyObject int te = 0; int p = 0; int mark = 0; - int lines = 0; + int lines = this.lines; int pe = data.length; int eof = data.length; %% write exec; + this.lines = lines; + return context.nil; } @@ -109,8 +114,10 @@ public class Lexer extends RubyObject @JRubyMethod public IRubyObject reset_native(ThreadContext context) { - this.act = 0; - this.cs = java_lexer_start; + this.act = 0; + this.top = 0; + this.stack = new int[4]; + this.cs = java_lexer_start; return context.nil; } @@ -158,6 +165,8 @@ public class Lexer extends RubyObject %%{ variable act this.act; variable cs this.cs; + variable stack this.stack; + variable top this.top; include base_lexer "base_lexer.rl"; }%%