Tutorial working with languages (VB.NET 2010)

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Version: 4.0.0287
Avatar
Hi,

Where can I find a proper (visual (step by step)) tutorial on how to add languages? I'm using the trial version btw.

Thanks in advance.

[Modified at 03/04/2011 04:27 PM]

Comments (12)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello, while we do have multi-part step-by-step tutorials on how to create a custom syntax language in our newer WPF and Silverlight versions of SyntaxEditor, we don't have such a thing in our WinForms version at this time.

What I would suggest is looking at the documentation and at the various syntax language samples that are provided. In the C# sample project we have a Languages/Dynamic/Lexers folder that contains many XML definitions for dynamic languages. VB's sample project uses those too. Then in the Languages/SimpleAddon folder we do a more advanced implementation of a language that has automated IntelliPrompt support, etc.

You can always post here or email us if you have questions after looking through the documentation and samples.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Thanks for the tip. Will have a look at it and let you know.

[Modified at 02/06/2011 07:46 AM]
Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Nope, the C# example is a maze of code, which is or a beginner like me way to hard to understand. Anyone with a direct approach? I just want a simple example which tells me how to create the syntax-highlighting using a lexer. Nothing fancy.

Thanks in advance.

[Modified at 02/07/2011 04:26 AM]
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Right, the Simple language is a full featured syntax language implementation so it my not be the best place to start.

If you just want to start with lexing and syntax highlighting, then look in the C# sample project's Languages/Dynamic/Lexers folder. The ActiproSoftware.CSharp.xml file is a good example to start with, to clone, and alter as you need. It's pretty easy to modify a dynamic language XML definition since it's all pattern-based.

One note is that if you do clone that file, remove the SyntaxLanguageTypeName attribute at the top. As described in the documentation that attribute ties in a code-behind class that lets you add code outlining, etc. But for starting out, you don't want to worry about that yet.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Thanks for the reply.

Have to convert everything to VB and since lack of clear description and documentation it will take some time. Will let you know. If I get the highlighting and intellisense to work I'm thinking of buying this one or QWHALE, since they have a special tool to create the lexers etc. far more easy. But I have a few weeks left before the trial stops to test everything.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You shouldn't have to convert anything to VB. The VB sample project has everything in it. Only the XML definition files (XML format) are in the C# sample's folder structure.

Also please note that our newer WPF/Silverlight versions of SyntaxEditor have a very nice Language Designer application where you can design your lexer using its user interface.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Sorry for my late reply. My laptop crashed (propably my HD broke down) Next week I'll have it back. Meanwhile I installed it on another computer. Today I start again and see how to append a language and let you know.
Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Okay, I have copied a file (ActiproSoftware.HTML.xml) from the lexers folder, renamed it to html.xml and added it to my project (folder "lib").

When I call it to load I get an error:

I've copied the XmlDynamicSyntaxLanguage.vb & HtmlDynamicSyntaxLanguage.vb classes to my project.

myEditor.Document.LoadLanguageFromXml(Application.StartupPath & "\lib\html.xml", 0)

I guess I'm forgetting something.

[Modified at 03/04/2011 11:54 AM]
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You need to make sure the SyntaxLanguageTypeName attribute in the root tag of the HTML tag points to the right "namespace.type, assemblyname" that it is in your assembly.

Also note that the HTML language links to other languages like CSS, etc. So you'd need to pull those over too and do the same sort of thing if they have SyntaxLanguageTypeName attributes. If you search through the HTML language definition for "filename=" you can find all the child languages it references and needs.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
hmmm... I did everything you told me. Changed all the "Filename" to the proper name etc, with the same result.

I created a small project and perhaps you could have a look and tell me what I'm doing wrong.

http://www.mediafire.com/file/6spivftrrlzydf5/testEditor.zip

Thanks in advance.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
There were three problems:

1) You had this in some of the XML definitions that weren't the HTML language (like css.xml), so I removed those:
SyntaxLanguageTypeName="html_edit.HtmlDynamicSyntaxLanguage, testEditor"

2) If you look in your assembly output, you set up your project so there is a testEditor default namespace meaning the entry in your html.xml file should be this instead:
SyntaxLanguageTypeName="testEditor.html_edit.HtmlDynamicSyntaxLanguage, testEditor"

3) You need to set all the .xml files to copy to your bin folder via the VS properties on those files. You only had the html.xml one doing so.

If you do those changes it works.


Actipro Software Support

Posted 13 years ago by Radjesh Klauke - Mr., X-impress
Avatar
Aha.. It was like that. It's simpler that I thought, but you really need to know this, you can't learn this from the examples nor the "help"... (at least... I couldn't )
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.