Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Parsing with Perl 6

by erikharrison (Deacon)
on Jul 05, 2002 at 03:46 UTC ( #179559=note: print w/ replies, xml ) Need Help??


in reply to Parsing with Perl 6

For lots of reasons, this is very impressive. As I am still learning Perl 5, I've had a hard time internalizing Perl 6 regexen. Overall, you've shown the nay sayers and doubters what can be done with the new syntax (and given me something to analyze while I wait for Exegesis 5 :-).

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.

Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


Comment on Re: Parsing with Perl 6
Re: Re: Parsing with Perl 6
by jryan (Vicar) on Jul 05, 2002 at 05:39 UTC
    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).

      Right... but I am not sure that you cover this case:

        q{"this string ends with a backslash \\"}

      does it? That is, \\" and \" are different.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://179559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2014-07-26 17:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls