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

Colin Yates colin.yates at gmail.com
Fri Jul 29 09:04:26 PDT 2011


(oops - clicked reply instead of reply-all)

---------- Forwarded message ----------
From: Colin Yates <colin.yates at gmail.com>
Date: 29 July 2011 16:34
Subject: Re: [antlr-interest] Any HTML editors for rich editing of documents
conforming to an ANTLR grammar?
To: Sam Harwell <sharwell at pixelminegames.com>


Hi Sam,

Thanks for the info.  I had seen both of those, but they are too heavyweight
for my needs - the editor must be a HTML5 construct.  Shipping any desktop
tool is a no-no as this is a web-application.

Regarding "You probably shouldn't try to create a new solution in this area.
I've been
working on IDEs for the past several years, and I can tell the task is
nowhere near as straightforward as it seems."

Not sure what to think of that - there are quite a few assumptions in there
:).  I shall take it as a friendly warning of "here be dragons" as I am sure
that is the intent.

Unfortunately I don't see any other option.  We have decided that a DSL is
the right way forward  for allowing clients to describe their reality to our
tool (previously it was through a chinese-whispers process of spreadsheets
into spreadsheets which we parsed and populated templates in the persistent
store - *that* is nowhere near as straightforward as it seems :)), and we
have decided that ANTLR is the right tool to allow us to build the DSL.

I am surprised that there isn't more traffic in this area - I would have
thought my use-case is very common.  If it is, then how do others allow
clients to build non-trivial documents conforming to a grammar defined in
ANTLR?

If I do have to do this from scratch then I expect I shall:

 - define an abstraction for the things the editor cares about (current
errors, ability to identify context based on cursor position, safe
suggestions for example)
 - provide an implementation that is hard coded for one document in the
first instance
 - dive into the internals in the second instance to see how much I can grab
from the ANTLR internals of the generated tokeniser and parser in the second
instance

Creating a HTML5 construct to appear to work is pretty trivial I expect (and
I cannot believe it hasn't already been done).  I see the 2nd and 3rd points
above being the can-of-worms, particularly the ability to figure out the
relevant part of the grammar that matches the place in the document the user
is currently editing.

With respect, I see it as non-trivial, but not un-doable.  It would make a
nice open-source project as well....

Thanks for the help - I don't mean to be dismissive - keep the ideas coming
:)

Col

On 29 July 2011 16:16, Sam Harwell <sharwell at pixelminegames.com> wrote:

> Hi Colin,
>
> In very general terms, the task at hand is you'd like to create an IDE for
> a
> language described by an ANTLR grammar. I haven't used either of these
> products, but the closest groups I know of to producing a product like you
> describe below are Xtext: http://www.eclipse.org/Xtext/ and Actipro
> SyntaxEditor:
>
> http://www.actiprosoftware.com/products/dotnet/wpf/syntaxeditor/default.aspx
>
> You probably shouldn't try to create a new solution in this area. I've been
> working on IDEs for the past several years, and I can tell the task is
> nowhere near as straightforward as it seems.
>
> Sam
>
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Colin Yates
> Sent: Friday, July 29, 2011 5:32 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Any HTML editors for rich editing of documents
> conforming to an ANTLR grammar?
>
> 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-pa
> rsing-errors/<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
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list