www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Syntax highlighting update for Kate

reply "Aziz K." <aziz.kerim gmail.com> writes:
Hi!

I've taken some time to improve the syntax highlighting xml file for Kate.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
   ========================================================================

   D.XML supports syntax highlighting for the D programming language under  
Kate.

   Copyright (C) 2007 - Aziz Köksal <aziz.koeksal gmail.com>
   Copyright (C) 2007 - Jari-Matti Mäkelä <jmjm iki.fi>
   Copyright (C) 2004 - Simon J Mackenzie  
<project.katedxml smackoz.fastmail.fm>

   This code is released under the LGPL as part of kdelibs/kate.

   ========================================================================

   D is a next generation language written by Walter Bright of Digital Mars  
fame.
   Digital Mars C, C++ and D Compilers can be obtained from  
http://www.digitalmars.com/

   ========================================================================

   Updates for D.XML can be obtained from http://kate.kde.org/hl/

   UPDATE HISTORY:-
   2007.06.30 - D.XML 1.39 - D 1.017 - matching is much faster now, added  
"lib" to pragma types, added special tokens, /+ +/ can be nested now,  
numbers are matched more correctly, character literals don't span multiple  
lines anymore, escape sequences inside strings and character literals are  
highlighted, non-hex characters in hex strings are highlighted with the  
Error style, using more default styles instead of custom ones
   2007.04.11 - D.XML 1.38 - D 1.011 - ref, macro keywords are now  
supported, fixed \\ inside a string, updated author
   2007.02.12 - D.XML 1.37 - D 1.006 - bool, foreach_reverse, lazy, scope  
and typeid keywords are now supported, fixed \"
                                     - inside a string, fixed ending of  
wysiwyg strings.
   2004.08.15 - D.XML 1.36 - D 0.98  - Current release of D.
                                     - package, writef(strictly speaking  
writef isn't a keyword) - keywords are now supported.
   2004.??.?? - D.XML 1.35 - D 0.??  - Not sure how this release got posted!
   2004.05.23 - D.XML 1.34 - D 0.90  - updated.
   2004.05.19 - D.XML 1.33 - D 0.89  - mixin - keyword is now supported.
   2004.05.19 - D.XML 1.32 - D 0.77  - pragma, typeof - keywords are now  
supported.
   2004.05.19 - D.XML 1.31 - D 0.76  - is - keyword is now supported.
   2003.09.06 - D.XML 1.30 - D 0.71  - foreach - keyword is now supported.
   2003.08.18 - D.XML 1.20 - D 0.69  - floats are now supported.
                                     - embedded underscores in integer and  
float literals are now supported.
   2003.08.11 - D.XML 1.10           - updated.
   2003.07.18 - D.XML 1.00           - First released.

   TODO:-

    ========================================================================
-->

<language name="D" section="Sources" extensions="*.d;*.D"  
mimetype="text/x-dsrc" version="1.38" kateversion="2.2"  
casesensitive="true" author="Jari-Matti Mäkelä (jmjm iki.fi)"  
license="LGPL">
   <highlighting>
     <list name="keywords">
       <item> abstract </item>
       <item> alias </item>
       <item> align </item>
       <item> asm </item>
       <item> auto </item>

       <item> body </item>
       <item> break </item>

       <item> case </item>
       <item> cast </item>
       <item> catch </item>
       <item> class </item>
       <item> const </item>
       <item> continue </item>

       <item> default </item>
       <item> delegate </item>
       <item> delete </item>
       <item> deprecated </item>
       <item> do </item>

       <item> else </item>
       <item> enum </item>
       <item> export </item>

       <item> false </item>
       <item> final </item>
       <item> finally </item>
       <item> for </item>
       <item> foreach </item>
       <item> foreach_reverse </item>
       <item> function </item>

       <item> goto </item>

       <item> if </item>
       <item> in </item>
       <item> inout </item>
       <item> interface </item>
       <item> invariant </item>
       <item> is </item>

       <item> lazy </item>

       <item> macro </item>
       <item> mixin </item>

       <item> new </item>
       <item> null </item>

       <item> out </item>
       <item> override </item>

       <item> package </item>
       <item> private </item>
       <item> protected </item>
       <item> public </item>

       <item> ref </item>
       <item> return </item>

       <item> scope </item>
       <item> static </item>
       <item> struct </item>
       <item> super </item>
       <item> switch </item>
       <item> synchronized </item>

       <item> template </item>
       <item> this </item>
       <item> throw </item>
       <item> true </item>
       <item> try </item>
       <item> typedef </item>
       <item> typeid </item>
       <item> typeof </item>

       <item> union </item>

       <item> volatile </item>

       <item> while </item>
       <item> with </item>
     </list>
     <list name="modules">
       <item> module </item>
       <item> import </item>
     </list>
     <list name="types">
       <item> void </item>
       <item> bool </item>
       <item> byte </item>
       <item> ubyte </item>
       <item> short </item>
       <item> ushort </item>
       <item> int </item>
       <item> uint </item>
       <item> long </item>
       <item> ulong </item>
       <item> cent </item>
       <item> ucent </item>
       <item> float </item>
       <item> double </item>
       <item> real </item>
       <item> ireal </item>
       <item> ifloat </item>
       <item> idouble </item>
       <item> creal </item>
       <item> cfloat </item>
       <item> cdouble </item>
       <item> char </item>
       <item> wchar </item>
       <item> dchar </item>
     </list>
     <list name="phobos">
       <item> printf </item>
       <item> writef </item>
     </list>

     <list name="linkage">
       <item> extern </item>
     </list>
     <list name="ltypes">
       <item> C </item>
       <item> D </item>
       <item> Windows </item>
       <item> Pascal </item>
     </list>

     <list name="debug">
       <item> debug </item>
     </list>
     <list name="assert">
       <item> assert </item>
     </list>

     <list name="pragma">
       <item> pragma </item>
     </list>
     <list name="ptypes">
       <item> msg </item>
       <item> lib </item>
     </list>

     <list name="version">
       <item> version </item>
     </list>
     <list name="vtypes">
       <item> DigitalMars </item>
       <item> X86 </item>
       <item> AMD64 </item>
       <item> Windows </item>
       <item> Win32 </item>
       <item> Win64 </item>
       <item> linux </item>
       <item> LittleEndian </item>
       <item> BigEndian </item>
       <item> D_InlineAsm </item>
       <item> none </item>
     </list>

     <list name="specialtokens">
       <item> __FILE__ </item>
       <item> __LINE__ </item>
       <item> __DATE__ </item>
       <item> __TIME__ </item>
       <item> __TIMESTAMP__ </item>
       <item> __VENDOR__ </item>
       <item> __VERSION__ </item>
     </list>

     <list name="unittest">
       <item> unittest </item>
     </list>

     <contexts>
       <context attribute="Normal Text" lineEndContext="#stay"  
name="normal">
         <keyword attribute="Keyword"        context="#stay"       
String="keywords"/>
         <keyword attribute="Module"         context="ModuleName"  
String="modules"/>
         <keyword attribute="Type"           context="#stay"       
String="types"/>
         <keyword attribute="Phobos Library" context="#stay"       
String="phobos"/>
         <keyword attribute="Linkage"        context="Linkage"     
String="linkage"/>
         <keyword attribute="Debug"          context="#stay"       
String="debug"/>
         <keyword attribute="Assert"         context="#stay"       
String="assert"/>
         <keyword attribute="Pragma"         context="Pragmas"     
String="pragma"/>
         <keyword attribute="Version"        context="Version"     
String="version"/>
         <keyword attribute="Unit Test"      context="#stay"       
String="unittest"/>
         <keyword attribute="SpecialTokens"  context="#stay"       
String="specialtokens"/>

         <!-- Scan r" or x" before scanning Normal Text -->
         <Detect2Chars attribute="RawString" context="RawString" char="r"  
char1="&quot;"/>
         <Detect2Chars attribute="HexString" context="HexString" char="x"  
char1="&quot;"/>
         <DetectIdentifier attribute="Normal Text"/>

         <HlCStringChar attribute="EscapeString" context="#pop"/>
         <Detect2Chars attribute="EscapeString" context="UnicodeShort"    
char="\" char1="u"/>
         <Detect2Chars attribute="EscapeString" context="UnicodeLong"    
char="\" char1="U"/>

         <DetectChar attribute="Char"     context="CharLiteral" char="'"/>
         <DetectChar attribute="String"   context="String"       
char="&quot;"/>
         <DetectChar attribute="BQString" context="BQString"    char="`"/>

         <Detect2Chars attribute="Comment" context="CommentLine"   char="/"  
char1="/"/>
         <Detect2Chars attribute="Comment" context="CommentBlock" char="/"  
char1="*" beginRegion="CommentBlock"/>
         <Detect2Chars attribute="Comment" context="CommentNested" char="/"  
char1="+" beginRegion="CommentNested"/>

         <DetectChar attribute="Normal Text" context="#stay" char="{"  
beginRegion="BraceA" />
         <DetectChar attribute="Normal Text" context="#stay" char="}"  
endRegion="BraceA" />
         <!-- Float -->
         <RegExpr attribute="Float" context="#pop"  
String="0[xX]_*[\da-fA-F_]*\.?[\da-fA-F_]*[pP][-+]?\d+[\d_]*[fFL]?i?"/>
         <RegExpr attribute="Float" context="#pop"  
String="\.\d[\d_]*([eE][-+]?\d[\d_]*)?[fFL]?i?"/>
         <RegExpr attribute="Float" context="#pop"  
String="\d[\d_]*[eE][-+]?\d[\d_]*[fFL]?i?"/>
         <RegExpr attribute="Float" context="#pop"  
String="\d[\d_]*\.[\d_]*([eE][-+]?\d[\d_]*)?[fFL]?i?"/>
         <RegExpr attribute="Float" context="#pop"  
String="\d[\d_]*([fFL]i?|[fFL]?i)"/>
         <!-- Binary|Octal|Hex|Integer -->
         <RegExpr attribute="Binary"  context="#pop"  
String="0[bB]_*[01][01_]*(L|[uU]|L[uU]|[uU]L)?"/>
         <RegExpr attribute="Octal"   context="#pop"  
String="0_*[0-7_]+(L|[uU]|L[uU]|[uU]L)?"/>
         <RegExpr attribute="Hex"     context="#pop"  
String="0[xX]_*[\da-fA-F][\da-fA-F_]*(L|[uU]|L[uU]|[uU]L)?"/>
         <RegExpr attribute="Integer" context="#pop"  
String="(0|\d+[\d_]*)(L|[uU]|L[uU]|[uU]L)?"/>

         <StringDetect attribute="Pragma" context="#pop" String="#line"/>
       </context>

       <!-- \u 4HexDigits -->
       <context attribute="EscapeString" context="#pop"  
lineEndContext="#pop" name="UnicodeShort">
         <RegExpr attribute="EscapeString" context="#pop"  
String="[\da-fA-F]{4}"/>
       </context>
       <!-- \U 8HexDigits -->
       <context attribute="EscapeString" context="#pop"  
lineEndContext="#pop" name="UnicodeLong">
         <RegExpr attribute="EscapeString" context="#pop"  
String="[\da-fA-F]{8}"/>
       </context>

       <context attribute="Module Name" lineEndContext="#stay"  
name="ModuleName">
         <DetectChar   attribute="Normal Text" context="#stay"          
char=","/>
         <DetectChar   attribute="Normal Text" context="#pop"           
char=";"/>
         <Detect2Chars attribute="Comment"     context="CommentLine"    
char="/" char1="/"/>
         <Detect2Chars attribute="Comment"     context="CommentBlock"  
char="/" char1="*" beginRegion="CommentBlock"/>
         <Detect2Chars attribute="Comment"     context="CommentNested"  
char="/" char1="+" beginRegion="CommentNested"/>
       </context>

       <context attribute="Linkage" lineEndContext="#pop" name="Linkage"  
fallthrough="true" fallthroughContext="#pop">
         <keyword    attribute="Type"         context="#pop"   
String="types"/>
         <DetectChar attribute="Normal Text"  context="#stay" char="("/>
         <keyword    attribute="Linkage Type" context="#pop"  
String="ltypes"/>
         <DetectIdentifier attribute="Error"  context="#pop"/>
       </context>
       <context attribute="Version" lineEndContext="#pop" name="Version">
         <DetectChar attribute="Normal Text"  context="#pop"  char="="/>
         <DetectChar attribute="Normal Text"  context="#stay" char="("/>
         <keyword    attribute="Version Type" context="#pop"  
String="vtypes"/>
         <DetectIdentifier attribute="Normal Text" context="#pop"/>
       </context>
       <context attribute="Pragma" lineEndContext="#pop" name="Pragmas">
         <DetectChar attribute="Normal Text"  context="#stay" char="("/>
         <keyword    attribute="Version Type" context="#pop"  
String="ptypes"/>
         <DetectIdentifier attribute="Normal Text" context="#pop"/>
       </context>
       <!-- r"..." -->
       <context attribute="RawString" lineEndContext="#stay"  
name="RawString">
         <DetectChar attribute="RawString" context="#pop" char="&quot;"/>
       </context>
       <!-- `...` -->
       <context attribute="BQString" lineEndContext="#stay" name="BQString">
         <DetectChar attribute="BQString" context="#pop" char="`"/>
       </context>
       <!-- x"..." -->
       <context attribute="HexString" lineEndContext="#stay"  
name="HexString">
         <DetectChar attribute="HexString" context="#pop" char="&quot;"/>
         <RegExpr attribute="Error" context="#stay" String="[^\t  
a-fA-F\d&quot;]+" />
       </context>
       <!-- '...' -->
       <context attribute="Char" lineEndContext="#pop" name="CharLiteral"  
fallthrough="true" fallthroughContext="#pop">
         <HlCStringChar attribute="EscapeSequence" context="#stay"/>
         <DetectChar    attribute="Char" context="#pop"  char="'"/>
         <RegExpr attribute="EscapeSequence" context="#stay"  
String="\\(u[\da-fA-F]{4}|U[\da-fA-F]{8})"/>
         <DetectChar   attribute="Char" context="#pop"  char="'"/>
         <RegExpr attribute="Char" context="#stay" String=".'"/>
       </context>
       <!-- "..." -->
       <context attribute="String" lineEndContext="#stay" name="String">
         <Detect2Chars attribute="String" context="#stay" char="\"  
char1="&quot;"/>
         <DetectChar attribute="String" context="#pop" char="&quot;"/>
         <HlCStringChar attribute="EscapeSequence"/>
         <RegExpr attribute="EscapeSequence" context="#stay"  
String="\\(u[\da-fA-F]{4}|U[\da-fA-F]{8})" />
       </context>

       <context attribute="Comment" lineEndContext="#pop"  
name="CommentLine"/>
       <context attribute="Comment" lineEndContext="#stay"  
name="CommentBlock">
         <Detect2Chars attribute="Comment" context="#pop" char="*"  
char1="/" endRegion="CommentBlock"/>
       </context>
       <context attribute="Comment" lineEndContext="#stay"  
name="CommentNested">
        <Detect2Chars attribute="Comment" context="CommentNested" char="/"  
char1="+" beginRegion="CommentNested"/>
        <Detect2Chars attribute="Comment" context="#pop" char="+" char1="/"  
endRegion="CommentNested"/>
       </context>
     </contexts>
     <itemDatas>
       <itemData name="Normal Text"    defStyleNum="dsNormal"/>
       <itemData name="Keyword"        defStyleNum="dsKeyword"/>
       <itemData name="Type"           defStyleNum="dsDataType"/>
       <itemData name="Integer"        defStyleNum="dsDecVal"/>
       <itemData name="Binary"         defStyleNum="dsBaseN"/>
       <itemData name="Octal"          defStyleNum="dsBaseN"/>
       <itemData name="Hex"            defStyleNum="dsBaseN"/>
       <itemData name="Float"          defStyleNum="dsFloat"/>

       <itemData name="SpecialTokens"  defStyleNum="dsNormal"    

       <itemData name="Module"         defStyleNum="dsKeyword"   

       <itemData name="Module Name"    defStyleNum="dsKeyword"   

       <itemData name="Phobos Library" defStyleNum="dsKeyword"   

       <itemData name="Linkage"        defStyleNum="dsKeyword"   
color="#ff0000" selColor="#ffffff"/>
       <itemData name="Linkage Type"   defStyleNum="dsDataType"  
color="#ff0000" selColor="#ffffff" bold="1" italic="1"/>
       <itemData name="Debug"          defStyleNum="dsKeyword"   
color="#ff00ff" selColor="#ffffff"/>
       <itemData name="Assert"         defStyleNum="dsKeyword"   

       <itemData name="Version"        defStyleNum="dsKeyword"   
color="#ff0000" selColor="#ffffff"/>
       <itemData name="Version Type"   defStyleNum="dsDataType"  
color="#ff0000" selColor="#ffffff" bold="1" italic="1"/>
       <itemData name="Unit Test"      defStyleNum="dsKeyword"   
color="#ff00ff" selColor="#ffffff" bold="1"/>
       <itemData name="Pragma"         defStyleNum="dsKeyword"   


       <itemData name="EscapeString"   defStyleNum="dsString"/>

       <itemData name="String"         defStyleNum="dsString"/>
       <itemData name="Char"           defStyleNum="dsChar"/>
       <itemData name="RawString"      defStyleNum="dsString"       
color="#a100a1" selColor="#ff00ff"/>
       <itemData name="BQString"       defStyleNum="dsString"     
color="#a100a1" selColor="#ff00ff"/>
       <itemData name="HexString"      defStyleNum="dsString"     
color="#a10022" selColor="#ff0055"/>

       <itemData name="Comment"        defStyleNum="dsComment"/>
       <itemData name="Error"          defStyleNum="dsError"/>
     </itemDatas>
   </highlighting>
   <general>
     <comments>
     <comment name="singleLine" start="//"/>
     <comment name="multiLine"  start="/*" end="*/" region="CommentBlock"/>
     <comment name="multiLine"  start="/+" end="+/" region="CommentNested"/>
     </comments>
     <keywords casesensitive="true"/>
   </general>
</language>
Jun 30 2007
parent Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= <jmjmak utu.fi.invalid> writes:
Aziz K. wrote:

 Hi!
 
 I've taken some time to improve the syntax highlighting xml file for Kate.
 
Well done :) I added some minor further improvements. The file should be available via the update service soon.
Jul 01 2007