Can a ANTLR grammar file be modified to be used by PLY?

北战南征 提交于 2019-12-10 11:44:58

问题


I want to make a python program that uses PLY to parse Javascript files, I din't found any sources of parsers that implement the ECMAScript, Javascript rules that use PLY.

The only thing I found was some ANTLR grammar files to parse javascript and ecmascript: http://www.antlr.org/grammar/1153976512034/ecmascriptA3.g http://www.antlr.org/grammar/1206736738015/JavaScript.g

Can ANTLR grammar files be adapted to be used as PLY rules, if yes, how can be done in a semi-automatic way, do I need to parse the grammar files? Is there another workaround this (i.e. than using ANTLR grammar files)?


回答1:


Can ANTLR grammar files be adapted to be used as PLY rules, [...] ?

No, they can't. PLY generates LALR parsers while ANTLR generates LL ones. Their input grammars are too different for a trivial (or automated) conversion.



来源:https://stackoverflow.com/questions/11988016/can-a-antlr-grammar-file-be-modified-to-be-used-by-ply

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