[antlr-interest] Any HTML editors for rich editing of documents conforming to an ANTLR grammar?

Colin Yates colin.yates at gmail.com
Fri Jul 29 03:32:29 PDT 2011


Hi all,

Most of the products we develop use documents which are parsed by ANTLR to
describe the real world to the application.  These are none-trivial and need
to be internally consistent.  Some of these documents (not the grammar) can
run into hundreds of pages and asking people to edit them via notepad or a
HTML text area is, er, well, not the best :)

I have had a quick search for a tool to help write documents (that conform
to the grammar - *not* the grammar itself!) but came to the conclusion that
I am going to have to write my own.  The requirements I have are:

 - auto-suggest for syntactically valid constructs
 - auto-suggest for semantically valid constructs (for example, if the first
part of the grammar defines a list of Xs then when a X is referred to later
on it should auto-suggest an X, even if the construct for referring to X is
quoted text)
 - line and character high-lighting of syntactical or semantical validations
 - and so on....

Catching and identifying the location of syntax errors is pretty trivial (
http://yatesco.wordpress.com/2011/07/15/capturing-line-numbers-from-antlr-parsing-errors/),
but that is just the start. One big issue is that there needs to be an API
that executes *very* quickly of the form:
List<Suggestion> calculateSuggestions(String currentWordFragment, int line,
int character) to retrieve a list of syntacticly and semantically correct
words.  To figure that out, there needs to be a way of identifying which
bits of grammar that position in the document has.

I don't want to write one editor specific to each grammar, rather I want to
abstract the required information into a generic library with one
implementation of ANTLR.

And I cannot, I just cannot believe I am the first person to want to do this
:).

So, a couple of questions - is there anything already out there that will do
this?  Would using an intermediate form tree, rather than constructing my
own internal representation help (I can't see that it would)?

Another way of asking is is "how do I use ANTLRWorks for documents that
conform to a grammar rather than the grammar itself" :)

Col


More information about the antlr-interest mailing list