• Products
  • Download
  • Purchase
  • Support
  • Company
Actipro Software company logo
Twitter Follow Actipro RSS Subscribe (RSS Feed)

The Actipro Blog

Tag Cloud

  • blog
  • docking
  • editors
  • intelliprompt
  • micro charts
  • navigation
  • propertygrid
  • ribbon
  • shared library
  • silverlight
  • syntaxeditor
  • themes
  • views
  • web site
  • winforms
  • winrt
  • wpf

Twitter Feed

Tweets by @Actipro

Month List

  • 2013
    • June (3)
    • May (7)
    • April (7)
    • March (9)
    • February (2)
    • January (7)
  • 2012
    • December (4)
    • November (7)
    • October (5)
    • September (7)
    • August (5)
    • July (9)
    • June (11)
    • May (12)
    • April (6)
    • March (11)
    • February (11)
    • January (2)
  • 2011
    • December (2)
    • November (7)
    • October (2)
    • September (1)
    • August (5)
    • July (3)
    • June (6)
    • May (5)
    • April (8)
    • March (4)
    • February (5)
    • January (9)
  • 2010
    • December (9)
    • November (10)
    • October (4)
    • September (8)
    • August (12)
    • July (9)
    • June (7)
    • May (6)
    • April (7)
    • March (6)
    • February (6)
    • January (4)
  • 2009
    • December (2)
    • November (2)
    • October (12)
    • September (3)
    • August (11)
    • July (10)
    • June (6)
    • May (3)
    • April (7)
    • March (6)
    • February (8)
    • January (10)
  • 2008
    • December (10)
    • November (2)
    • October (3)
    • September (5)
    • August (5)
    • July (8)
    • June (4)
    • May (4)
    • April (10)
    • March (8)
    • February (1)
    • January (2)

Category List

  • RSS feed for ActiproActipro (406)
  • RSS feed for AppsApps (8)
  • RSS feed for Blog SummaryBlog Summary (19)
  • RSS feed for Customer ShowcaseCustomer Showcase (1)
  • RSS feed for GeneralGeneral (43)
  • RSS feed for In developmentIn development (198)
  • RSS feed for New featuresNew features (211)
  • RSS feed for New productNew product (56)
  • RSS feed for PromotionPromotion (2)
  • RSS feed for SilverlightSilverlight (146)
  • RSS feed for Tips and tricksTips and tricks (4)
  • RSS feed for Visual Studio 2008Visual Studio 2008 (2)
  • RSS feed for Windows FormsWindows Forms (28)
  • RSS feed for Windows VistaWindows Vista (10)
  • RSS feed for WinRTWinRT (39)
  • RSS feed for WPFWPF (318)
  • RSS feed for XAMLXAML (34)

About Us

Actipro Software is a leading provider of .NET user interface controls for the WPF, WinRT XAML, Silverlight, and WinForms frameworks, and is most well-known for their SyntaxEditor syntax-highlighting code editor control.

Please take some time to learn more about us and our product offerings.

SyntaxEditor grammar/AST framework part 8: Grammar debugger preview

August 20, 2010 at 8:32 AM
by Bill Henning (Actipro)

In the previous post, we added error handling to our Simple language grammar.  This allowed the grammar parser to recover from any invalid syntax in a document being parsed, and to still produce an AST.

It concluded the three basic stages in building a grammar:

  1. Configure terminals, non-terminals, and EBNF productions
  2. Add customized tree constructors to productions that create a concise AST
  3. Add error handling to recover from invalid syntax

Now what happens when in the middle of the grammar design and something is not parsing as intended?  It can be tricky to know what the parser is “thinking” since it’s a bit of a black box.

Debugger1

To solve this issue, we’ve built complete debugging capabilities directly into the parser and have even enhanced the Language Designer application to have a complete debugger UI! 

Debugging our XML language grammar

As mentioned in some previous posts, we’ve been working on a port of our WinForms Web Languages Add-on for WPF.  We hope to get it into the WPF Studio 2010.2 release or shortly after.  We’ve been testing the grammar/AST framework with its advanced XML language implementation.

Here’s how the Language Designer looks once the LL Parser Debugger is opened and the assembly containing the XML parser is selected:

Debugger2

The middle area shows a textual EBNF representation of how our framework interprets the grammar that we created for our XML language.  Above that is a ComboBox containing the list of non-terminals in the grammar.

You can select a non-terminal to automatically jump to it in the EBNF representation.  Likewise, as you move the caret around in the EBNF representation, the ComboBox updates its selection appropriately.

The bottom selected tab shows the input we’ll use to debug.

Debugger3

Before we begin debugging, let’s also examine the Terminals tab.  It shows all the terminals in the grammar, their related token ID / key values, and error aliases.

Now let’s start debugging by pressing the Step Into button (or hitting F11):

Debugger4

In the above screenshot we’ve stepped into a number of constructs already.  The statusbar indicates we are paused at a * quantifier right now.  It is the quantifier that takes zero or more processing instruction text tokens.

In the EBNF, we can see the current term highlighted in yellow.  The input is also highlighting the current token in yellow and the previously-read token in green.  These visual indicators make it easy to see what we’re debugging at this break.

The Non-Terminal Stack tab on the upper right is showing us which non-terminals we’ve traversed into.  We’ve gone through the CompilationUnit non-terminal and are in the ProcessingInstruction one right now.

The Matches tab on the lower right shows us the AST matches that have been made thus far.  For this particular non-terminal production scope, we have read the <? token so far.

In the toolbar we have a full array of step commands, the same as you’ll find when debugging your standard C#/VB code in Visual Studio.  You can even set breakpoints on a non-terminal and code will auto-break when they are encountered.

Now let’s continue on a bit in our debugging…

Debugger5

In the above screenshot we have moved down further in the input and are at a < character.  In the EBNF, we’re starting to evaluate nodes that can be within an element.

The Conditions tab shows us all the “first set” tokens and any can-match callbacks that are allowed to match at the current EBNF term.

Let’s press the Start button and parse through to the end now.

Debugger6 

Parsing is complete and a text representation of the final AST result shows in the Matches tab.

Now let’s alter the input to be “<a> <b> </a>”, since we want to see if parse errors are caught.

Debugger7

When we run with this input, we see two parse errors were indicated.  Our grammar has some advanced logic in it to recognize missing close tags, etc.  You can see them reported in the Parse Errors tab.  If you double-click on an error, it will jump to the proper location in the Input tab editor.

Since our XML grammar has error handling built-in, per the techniques mentioned in the past blog posts, you can see a proper AST is constructed even though there are syntax errors.

Summary

We’ve put a lot of work into the creation of a first-class debugger UI for our upcoming grammar/AST framework.  We hope you will enjoy it once it’s released.  This is an invaluable tool when working on grammars for your own languages.

The debugger UI and the grammar/AST framework should be released in WPF Studio 2010.2, which we hope to have out in September.

Tags: wpf, silverlight, syntaxeditor
Filed under: Actipro, In development, Silverlight, WPF
Submit to DotNetKicks...
Permalink | Comments (2)

Related posts

SyntaxEditor grammar/AST framework part 3: Creating a grammar for the Simple languageIn the previous post we gave a detailed introduction to symbols, EBNF terms, and how you can transla...SyntaxEditor grammar/AST framework part 5: Optimizing the Simple grammar’s AST outputIn the previous post we gave an introduction to the powerful tree construction mechanism that is bui...SyntaxEditor grammar/AST framework part 7: Adding error handling to the Simple grammarIn the previous post, we saw how the grammar framework supports callbacks nearly everywhere in the E...

Comments

August 20, 2010 at 08:39  

trackback

SyntaxEditor grammar/AST framework part 8: Grammar debugger preview

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com

August 27, 2010 at 01:40  

trackback

FeedBurner blog post RSS feed issue fixed

FeedBurner blog post RSS feed issue fixed

The Actipro Blog - WPF and WinForms Development

Comments are closed
Copyright © 1999-2013 Actipro Software LLC. All rights reserved.
Home Actipro Software | Products | Download | Contact Us