Derek Peschel | 3 Feb 01:40 2007

Incremental parsing using PEGs?

Hi everybody,

Has anyone tried incremental parsing algorithms (the only one I know about
is Earley's) with PEGs?  And has anyone defined a set of data structures and
functions that make it easy to hook incremental parsers to editors?

The PEG-based parser generators I've seen are interesting, but geared toward
generating batch parsers.  As you may be able to tell from my questions, I'm
looking for an editor, or some tool to create one.  Specifically I'm looking
for an editor (or editor generator) that can work with programs in different
languages.  From that point of view, PEGs are a clear and powerful way to
write language modules for the editor, but another abstraction (CFGs or
something) might address my desires too.

By "work with", I mean "highlight the complete syntax of", "allow the user
to move through and edit the parse tree of", "pass the parse tree directly
to a compiler", "mark errors returned by the compiler", and other interesting
things like that.  Correctness is important -- many popular editors cheat
too much to qualify.

Another quality I'm looking for is self-awareness or self-hosting.  So the
editor should work with files containing language modules, and the editor
should also have built-in modules for the specialized languages it executes
(macros, search patterns, system commands, etc.) and should use highlighting
at prompts as well as in file buffers.

Interrestingly, the editors I've found (Climacs and DrScheme/MrEd) are
written in LISP dialects and work with LISP programs.  LISP is amazingly
easy to parse and manipulate.  But I haven't gotten very far yet at
expanding those editors, so I thought I'd ask for more ideas.


-- Derek