HighlightingStyles and State Transitions

SyntaxEditor for Windows Forms Forum

Posted 7 years ago by Kevin McCormick
Version: 4.0.0288
Avatar
We wanted to get some extra functionality out of the lexical parsing stage (specifically, supporting JavaScript's unique embedded Regex support), so we replaced our Dynamic implementation of JavaScript to a hand-build one that inherits from MergableSyntaxLanguage.

The good news is that porting the Dynamic language to Mergable was pretty easy, took about two days of work, and we also got the custom state transition logic working in our hand-built lexer.

The only odd thing I noticed was that the HighlightingStyles seemed inconsistent. For example, take the example of the following two states:

DefaultState (DefaultStyle: Black)
MultiLineCommentState (DefaultStyle: Green)

We use a delegate method in our lexer to watch for the /* token like so, and it works well:
public MatchType IsMultiLineCommentStateScopeStart(ITextBufferReader reader, ILexicalScope lexicalScope, ref ITokenLexicalParseData lexicalParseData)
        {
            if (reader.Peek() == '/' && reader.Peek(2) == '*')
            {
                reader.Read();
                reader.Read();
                lexicalParseData = new LexicalScopeAndIDTokenLexicalParseData(lexicalScope, EcmaScript3TokenID.MultiLineCommentStartToken);
                return MatchType.ExactMatch;
            }

            return MatchType.NoMatch;
        }
However, the /* is black, while all the remaining characters of the comment are Green. I can fix the appearance by adding extra logic in the GetHighlightingStyle in our Language, but this doesn't seem right, since really the MultiLineCommentStartToken should be in the MultiLineCommentState, not the DefaultState.

Any ideas on how to handle this scenario?

Comments (2)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kevin,

It's hard to say without seeing it happen and debugging. Could you make a new simple sample project that shows the issue and email that over? Rename the .zip file extension so it doesn't get spam blocked.

What you describe seems to work ok in the dynamic language samples at least.


Actipro Software Support

Posted 7 years ago by Kevin McCormick
Avatar
I emailed the sample project, as requested. :-)
The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.