Look behind Macro problem

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Matt Whitfield
Version: 4.0.0238
Avatar
Hello - just another question

I am trying to modify the SQL XML language definition

I have replaced the SystemVariableToken RegexPatternGroup with an explicit list of system variables - so that, @@TEST, for example, is not recognised as a system variable

However, @@TEST then gets recognised as a single @ and then a VariableToken @@

I wanted to create a lookBehind macro that would stop the VariableToken from allowing things that start with @@ from being highlighted as a variable.

So I tried LookBehind="(?<!@@)" in the VariableToken declaration in the XML - but this complained about the < character in XML. So I tried LookBehind="(?&lt;!@@)". This let the XML be loaded, but as soon as an '@' was typed in the document, would raise an ApplicationException with the message 'Op code not implemented: 12'.

So - can anyone help me modify the following XML so that variable tokens do not match on items with two @@ at the start?

                <!-- System Variables -->
                <ExplicitPatternGroup  TokenKey="SystemVariableToken" Style="SystemVariableStyle" LookAhead="{NonWordMacro}|\z">
                    <ExplicitPatterns>
                        @@CONNECTIONS @@CPU_BUSY @@CURSOR_ROWS @@DATEFIRST @@DBTS @@ERROR @@FETCH_STATUS @@IDENTITY @@IDLE 
                        @@IO_BUSY @@LANGID @@LANGUAGE @@LOCK_TIMEOUT @@MAX_CONNECTIONS @@MAX_PRECISION @@NESTLEVEL @@OPTIONS
                        @@PACK_RECEIVED @@PACK_SENT @@PACKET_ERRORS @@PROCID @@REMSERVER @@ROWCOUNT @@SERVERNAME @@SERVICENAME 
                        @@SPID @@TEXTSIZE @@TIMETICKS @@TOTAL_ERRORS @@TOTAL_READ @@TOTAL_WRITE @@TRANCOUNT @@VERSION
                    </ExplicitPatterns>
                </ExplicitPatternGroup>
                <!-- Variables -->
                <RegexPatternGroup TokenKey="VariableToken" Style="VariableStyle" PatternValue="@ {WordMacro}+" LookAhead="{NonWordMacro}|\z" LookBehind="(?&lt;!@@)" />

Comments (2)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You'd probably want something like LookBehind="[^@]|\A"

Please note you don't need the normal lookbehind syntax in the LookBehind attribute since it adds that for you.


Actipro Software Support

Posted 17 years ago by Matt Whitfield
Avatar
thanks - that did the trick!
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.