开发者

Parsing a context-free grammar in Python

What tools are 开发者_运维技巧available in Python to assist in parsing a context-free grammar?

Of course it is possible to roll my own, but I am looking for a generic tool that can generate a parser for a given CFG.


I warmly recommend PLY - it's a Lex/Yacc clone in Python that uses the language's introspection facilities in a sophisticated manner to allow for a very natural specification of the grammar. Yacc, if you recall, is the very embodiment of CFGs in an understandable DSL that defines how one parses them.

I used it to implement my parser for ANSI C and the interaction with PLY was almost effortless.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜