加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 21:17:34 所属栏目:大数据 来源:网络整理
导读:我知道Perl语法是模糊的,它的消歧是不平凡的( sometimes involving execution of code during the compile phase)。无论Perl是否具有正式语法(虽然含糊不清和/或上下文相关)? 解决方法 从 perlfaq7 Can I get a BNF/yacc/RE for the Perl language? There
我知道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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读