Sample Grammar and AST production

SyntaxEditor .NET Languages Add-on for WPF Forum

Posted 12 years ago by Subramanian Akileswar
Version: 12.2.0573
Avatar

Where can I find a sample grammar and AST production?

I need to create a domain specific language for usage by users of my application. Required language features include

 

1. Indentation sensitive (like python)

2. Standard expression parsing (including operator precedence and parenthesis)

3. Functions

4. Intellisense support in SyntaxEditor

Thanks

Akil

Comments (3)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Akil,

Our Sample Browser ships with a complete Getting Started series of QuickStarts that walk through creating a robust syntax language from start to finish.  Please see that and the extensive documentation on things like the LL(*) Parsing Framework for assistance.


Actipro Software Support

Posted 12 years ago by Subramanian Akileswar
Avatar

Yes there is a lot of documentation. I have read through a fair bit of it. Let me explain where I am stuck.

1. I can use the language designer to create a lexer. I can also do the classification types for highlighting.

I am not sure where to go from there in terms of specifying the parser grammar. The language designer UI also gives me the ability to create AST nodes. Not sure what this does other than create boiler plate code for each of the AST nodes i create.

I was hoping to see a simple working example of a AST production and a visitor pattern implementation to see what I am missing. Alternately, is there a keyword I can use in the documentation search to find the right help page?

As I was writing this, I brought up the sample browser C# solution (which I had not looked at). Seems like what I was asking for is right here.

 

Thanks

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

The Sample Browser project includes a Getting Started series that walks through the full process of building a syntax language.  It also shows some tradeoffs and options along the way, such as using a dynamic or programmatic lexer.

A parser grammar has to be written by hand but it is helpful to have the Language Designer code generate the AST node classes, if you plan on using type-specific AST nodes (recommended).  Then you just write your grammar productions's tree construction code to construct the AST using those AST nodes you generated.

The Language Designer can also debug your grammar, so if you run into issues while writing it, you can run the debugger on it with some test input and see where things are going wrong.

For documentation, it is easiest to run through the Table of Contents.  The LL(*) Parser Generator area within the SyntaxEditor area has info related to the grammar design.


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.