寻求一个交互式实用程序来创建上下文无关的解析器语法
我想要一个实用程序,我可以给出一段文本(在文本框中)并尝试解析器语法(通过编辑类似的 BNF)和标记结构,同时我可以看到解析树的外观(如果它是无法使用我当前的语法解析文本,我会看看它在哪里停止)。
关键词是交互性。 例如,我可以使用 flex 和 bison 来做到这一点,但我必须不断地重新创建我的词法分析器和解析器。
那里有这样的东西吗? 我还没有找到。 理想情况下,它应该可以在 Linux 上运行并且是免费的,如果这不是一个选择,它仍然值得关注。
I would like a utility which I can give a piece of text (in a text box) and experiment with a parser grammar (through editing a BNF of similar) and token structure while I can see how the parse tree would look (and if it's not able to parse the text using my current grammar, I would see where it halted).
The key word is interactivity. I could do this using flex and bison for example, but I would constantly have to re-create my lexer and parser.
Is there anything like this out there? I haven't found any. Ideally it should work in Linux and be free, if that's not an option it's still of interest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ANTLRWORKS (http://www.antlr.org/works/index.html)是迄今为止我见过的最好的交互式语法开发环境。 它可以让您可视化和调试用 ANTLR 编写的 LL(*) 语法。
ANTLRWORKS (http://www.antlr.org/works/index.html) is the best interactive grammar development environment I've seen so far. It let's you visualize and debug LL(*) grammars written in ANTLR.
看看 VisualBNF
Have a look at VisualBNF
你可以用 pyBison 和朋友使用 GTKSourceView 来完成它
我还没有看到任何东西,但如果你愿意,你可以编写一个程序来做到这一点。 我要么将 Bison 的源代码移植到 DSO,这样您就可以加载它并通过它运行 BNF 并拉出自动机表。 然后将评估附加到 GTK-source-view 文本框
- 或者 -
创建一个前端(GTKSourceView 看起来又不错)并将其附加到一些系统调用以写出你的 flex.c 和 bison.c 并形成一些共享对象输出.so 然后被加载并卸载到应用程序中,然后您可以通过它运行一些源代码。
我在开发语法时倾向于使用pyBison和其他高级语言工具来提高开发速度。 然后稍后将 C/Flex/Bison 与 .l 和 .y 文件一起使用。 GTK 在 Python 中应该非常容易使用来实现上述目标,而不需要 DSO 和 dlopen() fandango。
与 Read-Eval-Print 循环非常相似,其中 BNF 和测试语法与一些后端 D/NFA 生成器处于循环中
稍后
我发现这回答了另一个问题:
http://jscc.jmksf.com/jscc_on_web.png
它是一个类似 JavaScript Yacc/Bison 的工具,用于生成解析器在 JavaScript 中。 您可以轻松地使用它来调试您的 C 语法,因为无论如何它们都是 BNF! 我一定会用它。
you could knock it up with pyBison and friends using GTKSourceView
I have not seen anything, but you could write a program to do this if you wanted. I would either port the source of Bison to a DSO such that you can load it and run your BNF through it and pull out the automata tables. Then attach the evalutation to a GTK-source-view textbox
-- or --
Create a frontend (GTKSourceView seems good again) and attach that to some system calls to write out your flex.c and bison.c and form some shared object output.so which is then loaded and unloaded into the app which you can then run some source through.
What I tend to do when developing a grammar is use pyBison and other high-level language tools to increase the speed of development. Then use C/Flex/Bison with by .l and .y files later. GTK should be really easy to use in Python to achieve the above without the need for DSOs and dlopen() fandango.
Quite similar to a Read-Eval-Print loop whereby the BNF and test syntax are in a loop with some backend D/NFA generators
some time later
I found this answering another question:
http://jscc.jmksf.com/jscc_on_web.png
It is a JavaScript Yacc/Bison-like tool for generating parsers in JavaScript. You could easily use this to debug your C grammars as they are all BNF anyway! I will sure use it.