How can I store some data to the tokens in SemanticParser

SyntaxEditor for Windows Forms Forum

Posted 9 years ago by Peter Luo - AIMNEXT
Version: 4.0.0285
Avatar
Hi,

I want to define somen properties in my customize token class(inherit from MergeableToken class), and set value in the SemanticParser class, but when I use these properties in the XXXSyntaxLanguage class through
"((MyTokenClass)Document.GetTextStream(offset).Token).SomeProperties", the value is incorrect. How can I do that?

I knew that in DynamicToken class have "SemanticParseData" property, but what is the same one in non-DynamicToken class ?

In other words, how can I store some data to the tokens in SemanticParser, and get these data in other class after parser the document?

I used non-dynamic language definition.

Thanks

Comments (1)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Peter,

The lexer and tokens used in the semantic parser are unfortunately completely separate copies from those in the document. This is done to prevent any threading issues since generally semantic parsing is done in a worker thread.

What you'd likely have to do is on the semantic parse data changed event (which fires when the parsing completes), determine which range of tokens you altered and then alter the document's version of those tokens the same way.

The SemanticParseData property isn't really directly used by us, I believe you can make any property you want on your non-dynamic tokens to store semantic parse data.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.