develooper Front page | perl.perl6.compiler | Postings from January 2005

quoting characters

Thread Next
Nicholas Clark
January 2, 2005 02:33
quoting characters
Message ID:
Something that I've just found useful, and might prove useful for the perl 6
compiler somewhere...

In Perl 5 ASCII 0 bytes are valid in source code. As they're not identifier
characters [ :-) ] this means that they're valid as quoting characters for
things like q{}. Although they can't be stored inside C strings, the
Perl 5 tokeniser has no problem with them. This makes them rather useful,
as they can be used as delimiters around snippets of code generated
inside the compiler, where the snippet came in as a C string, as you can
guarantee that they won't appear *in the middle* of your snippet, so you
don't need to faff with parsing it and quoting a delimiter string.

Rafael used them to solve a bug when patch names had perl code in them:

and I've just used them to eliminate a lot of parsing and quoting code in
the Perl 5 tokeniser where it converts the -F flag to perl code:

I'm assuming that the insides of the Perl 6 compiler are going to be
equally agnostic of ASCII 0 bytes.

Nicholas Clark

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About