[Ottawa-pm] Perl6 eval

Allan Fields allan.fields at gmail.com
Mon Sep 26 23:50:07 PDT 2011


While I've had good success with a Client-Server Perl6 haz-bah, my
long term intent is to use it as a block in a web service.

A few questions to this list for those having Perl6 knowledge with
Grammar internals, likewise I'm going to hang around #perl6
(freenode).

Happily, many modules exist now, that do cool things in the new v6
code base and I was able to use these under PANDA.

It still does seem like an excercise in ACME::Language for the time
being, but practical applications I am assured are not that far off.
I'd be interested to hear stories of those who have succeeded in
implementing Perl6 rakudo in their pre-prod or prod environment.

In the mean-time, I currently have a small tool I've written which
parses text based upon grammars and a match which was specified
against various strings and which returns a results vector.

In my PoC, I have a work-around which uses a dispatch hash to choose
which grammar to return results for based on the values from another
process.  This is acceptable given the end application, but will mean
that the fully modular grammar cannot be passed to the backend
process, but must be registered into the server, then called by the
client.

Back to the evaluation method..
The mechanism involved in the eval of a Grammar, attempts 2-3 approaches:

0)  String: An attempt is made to evaluate a string  containing a
grammar but this approach does not work.

1)  String concat: An attempt is made to build and evaluate a string
containing a grammar.

2)  Finally, evaluation of a Grammar block with the rules/tokens
inlined.  (Which interpolation in the Grammar does this?  A simple
variable substitution doesn't.)


I have also made an attempt to work with the match object/tree
returned from larger Matches in order to extract the desired results.

Perl6 is quite flexible in how you can work with the results of the
match, but it is a bit hard for a v6 newbie to grok the Match object
syntax, so what I do to shed soem light is to simply print the
$match.perl block and see what-all is returned.

See attach code example showing how/why you cannot simply eval a
grammar block yet.  I loathe that I have not simply got some
successful cases to post to list.  I'll try to get some code snippets
here (affirming Perl6 works well in target applications.)


Thanks,
    Allan Fields
    Ottawa, Canada
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-grammar.pl6
Type: application/octet-stream
Size: 2591 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/ottawa-pm/attachments/20110927/908e8e19/attachment.obj>


More information about the Ottawa-pm mailing list