Extend IdentifierToken

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Carl Gilbert
Avatar
Hi

I have the following line in my language definition:
<RegexPatternGroup TokenKey="IdentifierToken" Style="VariableStyle" PatternValue="(_ | {AlphaMacro})({WordMacro})*" />
Is it possible to get code starting with a number or a single number to show up as an IdentifierToken?
So any of the following would show up as IdentifierTokens: 3, 4fds, fds3, 43re43, re34re

Note: I do not have a RealNumberToken or an IntegerNumberToken.

Also, how would this work is the token text has other characters such as: # - + £ $ % ^ etc.?
This last question isn't that important as I might just exclude the use of such characters.

Regards, Carl

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Absolutely... you can do almost anything with regular expressions.

Here's what you can use:
<RegexPatternGroup TokenKey="IdentifierToken" Style="VariableStyle" PatternValue="{WordMacro}+"/>
However WordMacro by default includes _ characters as well, which you may or may not want. If you don't want those, you can change it to something like:
<RegexPatternGroup TokenKey="IdentifierToken" Style="VariableStyle" PatternValue="({AlphaMacro} | {DigitMacro})+"/>


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.