[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interactive parsing with Bison

From: Hans Aberg
Subject: Re: Interactive parsing with Bison
Date: Fri, 23 Jun 2006 20:06:59 +0200

I have discussed ideas of such an IDE with Richard M. Stallman <address@hidden>, though I do not know the state of the matter for a computer programming language IDE. The simplest idea seems to be to somehow extend Emacs to do the job.

As for letting the Bison parser doing the things you want, be able to step through the grammar, the information is basically already there, in the .output file that Bison produces. Essentially, the "." in each state tells exactly how far the parsing has proceeded in each rule. So one needs to extract which state is the current (actually stacked in the parser stack), and then the IDE displays an arrow in the .y grammar for each rule in that state at the point the "." where the state is.

If there already is some IDE with the capacity of displaying multiple arrows as above, then this would vastly save the programming time needed.

  Hans Aberg

On 23 Jun 2006, at 16:20, Satya wrote:

I was looking at some of the visual parser generator tools today - I
discovered Anagram (, and Visual Parse ++
( . These tools can generate LALR parsers like
Bison but also come with a nice visual interface to single step
through parses. You compose and debug grammars through an IDE.
Unfortunately both programs are non-free.

I am considering the possibility of building a free IDE for Bison with
at least the following abilities :

1. Single step through a test input file and obtain a trace (like the
one produced by a %debug directive. But now it will break after each
step and wait for user input)

2. Alter input before proceeding to the next step.

3. Set breakpoints in the input and parse until break point is reached.

4. Watch the stack, current state, look-aheads at each state.

There are many more possibilities - for example, you can watch a GLR
parser split and merge as you single step; Also, an editor could be
provided to compose grammars with syntax highlighting (And indication
of conflicts as you compose);

I am facing two alternatives to implement this idea:

1. Take the current release of Bison, and build on its source code to
produce a visual IDE.
2. Implement a debugging interface in bison that can talk to such IDE
/debugging tools. This interface can then evolve with Bison;

The second  approach appeals to me since many tools can be built with
varying capabilities (e.g, ncurses based tool or a simple command line
tool like gdb or a full fledged IDE with GTK+ etc.) ; Also, changes in
Bison can be easily reflected in the tool (keeping a clean separation
between Bison and the IDE tool);

Also there are a number of challenges in building such an IDE. For a
start, we cant execute semantic actions while test-parsing; How would
we simulate cases  where the lexer needs to examine the symbol table
for supplying tokens ?   (possible answer: we don't).

Please comment upon this idea. I want to know your opinion on the
correct way to do this. Thanks!

By the way, I have some documentation on Bison internals on

I am still midway through it. If you think I have  documented
something incorrectly, pls drop a line. Thanks!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]