是Python 3.5的语法LL(1)吗? [英] Is Python 3.5's grammar LL(1)?

查看:105
本文介绍了是Python 3.5的语法LL(1)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了 http://matt.might.net/teaching/compilers/spring -2015/表示Python 3.4是LL(1)

I saw http://matt.might.net/teaching/compilers/spring-2015/ saying Python 3.4 is LL(1)

Python 3.5的语法是否仍为LL(1),以便可以编写递归下降解析器?

Is Python 3.5's grammar still LL(1) so one can write a recursive descent parser?

推荐答案

是.这是故意的语言功能,而不仅仅是碰巧的情况. PEP 3099 明确拒绝对Python 2的任何更改-> 3个过渡(比任何3.x-> 3.y都要大得多的过渡):

Yes. This is a deliberate language feature, and not just something that happened to be the case. PEP 3099 explicitly rejected any changes to this for the Python 2 -> 3 transition (a notably bigger transition than any 3.x -> 3.y will be):

  • 解析器不会比LL(1)更复杂.

  • The parser won't be more complex than LL(1).

简单胜于复杂.这个想法扩展到了解析器.将Python的语法限制为LL(1)解析器是一种祝福,而不是 诅咒.它把我们戴上手铐,以防止我们过头 最终以时髦的语法规则(如其他动态语法)结束 无法命名的语言,例如Perl.

Simple is better than complex. This idea extends to the parser. Restricting Python's grammar to an LL(1) parser is a blessing, not a curse. It puts us in handcuffs that prevent us from going overboard and ending up with funky grammar rules like some other dynamic languages that will go unnamed, such as Perl.

这篇关于是Python 3.5的语法LL(1)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆