The Actipro Blog

All the latest UI control development news from Actipro

SyntaxEditor grammar/AST framework part 1: Overview

Last month we did a posting called “What features do you want to see in WPF/Silverlight SyntaxEditor’s grammar and AST framework?” where we described some conceptual ideas we had for building the next-generation grammar and AST framework for our SyntaxEditor code editor control.  Before continuing on this post, you may wish to quickly review that.

Today’s post begins a multi-part walkthrough on what we’ve accomplished with the framework and shows how to use it.

We’ve been testing the framework with a WPF version of an advanced XML language implementation that has a grammar-based parser which constructs an AST of an XML document.  This was shown in the previous “Progress on a SyntaxEditor Web Languages Add-on for WPF and Silverlight” post.

Quick summary of grammar/AST

A grammar/AST framework is the key to enhancing a SyntaxEditor editing experience because it gives us meaningful information about what is contained in the document.  This not only can be used to provide contextual information to the end user (what method is the caret in), but is used to help drive features like automated IntelliPrompt completion lists, parameter info, and quick info.

To quickly sum up, a grammar is a set of parsing rules defined via EBNF for how to derive structure from text.  In the case of SyntaxEditor usage, the text being examined is nearly always programming code.  When running a grammar-based parser on text, one output is typically an AST (abstract syntax tree).  Another output is a collection of parsing errors.  Other custom output can be created as well.

For example, if we define a grammar for Javascript, an end user should be able to load up a Javascript document in SyntaxEditor and our syntax language will have access to the document’s AST and errors collection.  Then with some additional coding, the syntax language can use information from the AST to provide automated IntelliPrompt for the end user.

What this multi-part walkthrough will cover

We’ll be doing multiple posts over the coming days that walk through the design of our new grammar/AST model.  We’ll step through and build a grammar for our “Simple” language that is like a slimmed down version of Javascript.

We’ll also show a preview of the grammar debugger we’re working on that we hope can be included in a future release of the Language Designer.

Here’s a list of the posts that will be part of this walkthrough series:

We’ll dig into everything starting with the next post.  Stay tuned!

Pingbacks and trackbacks (2)+

Comments are closed