views:

278

answers:

3

Hi,

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.

+2  A: 

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.

Aiden Bell
Hi! Sorry for not getting back to you until now. This is a spare time ordeal and things have been quite hectic at work. :-)I don't think I have time to contribute to a project like this, I might also lack knowledge as I've only tried a bit of Python and have never done anything using GTK. But it's a nice idea, I wish I had some more time to invest in hobby projects.The tool you linked seems good enough! I haven't tested it yet but I'm looking forward to doing so!Thanks for answering!
DeletedAccount
@Kent - No worries, been waiting on this one ;) that tool does look pretty cool. Only found it yesterday :P Good luck!
Aiden Bell
+3  A: 

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.

Indhu Bharathi
A: 

Have a look to visualbnf at http://www.intralogic.eu/

Raffaele