[perl #40231] [PATCH] t/compilers/pge/06-grammar.t written in PIR

2006-09-08 Thread Will Coleda via RT
On Thu Aug 24 08:03:56 2006, smash wrote:
> Hi all,
> 
>  Inspired in the new t/compilers/pge/p6regex/01-regex.t written in PIR
> by Coke, I have rewritten t/compilers/pge/06-grammar.t in PIR. The
> test became four times faster. I think this test file should replace
> the current t/compilers/pge/06-grammar.t, which is written in Perl.
> But before that i would like to have some comments, suggestions for
> improvments, etc.
> 
>  Attached to this message you can find a file named '06-grammar.t'
> which implements the same tests as the current
> t/compilers/pge/06-grammar.t but in PIR.
> 
> Best regards,
> ./smash

Thanks, Applied as r14504!




Re: socket related constants

2006-09-08 Thread chromatic
On Friday 08 September 2006 03:38, Leopold Toetsch wrote:
> typical socket ocde currently looks a bit unfriendly due to magic
> constants, e.g.
>
> socket sock, 2, 1, 6  # PF_INET, SOCK_STREAM, tcp
>
> I'd like to have symbolic constants for all that stuff:
>
> socket sock .PF_INET, .SOCK_STREAM, .PROTO_tcp
>
> Appended is a C snippet, which produces such constants[1]. It's incomplete
> and not integegrated in Configure/make at all, but maybe it is a starting
> point.
>
> Q: is there a better option to generate these constants?

It'd sure be nice to have a PGE/TGE parser that could understand C header 
files and generate static NCI code.  (That is, don't make the FFI mistake of 
parsing the header files every time you run the program that uses them.)

-- c


[perl #40292] [TODO] Add JSON tests

2006-09-08 Thread Will Coleda via RT
Thanks, applied, along with the previous patch.


Re: [perl #40292] [TODO] Add JSON tests

2006-09-08 Thread Nuno Carvalho

Hi again,

Haded some more tests to check for white spaces problems. Some tests
fail to parse and so are marked todo. Attached to this message is the
patch for the file 't/compilers/json/to_parrot.t'.

Best regards,
./smash

On 9/7/06, Nuno Carvalho <[EMAIL PROTECTED]> wrote:

Hi all,

 I haded some more tests to t/compilers/json/to_parrot.t file to test
some objects/array combinations. All tests pass at this point, except
for tests:

#17 - something about null value in a array
#25 - just added that random sequence, it does not parse not quite sure why.

Attached to this message you have the patch for file:
t/compilers/json/to_parrot.t

Best regards,
./smash

On 9/7/06, via RT Will Coleda <[EMAIL PROTECTED]> wrote:
> # New Ticket Created by  Will Coleda
> # Please include the string:  [perl #40292]
> # in the subject line of all future correspondence about this issue.
> # http://rt.perl.org/rt3/Ticket/Display.html?id=40292 >
>
>
> There is now a "JSON" compiler: perldoc compilers/json/JSON.pir
>
> We need more tests (t/compilers/json/to_parrot.t) that test the
> _dumper() output of a PMC generated by converting from a JSON string.
>
> E.g.:
>
> ""
>
> Would convert to an empty string, which would then be dumped as:
>
> "JSON" => ""
>
> See http://www.json.org/ for a description of the JSON grammar: all
> elements of that grammar should be tested.
>
> For failing tests, TODO them, and I'll be happy to fix the compiler.
> Unless you beat me to it, which is fine.
>
> As of the opening of this ticket, expect arrays and objects to fail
> (need TGE support), true/false/null to work, and strings & numbers to
> partially work.
>
> Regards.
>
> --
> Will "Coke" Coleda
> [EMAIL PROTECTED]
>
>
>



Index: t/compilers/json/to_parrot.t
===
--- t/compilers/json/to_parrot.t	(revision 14493)
+++ t/compilers/json/to_parrot.t	(working copy)
@@ -6,7 +6,7 @@
 use lib qw( t . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 35;
+use Parrot::Test tests => 41;
 
 =head1 NAME
 
@@ -81,6 +81,17 @@
 ]
 OUT
 
+json_dump_is(<<'JSON', <<'OUT', 'simple array (check white spaces)',todo=>'parse error');
+[1 , 2,  3   ]
+JSON
+"JSON" => ResizablePMCArray (size:3) [
+1,
+2,
+3
+]
+OUT
+
+
 json_dump_is(<<'JSON', <<'OUT', 'array of empty arrays');
 [[],[],[]]
 JSON
@@ -94,6 +105,20 @@
 ]
 OUT
 
+json_dump_is(<<'JSON', <<'OUT', 'array of empty arrays (check white spaces)');
+[[]  ,  [] , [] ]
+JSON
+"JSON" => ResizablePMCArray (size:3) [
+ResizablePMCArray (size:0) [
+],
+ResizablePMCArray (size:0) [
+],
+ResizablePMCArray (size:0) [
+]
+]
+OUT
+
+
 json_dump_is(<<'JSON', <<'OUT', 'array of arrays of integers');
 [[1,2,3],[1,2,3],[1,2,3]]
 JSON
@@ -149,6 +174,19 @@
 ]
 OUT
 
+json_dump_is(<<'JSON', <<'OUT', 'array of empty objects (check white spaces)');
+[{} , {}  , {}]
+JSON
+"JSON" => ResizablePMCArray (size:3) [
+Hash {
+},
+Hash {
+},
+Hash {
+}
+]
+OUT
+
 json_dump_is(<<'JSON', <<'OUT', 'array of objects with one element');
 [{"one":1},{"two":2},{"three":3}]
 JSON
@@ -165,6 +203,23 @@
 ]
 OUT
 
+json_dump_is(<<'JSON', <<'OUT', 'array of objects with one element (white space check)');
+[  { "one"  : 1 }  , {"two":  2 } , {"three"  : 3} ]
+JSON
+"JSON" => ResizablePMCArray (size:3) [
+Hash {
+"one" => 1
+},
+Hash {
+"two" => 2
+},
+Hash {
+"three" => 3
+}
+]
+OUT
+
+
 json_dump_is(<<'JSON', <<'OUT', 'array of objects with multiple elements');
 [{"one":1,"two":2,"three":3},{"one":1,"two":2,"three":3},{"one":1,"two":2,"three":3}]
 JSON
@@ -233,6 +288,17 @@
 }
 OUT
 
+json_dump_is(<<'JSON', <<'OUT', 'object with strings (white space check)',todo=>'parse error');
+{  "one" : "string a",   "two"  :  "string b" , "three"   : "string c"}
+JSON
+"JSON" => Hash {
+"one" => "string a",
+"three" => "string c",
+"two" => "string b"
+}
+OUT
+
+
 json_dump_is(<<'JSON', <<'OUT', 'object with one empty object');
 {"one":{}}
 JSON
@@ -276,6 +342,19 @@
 }
 OUT
 
+json_dump_is(<<'JSON', <<'OUT', 'object with one object of various element with strings (check white spaces)',todo=>'parse error');
+{   "one" :  { "one" :   "string a" , "two"  : "string b"  ,  "three" :  "string c"   }}
+JSON
+"JSON" => Hash {
+"one" => Hash {
+"one" => "string a",
+"three" => "string c",
+"two" => "string b"
+}
+}
+OUT
+
+
 json_dump_is(<<'JSON', <<'OUT', 'object with more than one empty object');
 {"one":{},"two":{},"three":{}}
 JSON


When should a LAST block be triggered?

2006-09-08 Thread Agent Zhang

Hello~

S04 says, "A NEXT executes only if the end of the loop block is
reached normally, or an explicit next is executed."

Then how about LAST blocks?

Do they execute only if the last iteration of the loop is reached
normally, or an explicit last is executed?

Will return/leave/goto quietly bypass LAST blocks just like NEXT?

Clarification (especially in the form of S04 updates) will be very
appreciated. Thanks!

Agent


Re: IO::Socket, or any IO

2006-09-08 Thread Michael Snoyman

Thanks Audrey.  I actually found that after writing that post.  What I had
wanted to do was write a threaded server, implemented in Perl 6 only (ie,
including Perl 6 regexs).  I got that working almost entirely, when I
couldn't find any thread implementation.  I tried using fork() to get a same
effect, but it seems that fork also isn't available.  Was I missing
something, or are these just features that I need to wait for?

Thanks,
Michael

On 9/8/06, Audrey Tang <[EMAIL PROTECTED]> wrote:




在 Aug 25, 2006 12:54 AM 時,Michael Snoyman 寫到:

> I was thinking of rewriting a little webserver program I wrote in
> Perl 5
> using Pugs.  I was wondering what the equivilent (if any) of
> IO::Socket is.
> I suppose I could use an external webserver and use CGI to get this
> working
> with IO, but my preference would be a pure Perl 6 approach.

See examples/network/http-server.pl in the Pugs tree. :-)

Cheers,
Audrey




socket related constants

2006-09-08 Thread Leopold Toetsch
Hi,

typical socket ocde currently looks a bit unfriendly due to magic constants, 
e.g.

socket sock, 2, 1, 6# PF_INET, SOCK_STREAM, tcp

I'd like to have symbolic constants for all that stuff:

socket sock .PF_INET, .SOCK_STREAM, .PROTO_tcp

Appended is a C snippet, which produces such constants[1]. It's incomplete and 
not integegrated in Configure/make at all, but maybe it is a starting point.

Q: is there a better option to generate these constants?

leo

[1] # or such
$ cc -DUNIX -o sock_gen -Wall sock_gen.c && ./sock_gen > 
runtime/parrot/include/socket.pasm
#include 
#include 

#ifdef UNIX
#include 
#include 
#endif

#ifdef WIN32
#include 
#endif

int main(int argc, char *argv[])
{
struct protoent *ent;

printf("# DO NOT EDIT - autogenerated by Configure.pl & %s\n\n", argv[0]);
printf("# protocal family\n");
printf(".constant PF_UNIX %d\n", PF_UNIX);
printf(".constant PF_LOCAL %d\n", PF_LOCAL);
printf(".constant PF_INET %d\n", PF_INET);
printf(".constant PF_INET6 %d\n", PF_INET6);

printf("\n# socket type\n");
printf(".constant SOCK_STREAM %d\n", SOCK_STREAM);
printf(".constant SOCK_DGRAM %d\n", SOCK_DGRAM);
printf(".constant SOCK_RAW %d\n", SOCK_RAW);

printf("\n# protocols\n");
while ( (ent = getprotoent() )) {
	printf(".constant PROTO_%s %d\n", ent->p_name, ent->p_proto);
}
endprotoent();

return 0;
}


Re: IO::Socket, or any IO

2006-09-08 Thread Audrey Tang



在 Aug 25, 2006 12:54 AM 時,Michael Snoyman 寫到:

I was thinking of rewriting a little webserver program I wrote in  
Perl 5
using Pugs.  I was wondering what the equivilent (if any) of  
IO::Socket is.
I suppose I could use an external webserver and use CGI to get this  
working

with IO, but my preference would be a pure Perl 6 approach.


See examples/network/http-server.pl in the Pugs tree. :-)

Cheers,
Audrey