Setup for Java and Ragel.

This commit is contained in:
Yorick Peterse 2014-05-06 10:20:30 +02:00
parent 2652bc0103
commit 64c9e18651
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,40 @@
package org.liboga.xml;
%%machine lexer;
import java.io.IOException;
import org.jruby.Ruby;
import org.jruby.RubyModule;
import org.jruby.RubyClass;
import org.jruby.RubyObject;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
@JRubyClass(name="Oga::XML::Lexer", parent="Object")
public class Lexer extends RubyObject
{
%% write data;
public Lexer(Ruby runtime, RubyClass klass)
{
super(runtime, klass);
}
@JRubyMethod
public IRubyObject advance_native(ThreadContext context)
{
%% write init;
%% write exec;
return context.getRuntime().getNil();
}
}
%%{
main := |*
any;
*|;
}%%

View File

@ -20,5 +20,12 @@ rule '.c' => '.rl' do |task|
sh "ragel -C -G2 #{task.source} -o #{task.name}" sh "ragel -C -G2 #{task.source} -o #{task.name}"
end end
rule '.java' => '.rl' do |task|
sh "ragel -J #{task.source} -o #{task.name}"
end
desc 'Generates the lexers' desc 'Generates the lexers'
task :lexer => ['ext/liboga/lexer.c'] multitask :lexer => [
'ext/liboga/lexer.c',
'ext/liboga/org/liboga/xml/Lexer.java'
]