Re:Perl 7 is going to be Perl 5.32, mostly
by alexchantavy on Wednesday June 24, 2020 @03:13PM
(#23632509)
Do you have a good link to learn about grammars in perl?
[ Parent
| on HN ]
Re:Perl 7 is going to be Perl 5.32, mostly
by SuspiciousSwan on Wednesday June 24, 2020 @05:26PM
(#23634064)
Start https://perldoc.perl.org/perlre.html#Extended-Patterns . I was trying to find an article from many years ago, but either my google skills fail me, or it is dead. Perl's regular expressions haven't been regular expressions for a long time. Beyond that, the ergonomics of perl make them much more useful for things like flow control than in other languages. It's similar to how you can do type matching in Java, but it's ugly, versus a language like Haskell where using type matching simplifies the code.
Perl 6 (as lizmat pointed out), has more powerful rules. I don't know a ton about them.
Re:Perl 7 is going to be Perl 5.32, mostly
by lizmat on Wednesday June 24, 2020 @03:37PM
(#23632857)
Perl does not have grammars (at least, not built-in). Raku (formerly known as Perl 6) does: https://docs.raku.org/language/grammar_tutorial
Re:Perl 7 is going to be Perl 5.32, mostly
by blindluke on Thursday June 25, 2020 @03:21AM
(#23637772)
> Perl does not have grammars (at least, not built-in).
That's not true since v5.10 (2007). Here's a sample that matches a subset of LaTeX markup:
$matcher = qr{
(?&File)
(?(DEFINE)
(?<File> (?&Element)* )
(?<Element> \s* (?&Command)
| \s* (?&Literal)
)
(?<Command> \\ \s* (?&Literal) \s* (?&Options)? \s* (?&Args)? )
(?<Options> \[ \s* (?:(?&Option) (?:\s*,\s* (?&Option) )*)? \s* \])
(?<Args> \{ \s* (?&Element)* \s* \} )
(?<Option> \s* [^][\$&%#_{}~^\s,]+ )
(?<Literal> \s* [^][\$&%#_{}~^\s]+ )
)
}xms
It's nowhere near as advanced as Raku grammars (not much is), but it's there, and it's built-in.