Re: Best way to get a PCRE6 on the JVM?

2016-09-29 Thread Joachim Durchholz

Am 29.09.2016 um 21:41 schrieb Patrick R. Michaud:

On Thu, Sep 29, 2016 at 01:30:29PM +0200, Joachim Durchholz wrote:

Can you tell me where the sources for the regex engine live? At the
detailed-technical-spec level, I found S05, and I can find the NQP spec, but
I don't know my way around the interpreter sources yet.


The regex engine lives in src/QRegex of the nqp repository.
https://github.com/perl6/nqp/tree/master/src/QRegex


Thanks, going to look into it.


My hope is that it's possible to use the JVM port of Rakudo to compile the
regex engine to JVM bytecode.


I'm not entirely familiar with Rakudo's JVM implementation, but I
believe that the regex engine portion (supplied by NQP) is
_already_ in JVM bytecode.


My bad - with "Rakudo", I meant whatever is compiling the regex NQP 
sources to bytecode.

What is the NQP compiler, anyway?


Unlike PCRE, the NQP regex library isn't a C-based library that
is magically linked into the runtime engine with glue.


Indeed. It's a pretty portable design.

This should provide quite some synergies.
1) An NQP-based PCRE will be almost guaranteed to have a 100% exact 
semantics, no excuses.

2) It will even follow the future evolution of Perl regexen.
3) The Perl crowd won't have to deal with subtle corner cases that a 
PCRE library misimplemented.
4) This provides another incentive to write a backend for yet another 
platform: beyond Perl6, they also get a pretty powerful and 
well-designed regex library for any programming language available on 
that platform.


This has all the marks of awesome written over it.
Now let's see whether I can make this happen... ;-)

Thanks for all the feedback, I think I have enough to get me started.
I'll surely be back with more questions as they arise :-D

Regards,
Jo


Re: Best way to get a PCRE6 on the JVM?

2016-09-29 Thread Patrick R. Michaud
On Thu, Sep 29, 2016 at 01:30:29PM +0200, Joachim Durchholz wrote:
> Can you tell me where the sources for the regex engine live? At the
> detailed-technical-spec level, I found S05, and I can find the NQP spec, but
> I don't know my way around the interpreter sources yet.

The regex engine lives in src/QRegex of the nqp repository.
https://github.com/perl6/nqp/tree/master/src/QRegex

> My hope is that it's possible to use the JVM port of Rakudo to compile the
> regex engine to JVM bytecode.

I'm not entirely familiar with Rakudo's JVM implementation, but I
believe that the regex engine portion (supplied by NQP) is 
_already_ in JVM bytecode.

Unlike PCRE, the NQP regex library isn't a C-based library that
is magically linked into the runtime engine with glue. 
NQP compiles the regex engine (and many of NQP's other components)
directly to the target VM's environment.

Pm


Re: Best way to get a PCRE6 on the JVM?

2016-09-29 Thread Joachim Durchholz

Am 28.09.2016 um 15:21 schrieb Will Coleda:

To start with, there isn't a PCRE6.


Good to know, then this is indeed the right list to discuss this.


If you want, more generically, to be able to use Perl 6 Regular
Expressions in Java, you can build a rakudo that runs (with reduced
functionality) on the JVM.


You mean a Perl interpreter that's been stripped down to regex and the 
bare minimum that it depends on?



I'm not sure there's a way at this point to call into the Perl 6 code
from arbitrary Java code, however.


Arbitrary Java code wouldn't be necessary, it would be a wrapper class 
that exposes the API needed to whatever people wanted to do with a regex 
and a string.


Re: Best way to get a PCRE6 on the JVM?

2016-09-29 Thread Joachim Durchholz

Am 28.09.2016 um 15:46 schrieb Patrick R. Michaud:

A simpler approach might be to build an NQP that runs on the JVM,


Sounds reasonable, given NQP's position in the toolchain.
Not sure what you mean with "build an NQP" - a compiler, a runtime, 
both, something else?


> and find a way to call into it.

Seems like the main issue is data types that get exchanged between NQP 
and Java callers, is that correct or did I overlook something?


> (The Perl 6 regular expression engine is

written in NQP.)


Good to know. The ability to simply run the implementation should reduce 
the porting effort by orders of magnitude. Also, I can entirely skip 
porting the test suite, that's one life-long task less to do - sweet.


Can you tell me where the sources for the regex engine live? At the 
detailed-technical-spec level, I found S05, and I can find the NQP spec, 
but I don't know my way around the interpreter sources yet.


My hope is that it's possible to use the JVM port of Rakudo to compile 
the regex engine to JVM bytecode. That way, Perl6 semantics would be 
entirely handled by Perl6 itself, and we'd meet at the JVM semantics 
that's well-understood by both sides.

Am I daydreaming, or is that a reasonable way forward?

Regards,
Jo


Re: Best way to get a PCRE6 on the JVM?

2016-09-28 Thread Patrick R. Michaud
A simpler approach might be to build an NQP that runs on the JVM, and
find a way to call into it.  (The Perl 6 regular expression engine is
written in NQP.)

Pm

On Wed, Sep 28, 2016 at 09:21:50AM -0400, Will Coleda wrote:
> To start with, there isn't a PCRE6.
> 
> If you want, more generically, to be able to use Perl 6 Regular
> Expressions in Java, you can build a rakudo that runs (with reduced
> functionality) on the JVM.
> 
> I'm not sure there's a way at this point to call into the Perl 6 code
> from arbitrary Java code, however.
> 
> On Wed, Sep 28, 2016 at 6:10 AM, Toolforger  wrote:
> > Hi all,
> >
> > title says it all: I have a use case for a Perl6 PCRE on the JVM.
> >
> > Sorry for wasting your time if such a thing already exists; if no, I'd like
> > to discuss strategies how to best do that.
> >
> > Thanks in advance!
> > Jo
> 
> 
> 
> -- 
> Will "Coke" Coleda


Re: Best way to get a PCRE6 on the JVM?

2016-09-28 Thread Will Coleda
To start with, there isn't a PCRE6.

If you want, more generically, to be able to use Perl 6 Regular
Expressions in Java, you can build a rakudo that runs (with reduced
functionality) on the JVM.

I'm not sure there's a way at this point to call into the Perl 6 code
from arbitrary Java code, however.

On Wed, Sep 28, 2016 at 6:10 AM, Toolforger  wrote:
> Hi all,
>
> title says it all: I have a use case for a Perl6 PCRE on the JVM.
>
> Sorry for wasting your time if such a thing already exists; if no, I'd like
> to discuss strategies how to best do that.
>
> Thanks in advance!
> Jo



-- 
Will "Coke" Coleda