Does the language design tool support text/UI separation

SyntaxEditor for WPF Forum

Posted 1 month ago by Michael S
Version: 24.1.1
Avatar

the result i try to achieve is to use the language for 

1. parse and validate code without any gui

2. reuse this language in wpf for a code editor

i tried to create a language with the language designer tool. Appearantly it creates a lexer which requires the classificationprovider which in this case contains references to the syntaxeditor - which i would separate in my code.

Comments (3)

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The lexer that is generated will use an interface for the classification type provider (i.e., IMyLanguageClassificationTypeProvider).  An implementation class of that interface (i.e., MyLanguageClassificationTypeProvider) is generated too that does rely on UI, but mainly because there are color references needed for the highlighting styles that get registered, and those colors rely on the UI framework's color classes. 

You could make your own class implementation of IMyLanguageClassificationTypeProvider that doesn't do that highlighting style registration and thus wouldn't need color classes or a UI framework loaded.  That's the best way to go if you want to use the syntax language in a non-GUI environment.


Actipro Software Support

Posted 1 month ago by Michael S
Avatar

So it requires actually two ClassificationProviders to achieve code separation? Or is there any example of putting highlighting style in a different library?

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you wanted to use the syntax language in an app with UI and in an app/server without UI, you would need to have two separate classification type providers.  You would pass the one to use (based on the calling app) into the syntax language's constructor, which would need to have a parameter that is the classification type provider interface (e.g., IMyLanguageClassificationTypeProvider).

The Language Designer generates the interface and the UI-dependent version.  The non-UI-dependent version that would you write could be a simple class that implements the interface and returns ClassificationType instances for the properties.

If you were looking for an example of some separation, our premium add-ons like the .NET Languages Add-on have two libraries, one that is named with Text in the name and has no UI dependencies and another with SyntaxEditor in the name that is UI-dependent.  Our syntax language and classification type provider is defined in the latter.  Core language services are defined in the former.


Actipro Software Support

The latest build of this product (v24.1.2) was released 5 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.