How to implement advanced features

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Nassim Farhat
Version: 4.0.0276
Hello team,

I am using SyntaxEditor (for WinForms) and I am coding a simple language that ressembles BASIC, so I have already defined the color coding using a Grammar XML definition (GDX) file and it worked perfectly. But now I am faced with other concerns since my ultimate goal is to make this language much more andvanced and I need to prepare an evaluation on how to approach each of the following elements using ActiPro, so I was wondering if you could guide me a little on how to do the following things and/or maybe point me to code snippets?:

Auto completion (IntelliPrompt for variable, code, fct, parameters) -> User shall be able to enter a variable name, function name by directly typing the name of the elements. While typing, user shall be presented the list of available element that started with letter typed.

How to incorporate span indicator inside my present design have an automatic parsing feature that changes the style in real time for the following:
* How to show Compiler error in real time as user types and after compilation is done.
* Grammar error - draws a green wave line under text
* Highlighting style - how and when to use the highlighting style object?
* Spelling error - draws a blue wave line under text
* Syntax error - draws a red wave line under the error

How to approach teh following span indicators?
* How to implement Breakpoint
* Current statement - this is for step by step debug with the yellow arrow.

Also, I would like to know how can these styles be customized so that the user can change them whenever he/she wants (ex: from the options menu)?

My application requires that we lock certain declared variables. SO I was wondering if it was possible in ActiPro to add little pictures (ex. a little lock) right next to the variable name in the text editor?
This would be triggered by a menustrip item when right clicking on the variable.

How do i include intellisens in my code? Is there an easy way to do so? And if so, do you have specfic code examples?

I was wondering, would the .NET language add-on help increase the rapidity of developement for what I wish to achieve? If so, could it be used in parallel with the GXD-Grammar XML Definition file or would that completely change all the developement i've done so far?

I know this is asking you a lot and if you could help me with all the above question I would greatly appreaciated it.


Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Hello Nassim,

Q1/Q4: To get IntelliPrompt support, you typically have to know something about the document content, like via an AST (abstract syntax tree). If you make a grammar with our Grammar Designer and have it build AST nodes then you can run through the AST to determine which variables are defined, etc. This post gives a good summary of how we did things with the .NET Languages Add-on:

The "Simple" language sample shows how to implement quick info, parameter info, and member lists when used in a language that can examine AST data. So that is an excellent reference sample. It also shows how to respond to various UI callbacks (like keys being typed, etc.) and show the appropriate IntelliPrompt popups.

Q2: We have a QuickStart that shows how to use span indicators and make different colors for wave lines, etc. Check that out.

The "SyntaxEditor Text Visualization Features / Span Indicators" help topic will help you too.

If you use ASTs, then you can get automated error wave lines by following tips in this help topic:
"SyntaxEditor Language Definition Guide - Other Features / Error Wave Lines"

For breakpoints and current line, they are just span indicators in a span indicator layer. You can move the indicators as needed to update the UI.

The HighlightingStylesForm.cs form in the sample project shows how to allow users to customize styles.

Q3: While read-only regions are supported (and you can give them a separate background color), we don't yet support embeddeding of images in the text editor. That is something we're adding in our newer platform that we're prototyping with the WPF version right now.

Q5: Some customers who don't wish to use the add-on itself but want learn from its implementation purchase the Blueprint source code for the add-on. Directly its code may not be usable for you since its is based on our own programmatic lexer's tokens, etc. However seeing how we handle some things for Visual Basic in terms of building the semantic parser and related AST may be useful.

Hope that helps.

Actipro Software Support

Posted 14 years ago by Nassim Farhat
Thank you for your guidance.

Given the fact that the language I'm designing is not so complicated, I'm not sure if the best solution for me is to go ahead and create something similar to the "Simple" language.

Based on your samples, I have already established a basic coloring scheme for my language using Dynamic Language definition XML file, this file starts with:

<SyntaxLanguage Key="ST" LanguageDefinitionVersion="4.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/4.0/LanguageDefinition">

On the otehr hand, the simple language uses the XML grammar definition file, which starts with the following (and is way more complicated):

These seem to be 2 different files! I have noticed that coloring is not defined in the "simple" grammar language definition file. Where is it defined? If i was to go ahead with creating my own grammer language definition file will i need to flush what I already did for my dynamic language definition?

So I understand that one way to integrate intelliprompt into my language is to create a Grammar definition file similar to "simple" language and run it through the grammar desiger tool in orders to obtain my parser + AST code that manages my tokens, outlining etc... So do you think that the quickest and simplest way to accomplish what I need to do is to use the "simple" language grammer definition file, reverse engineer the "simple" grammar definition file to make it fit with my custom language and then use the Grammar designer tool to create the AST tree and parser for my custom language? If so, for someone who does not have much experience with ActiPro, according to your experience, how long do you think this can take me to accomplish?

Or maybe...

There is even a quicker and easier solution where i can directly integrate the Intelliprompt with the dynamic language i have already created (*note: all i defined so far is color of certain tokens and comments) or does it absolutely require me to define my own grammer in XML using the "simple" language example in order to create my own programmatic parser and AST tree in order to integrate the intelliprompt?
IF I could avoid all the time and overhead of create my own programmatic parser i think that it would save me a lot of trouble... A good thing is that my architecture provides a symbolic table where I can access every symbol that should be added inside the intelliprompt, I guess that it's just a matter of feeding the intelliprompt correctly and displaying the intelliprompt to the user on certain triggers, but how can i accomplish that? I have not seen any examples in your dashboard that integrates intelliprompt from a simple dynamic language definition file with only the use of syntaxEditor and no other special .NET or WEB add-ins.

If the solutin in question 3 is possible, then, using only dynamic language definition file, can I still achieve automatic parsing of my code (ex: missing ";" will trig changes in realtime like red lines inside my code) or do i absolutely need to create my own grammer language definition file in order to accomplish this?

Once again.....thank you so much for your time

[Modified at 12/22/2009 08:05 AM]
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Q1) Yes those are different. The Dynamic Language XML Definition file is just for defining a language with a dynamic lexical parser. This controls syntax highlighting and tokenizing. The Grammar XML file is used by our Grammar Designer to code generate a semantic parser class that can be integrated with your language via a code-behind class for your language. If you don't care about ASTs, then you don't need to do the Grammar XML one. In the Simple language sample, we have a programmatic lexical parser (written in code) instead of using a Dynamic Language XML Definition to define a lexical parser. But you could do either way with your language.

Q2/3) Well IntelliPrompt can be as simple or complex as you want it to be. The main question is, how hard is it for you to determine what to show and when. If you can determine what to show in a member list, etc. via just scanning a couple of tokens to determine the context of what is at the caret, then you can get away fine without an AST. The AST gives you a tree structure representing your document. So in there you can parse out all the various procedures, variables, etc. and can build lists from those. You can more easily tell whether the caret is in a procedure, etc. too. However as mentioned it can take a fair amount of work to build a Grammar XML file that will construct an AST. It all depends on how complex your language is and what the synctactic structure is like. So it's a trade off on whether you want to invest the time to do a grammar and output a semantic parser that will build an AST, which will allow you to more accurately determine the context of the caret, or not. Again if you are just building member list items based on some external list, then you probably don't need an AST.

Q4) Wave lines only automatically come in if your root semantic parse result is an ICompilationUnit that has its errors collection populated. That being said, you can easily add span indicators any time you wish (without an AST) that look like wave lines if you write code similar to our Indicators QuickStart.

Actipro Software Support

Posted 14 years ago by Nassim Farhat
I don't find much documentation concerning the ICompilationUnit and the example you have in the QuickStart use ICompilationUnit together with parsers and AST node classes.

If i want to use my dynamic language file, NO custom AST/parsing and use only the DynamicOuliningSyntaxLanguage engine how can i declare errors like: missing ";" in code and have them connected to a specific style and automatically displayed in my code?
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
The error display help is in the "SyntaxEditor Language Definition Guide - Other Features / Error Wave Lines" topic. That talks about ICompilationUnit and how it can be used to provide errors. Basically if you set your Document.SemanticParseData to an object that implements ICompilationUnit, it will look at the errors indicated in that object and will automatically show them. Normally this is done with a semantic parser generated from a grammar, where your root AST node implements ICompilationUnit. But you could really assign any object there.

If you don't want to use ASTs or that mechanism, you'd have to write code to determine where your errors are in the the code. Then you could manually add wave line indicators for those ranges and update them appropriately based on text edits. The Indicators QuickStart shows you how to make wave line indicators. You can make them in any color you wish.

Actipro Software Support

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.