3 ms·
Perl does not have grammars (at least, not built-in). Raku (formerly known as Perl 6) does: https://docs.raku.org/language/grammar_tutorial https://docs.raku.o
by lizmat 6y ago
Perl does not have grammars (at least, not built-in). Raku (formerly known as Perl 6) does: https://docs.raku.org/language/grammar_tutorial https://docs.raku.org/language/grammar_tutorial
- blindluke 6y ago> 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.