in reply to Re: Parsing with Perl 6
in thread Parsing with Perl 6
A nit, though. I don't know diddly 'bout JavaScript, but are backslashed backslashes allowed in strings? If so, this grammar doesn't allow for this.
Sure it does, try the perl 5 version that I have at the end:
sub quoted_string { my $type = quotemeta shift; return qr/ $type (?: [^$type]+ | (?<= \\ ) $type )* $type /x; } my $data = qq(This "is a quoted string" and so is "this" and this one "has \\\\ \\" backslashes" and other unrelated stuff); my @matches = $data =~ / ((??{ quoted_string( qq(") ) })) /xg; print join("\n\n",@matches);
Also, here are a few Javascript code snippets for those unfamiliar with Javascript:
<script> function Some_Function (arg1, arg2) { } do { } while (1) for (i=0; i < 10; i++) { } while (1) { } </script>
Its pretty much just like C, for those who are familiar with that (except Javascript variables don't have types).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Parsing with Perl 6
by Anonymous Monk on Mar 24, 2005 at 17:25 UTC |
In Section
Meditations