E
E
EGDFree2013-06-26 21:30:54
linux
EGDFree, 2013-06-26 21:30:54

Syntax highlighting rules for Kate?

I want to add a rule so that an apostrophe inside a construct matching the q'(\S).*\1' regular expression is not considered a closing one. For example, q'#Oracle's quote#' is a single string literal.

Opened the file ~/.kde4/share/apps/katepart/syntax/sql.xml , into the element

<context name="Normal" attribute="Normal Text" lineEndContext="#stay"><br>

in front of the node
<DetectChar attribute="String" context="String literal" char="'"/><br>

add my node
<RegExpr attribute="String" context="Oracle quote operator" String="q&(\S)" dinamic="true" lookAhead="true"/><br>

Then I added the appropriate context, but nothing works ...
<context name="Oracle quote operator" attribute="String" lineEndContext="#stay" dinamic="true" lookAhead="true"><br>
        <Detect2Chars attribute="String" context="#pop" char="%1" char1="&" dinamic="true"/><br>
        <DetectChar attribute="String Char" context="#stay" char="&"/><br>
</context><br>


I tried without regular expressions just to search for a string of the form q'# #' through StringDetect, but this also did not lead to highlighting the test as a string literal. I can't figure out what I'm doing wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EGDFree, 2013-07-20
@EGDFree

Found a variant of the task of rules at which everything works.

<contexts>
      <context name="Normal" attribute="Normal Text" lineEndContext="#stay">
        <RegExpr attribute="Operator" context="Quote operator brace" String="\bq'\{" insensitive="true"/>
        <RegExpr attribute="Operator" context="Quote operator bracket" String="\bq'\[" insensitive="true"/>
        <RegExpr attribute="Operator" context="Quote operator parenthesis" String="\bq'\(" insensitive="true"/>
        <RegExpr attribute="Operator" context="Quote operator" String="\bq'(\S)" insensitive="true"/>
        <DetectChar attribute="String" context="String literal" char="'" insensitive="true"/>
      </context>
      <context name="Quote operator" attribute="String" lineEndContext="#stay" dynamic="true">
        <RegExpr attribute="Operator" context="#pop" String="%1'" dynamic="true"/>  
      </context>
      <context name="Quote operator brace" attribute="String" lineEndContext="#stay">
        <Detect2Chars attribute="Operator" context="#pop" char="}" char1="'"/>
      </context>
      <context name="Quote operator bracket" attribute="String" lineEndContext="#stay">
        <Detect2Chars attribute="Operator" context="#pop" char="]" char1="'"/>
      </context>
      <context name="Quote operator parenthesis" attribute="String" lineEndContext="#stay">
        <Detect2Chars attribute="Operator" context="#pop" char=")" char1="'"/>
      </context>
</contexts>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question