Grammar designer for C/C++

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by pranay
Version: 4.0.0249
Hi all,
I'm using the evaluation version of Syntax-Editor to create an IDE which will suportC/C++.I have been tinkering with the grammar designer and given example codes. Unfortunately, I wasn't able to get hold of the grammar designer. If anyone can help me to create the Grammar.XML files for the languages specified. I went through the documentation but I wasn't able to find my starting point for creating a grammar.xml. I have tried manipulating the Simple syntax language example. Any kind of suggestion will be of great help.

Comments (2)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Pranay,

Based on your emails, you would like to do syntax highlighting, outlining, and some IntelliPrompt.

First, the grammar designer is for developing semantic grammars. That is an advanced technique that you don't really want to get into until you understand the basics of SyntaxEditor.

The best place to start is to make a dynamic language XML definition for you C/C++ language. To do that, go into our C# sample project's Languages\Dynamic\Lexers folder and copy the ActiproSoftware.CSharp.xml to a new file. Then you can start to modify that as needed to make it work for your language. Be sure you remove the SyntaxLanguage tag's SyntaxLanguageTypeName attribute for now (that references a codebehind class that does outlining).

You can load the dynamic any time into the SDI Editor sample via the Languages/Load Custom Dynamic menu item. This is a great way to test out how your lexer will tokenize and color code. So first finish that off by adding patterns/styles for your custom functions or anything else you want to highlight.

Once you have that complete you can move onto the next step, which is to create a code-behind class that outlines the code. The CSharpDynamicSyntaxLanguage class might be very close to what you want. So then you'll want to make your own class similar to that, include it in your assembly and add a SyntaxLanguageTypeName attribute back into your SyntaxLanguage tag, that points to that code behind class. The documentation tells you the syntax.

At that point you will have highlighting and outlining complete. Then you can start thinking about doing more complicated stuff.

Note that the Simple syntax language example is an example of a "simple" advanced programmatic lexical parser. Designing a dynamic language is more recommended for developers who are new to the product since they are much easier to create.

Also note that while our Grammar Designer and AST model are very helpful and will cut down on the time needed to make a robust semantic parser, you still might spend weeks or work to get there. For instance, our advanced C# and VB languages in the .NET Languages Add-on took us weeks each to write. But once it was completed, we now have a great system for storing reflection data and providing contextual IntelliPrompt to end users.

Hope this helps get you started!

Actipro Software Support

Posted 17 years ago by pranay
Thanks a zillion for the reply. I have started walking :). So far I'm able to highlight the keywords. As I went through the example I realized that editor is not highlighting the user defined class names or structs.
Thanks again.
The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.