Is Python 3.5's grammar LL(1)?

扶醉桌前 提交于 2019-12-06 02:41:55

问题


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

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


回答1:


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):

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

    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.



来源:https://stackoverflow.com/questions/31637435/is-python-3-5s-grammar-ll1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!