How would you implement method highlighting for JScript?

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Charles W. Hooks
Avatar
I have a simpel test case I am workign with right now... But the highlighting is explicit and always shows up, regardless of whether it is a method or not... How would you go about defining a method token in the XML? My simple stab is include below, using JScript from the example and inserted a few lines between the boolean and identifier tokens...


<ExplicitPatternGroup TokenKey="BooleanToken" Style="ReservedWordStyle" LookAhead="{NonWordMacro}|\z" CaseSensitivity="Sensitive">
<ExplicitPatterns>
false true
</ExplicitPatterns>
</ExplicitPatternGroup>

<ExplicitPatternGroup TokenKey="Kali Object Methods" Style="KaliObjectMethodStyle" CaseSensitivity="Sensitive" xmlns="">
<ExplicitPatterns>methodA methodB methodC</ExplicitPatterns>
</ExplicitPatternGroup>

<ExplicitPatternGroup TokenKey="Kali Object Properties" Style="KaliObjectPropertyStyle" CaseSensitivity="Sensitive" xmlns="">
<ExplicitPatterns>propA propB propC</ExplicitPatterns>
</ExplicitPatternGroup>

<ExplicitPatternGroup TokenKey="Kali Object Events" Style="KaliObjectEventStyle" CaseSensitivity="Sensitive" xmlns="">
<ExplicitPatterns>eventA eventB eventC</ExplicitPatterns>
</ExplicitPatternGroup>

<ExplicitPatternGroup TokenKey="BobClass" Style="KaliObjectStyle" CaseSensitivity="Sensitive" xmlns="">
<ExplicitPatterns>
bob myBob
</ExplicitPatterns>
</ExplicitPatternGroup>

Comments (4)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It looks mostly ok as long as you have the styles defined. However I wonder why you have xmlns="" in those pattern group tags. That perhaps is messing things up? Try removing that and see if it helps.


Actipro Software Support

Posted 17 years ago by Charles W. Hooks
Avatar
The snippet is from an InnerXml during debug. The namespace is not a problem

The problem is that I want methods on an isntance of BobClass (aka bob and myBob) to be highlights, but not variables named the same as my method.

i.e. The following would have highlighting...
bob.methodA
myBob.methodB

The following would not have highlighting.
methodA
methodB

Right now all method are highlighted no matter where they appear.

Note: The following example do not highlight and is as expected and desired
mmethodA
methodBB
Posted 17 years ago by Charles W. Hooks
Avatar
Any ideas?
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Charles,

If you have a small number of keywords you could do things like look for a dot followed by the keyword and color it appropriately. You can build a language via code and add patterns that use lookbehind for that sort of thing.

But that may not be realistic or practical depending on the complexity of your language.

In VS, Microsoft somehow colors tokens by combining their lexer with information from semantic parsing. That is the best way to do this sort of thing but is extremely complex to implement.


Actipro Software Support

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