在哪里可以找到Perl编程语言的正式语法? - 代码日志

在哪里可以找到Perl编程语言的正式语法?

我知道Perl语法是模糊的,它的消歧是不平凡的(sometimes involving execution of code during the compile phase)。无论Perl是否具有正式语法(虽然含糊不清和/或上下文相关)?
perlfaq7

Can I get a BNF/yacc/RE for the Perl language?

There is no BNF, but you can paw your
way through the yacc grammar in
perly.y in the source distribution if
you’re particularly brave. The grammar
relies on very smart tokenizing code,
so be prepared to venture into toke.c
as well.

In the words of Chaim Frenkel: “Perl’s
grammar can not be reduced to BNF. The
work of parsing perl is distributed
between yacc, the lexer, smoke and
mirrors.”

为了看到精彩的例子,为什么由于上下文的影响,几乎不可能解析Perl,请查看Randal Schwartz’s post: On Parsing Perl

另外,请参阅Simon Cozens的“Perl 5 Internals (Chapter 5. The Lexer and the Parser)”中的讨论。

请注意0​​7003

>有a grammar for Perl6
> Rakudo Perl有its own version of the grammar

http://stackoverflow.com/questions/4625408/where-can-i-find-a-formal-grammar-for-the-perl-programming-language

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:在哪里可以找到Perl编程语言的正式语法?