PatternGroup takes precedence over ChildState

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Eben Roux

Using the supplied VBDotNet and CSharp language definition files I aim to add a template parsing ASP style code state; much like CodeSmith.

I added this CodeState as a child state to the default state and the StringState and CommentState. My problem is that when one is in the StringState it works fine if the CodeState start tag (<%) is directly after the quote or escaped quotes. As soon as I type any other character it goes tot eh StringDefaultToken2 pattern group token.

How can I convince the language to enter my CodeState instead.


p.s. The SyntaxEditor is a really nifty tool and is helping me tremendously :)

Comments (1)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Eben,

It is a greedy parser so that means that once it starts matching a pattern, it will continue until a stop condition is met. What I suspect is that your internal string patterns encompass the &lt; character, therefore meaning that the parser never stops at that point to try and match a new pattern, which would make your CodeState start tag get picked up. So you might want to exclude the &lt; character from your internal string pattern and let the state's default pick it up if a CodeState start tag is not found there.

Our sample app is great for debugging custom languages. You can browse to open a language and then when you move the caret over a character, in the status bar it gives you information about what the parser has parsed for the Token under the caret. If a Token begins on a character, an asterisk (*) will appear there too. That's very helpful since in this case you want to see an asterisk at the &lt; character if you have your language set up correctly.

Actipro Software Support

The latest build of this product (v21.1.0) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.