Adding tokens at runtime (2)

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by John Youren
Version: 4.0.0234
Avatar
Hi,

I asked this question before (
http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=1584#5613), and it worked fine. But now with the changes it's broke the code :S

I have tried to update it, but I have

if (File.Exists(FileUtilities.GetAppPath() + "\\Syntax\\Dark Basic Professional.xml"))
{
    DynamicSyntaxLanguage syn = ActiproSoftware.SyntaxEditor.Addons.Dynamic.DynamicSyntaxLanguage.LoadFromXml(FileUtilities.GetAppPath() + "\\Syntax\\Dark Basic Professional.xml", 0);

for (int pattern = 0; pattern < DBPSyntax.GetKeywordCount(); pattern++)
{
syn.LexicalPatternGroups.Insert(0, new LexicalPatternGroup(LexicalPatternType.Regex, "ReservedWordToken", editor.Document.Language.HighlightingStyles["ReservedWordStyle"], DBPSyntax.GetKeyword(pattern).GetKeyword().Replace(" ", "\\s+"), "{NonWordMacro}"));
}

    editor.Document.Language = syn;
}
Any help would be appreciated. Thanks!

Comments (3)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Could you describe in detail what the problem is?

Also do you mean upgrading from v3.1 to v4.0 is causing this problem?

[Modified at 11/13/2006 05:21 PM]


Actipro Software Support

Posted 17 years ago by John Youren
Avatar
Sure, this line

syn.LexicalPatternGroups.Insert(0, new LexicalPatternGroup(LexicalPatternType.Regex, "ReservedWordToken", editor.Document.Language.HighlightingStyles["ReservedWordStyle"], DBPSyntax.GetKeyword(pattern).GetKeyword().Replace(" ", "\\s+"), "{NonWordMacro}"));
used to work, but now there is no such property. What should I use instead to add tokens to the language after it has been loaded from XML.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The same features are there in dynamic languages but you probably just need to cast to a dynamic type.
For instance, LexicalPatternGroups is defined on the DynamicLexicalState class.
So if you cast the lexical state you are adding the pattern groups to to DynamicLexicalState
then you can do it.


Actipro Software Support

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.