Language Transitions

SyntaxEditor for WPF Forum

Posted 8 years ago by Nick
Version: 12.2.0571


I'm trying to implement an editor for the razor templating engine (mvc). I've been looking at your language transitions sample, and that is very close to what I need. A few questions:

Can I use the CSharp and VBasic add-on languages instead of loading from a langdef file? When I try to do this, I'm not sure how to get the default lexical state and I can't cast these languages' lexers' to DynamicLexer.

Do you have any samples which show how to provide services for child languages (so I can provide intellisense etc. to the child language)?

Do you have any recommended regexs for the Razor syntax?

lexicalScope.StartLexicalPatternGroup = new DynamicLexicalPatternGroup(DynamicLexicalPatternType.Regex, "ASPDirectiveStartDelimiter", serverSideScriptClassificationType);
        lexicalScope.StartLexicalPatternGroup.Patterns.Add(new DynamicLexicalPattern(@"@(?!\{)"));

        lexicalScope.EndLexicalPatternGroup = new DynamicLexicalPatternGroup(DynamicLexicalPatternType.Regex, "ASPDirectiveStartDelimiter", serverSideScriptClassificationType);
        lexicalScope.EndLexicalPatternGroup.Patterns.Add(new DynamicLexicalPattern(@"[\s\r\t\n\w]+(?=[<@])"));

        lexicalScope2.StartLexicalPatternGroup = new DynamicLexicalPatternGroup(DynamicLexicalPatternType.Explicit, "ASPDirectiveStartDelimiter", serverSideScriptClassificationType);
        lexicalScope2.StartLexicalPatternGroup.Patterns.Add(new DynamicLexicalPattern("@{"));

        lexicalScope2.EndLexicalPatternGroup = new DynamicLexicalPatternGroup(DynamicLexicalPatternType.Explicit, "ASPDirectiveEndDelimiter", serverSideScriptClassificationType);
        lexicalScope2.EndLexicalPatternGroup.Patterns.Add(new DynamicLexicalPattern("}"));


Comments (1)

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

Hi Nick,

We have an internal sample we can give you that shows how to use our .NET Languages Add-on languages as child languages within things like ASP server tags.  So that concept would sort of apply to Razor as well.  We haven't worked on making a Razor langdef though.  Razor can be tricky since there aren't as clearly defined start/end delimiters for the child language as in other languages.

If you'd like that sample I mentioned, please write our support address and we'll tell you how to get it.

Actipro Software Support

The latest build of this product (v21.1.1) 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.