Perl 6 Grammars and Regular Expressions 202
An anonymous reader writes "Perl 6 is finally coming within reach. This article gives you a tour of the grammars and regular expressions of the Perl 6 language, comparing them with the currently available Parse::RecDescent module for Perl 5. Find out what will be new with Perl 6 regular expressions and how to make use of the new, powerful incarnation of the Perl scripting language."
Re:Big problem (Score:3, Informative)
The idea of :p5 is not just that you can take Perl 5 code and modify it to make it work.
The idea is that if you don't bother to write a zillion-rule grammar to match whatever you're trying to match, you can still use the P5-style regular expressions you know and love. It's another case of Not Swatting A Fly With The Nuke.
Re:Big problem (Score:5, Informative)
Therefore, it's just Perl 6 scripts which want to use Perl 5 regular expression syntax, which would want to use the :p5 modifier.
Don't get your knickers in a bunch.
Re:Why would a satisfied Perl5 user migrate? (Score:4, Informative)
Re:Why would a satisfied Perl5 user migrate? (Score:3, Informative)
Re:Grammar (Score:5, Informative)
Perl never was an acronym. It's a backronym.
Perl is the language and perl is the interpreter. Remember, "only perl can parse Perl" and it's easy to remember.
Re:Big problem (Score:5, Informative)
Thus spake Larry Wall in Apocalypse 5:
And from Apocalypse 1:
In other words, it is backwards compatible, it isn't backwards compatible, and when you install Perl 6, you are installing both.
TTFN
Re:bad example? (Score:3, Informative)
# Perl 6 :w modifier surrounds all tokens with "automagic" whitespace,
# which basically means it will match what most people would call
# "words"
Re:Adoption (Score:4, Informative)
Not much hypercompetition there, if you ask me. But then, it might as well be me who misunderstood the quote.
Re:Pet Project (Score:2, Informative)
Guess Mark wants to resolve a host name. Here is a working link:
http://www.ozonehouse.com/mark/blog/code/Periodic
Re:wow, looks like boost::spirit (Score:3, Informative)
Re:Big problem (Score:4, Informative)
The
Re:Perl goodness (Score:4, Informative)
There really aren't many choices. The current regular expression syntax is the only form I've seen tried, with only minor variation.
as he has done somewhat with the Perl 6 expressions
Perl 6 regular expressions have almost exactly the same syntax as Perl 5. The parts that are new are not regular expressions. Cosmetic differences (like [] vs <[]> are fairly ignorable syntactically. It would be like saying that Perl 5 will use
All of the inline comments and whitespace are part of Perl 5 extended expressions, though the word-matching on whitespace is new to Perl 6.
POSIX on the other hand ignored most of that historic syntax and instead chose their horribly bloated keyword syntax.
That's not really part of the regular expression syntax. Having [[:digit:]] as an alias for Perl's \d is hardly a different syntax so much as sugar. The fundamentals of POSIX regular expressions are the fundamentals of all modern regex syntaxes:
I've often thought that the ease with which regular expressions can be accessed within per was a blessing and a curse. So many people like yourself seem to think that Perl championed regular expressions, when in fact it just followed AWK's lead in integration between C and Ken Thompson's regular expression implementation (which in turn inspired the version that was written from scratch by Henry Spencer and used by Larry for Perl).
If you have a new syntax in mind, I suggest introducing it and seeing how it does. Modern regular expressions are an incremental improvement on classical set notations, and have served us well to date, but I'm sure someday someone will see a better way.