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
[ Parent
| on HN ]
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.