Warning, /frameworks/syntax-highlighting/data/syntax/matlab.xml is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="UTF-8"?> 0002 <!-- 0003 ==================================================================== 0004 MATLAB syntax highlighting file for the KDE editors Kate and Kwrite 0005 ==================================================================== 0006 works (at least) for MATLAB versions 5.3, 6.0, 6.1, 6.5, 6.5sp1 0007 works with Kate 2.2 and with Kwrite 4.2 (KDE 3.2) 0008 0009 This file works only for syntactically correct MATLAB code. For incorrect 0010 code, the behaviour is undefined. One exception is made: Incomplete strings 0011 with missing closing delimiter are highlighted separately, just as in the 0012 native editor of MATLAB does. 0013 0014 Highlighting errors never propagate across line breaks. 0015 0016 Most of this XML file is straight and simple. Only the character ' (') 0017 needs nontrivial treatment, since it is both a postfix operator indicating 0018 complex conjugate transpose (adjoint) and a string delimiter. It is an 0019 adjoint operator in the following positions: 0020 1) immediately after an identifier (variable, function, but not keyword) 0021 2) immediately after a number literal 0022 3) immediately after the closing parenthesis ), ] and } 0023 4) immediately after a simple transpose operator .' 0024 5) immediately after another adjoint operator ' 0025 In all other cases it is a string delimiter. 0026 0027 This is implemented using look-ahead regexps. If one of the entities in the 0028 above cases 1-4 (identifier, number literal, ...) matches and look-ahead 0029 shows that it is followed by a ', the entity is highlighted and control is 0030 passed to the special context _adjoint, whose sole purpose is to correctly 0031 highlight a series of ' (thus covering case 5 as well). _adjoint immediately 0032 returns to the default context _normal. 0033 0034 MATLAB number literals are different from those in C and similar languages: 0035 a) All numbers literals are doubles. There is no distinction between float and int. 0036 b) There is no notation of hex or oct base integers. 0037 c) The symbols i or j may be attached to a number to indicate a multiplication 0038 with the imaginary unit. 0039 0040 MATLAB identifiers have to start with a letter followed by any number of letters, 0041 digits and underscores. 0042 0043 There is a small number of reserved keywords, which cannot be the target of an 0044 assignment. All other identifiers (including all of the many 100s of MATLAB commands) 0045 can be redefined. Consequently, only the reserved keywords are highlighted. 0046 0047 At the end of the XML file, there is MATLAB testing code for developers. 0048 0049 Change log: 0050 19-Nov-03 Created from scratch. 0051 08-Mar-04 Small corrections. Added default colors of MATLAB editor. 0052 25-Jan-09 Addedd basic support for OOP (Matlab 2008) (by Leonardo Finetti) 0053 0054 Author: Stefan Stoll, Swiss Federal Institute of Technology, Zurich 0055 Co-author: Leonardo Finetti, www.finex.org 0056 --> 0057 0058 <!DOCTYPE language> 0059 <!-- low priority to let Objective-C win for .m files per default --> 0060 <language name="Matlab" version="8" kateversion="5.0" section="Scientific" extensions="*.m;*.M" priority="-9" mimetype="text/mfile" casesensitive="1"> 0061 <highlighting> 0062 0063 <!-- Reserved keywords in MATLAB --> 0064 <list name="KeywordsList"> 0065 <item>break</item> 0066 <item>case</item> 0067 <item>catch</item> 0068 <item>classdef</item> 0069 <item>continue</item> 0070 <item>else</item> 0071 <item>elseif</item> 0072 <item>end</item> 0073 <item>for</item> 0074 <item>function</item> 0075 <item>global</item> 0076 <item>if</item> 0077 <item>otherwise</item> 0078 <item>parfor</item> 0079 <item>persistent</item> 0080 <item>return</item> 0081 <item>spmd</item> 0082 <item>switch</item> 0083 <item>try</item> 0084 <item>while</item> 0085 <item>methods</item> 0086 <item>properties</item> 0087 <item>events</item> 0088 </list> 0089 0090 <contexts> 0091 0092 <context name="_normal" attribute="Normal Text" lineEndContext="#stay"> 0093 0094 <!-- Look-ahead for adjoint ' after variable, number literal, closing braces and .' --> 0095 <RegExpr context="_adjoint" attribute="Variable" String="[a-zA-Z]\w*(?=')" /> 0096 <RegExpr context="_adjoint" attribute="Number" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?[ij]?(?=')" /> 0097 <RegExpr context="_adjoint" attribute="Delimiter" String="[\)\]}](?=')" /> 0098 <RegExpr context="_adjoint" attribute="Operator" String="\.'(?=')" /> 0099 0100 <!-- If ' is not the adjoint operator, it starts a string or an unterminated string --> 0101 <RegExpr context="#stay" attribute="CharVector" String="'[^']*(''[^']*)*'(?=[^']|$)" /> 0102 <RegExpr context="#stay" attribute="Incomplete CharVector" String="'[^']*(''[^']*)*" /> 0103 <RegExpr context="#stay" attribute="String" String=""[^"]*(""[^"]*)*"(?=[^"]|$)" /> 0104 <RegExpr context="#stay" attribute="Incomplete String" String=""[^"]*(""[^"]*)*" /> 0105 0106 <!-- Handling of keywords, comments, system commands, identifiers, numbers and braces --> 0107 <keyword context="#stay" attribute="Keyword" String="KeywordsList" /> 0108 <DetectChar context="Comment" attribute="Comment" char="%" /> 0109 <DetectChar context="System" attribute="System" char="!" /> 0110 <RegExpr context="#stay" attribute="Variable" String="[a-zA-Z]\w*" /> 0111 <RegExpr context="#stay" attribute="Number" String="(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?[ij]?" /> 0112 <AnyChar context="#stay" attribute="Delimiter" String="()[]{}"/> 0113 0114 <!-- Three and two-character operators --> 0115 <StringDetect context="#stay" attribute="Operator" String="..."/> 0116 <Detect2Chars context="#stay" attribute="Operator" char="=" char1="="/> 0117 <Detect2Chars context="#stay" attribute="Operator" char="~" char1="="/> 0118 <Detect2Chars context="#stay" attribute="Operator" char="<" char1="="/> 0119 <Detect2Chars context="#stay" attribute="Operator" char=">" char1="="/> 0120 <Detect2Chars context="#stay" attribute="Operator" char="&" char1="&"/> 0121 <Detect2Chars context="#stay" attribute="Operator" char="|" char1="|"/> 0122 <Detect2Chars context="#stay" attribute="Operator" char="." char1="*"/> 0123 <Detect2Chars context="#stay" attribute="Operator" char="." char1="^"/> 0124 <Detect2Chars context="#stay" attribute="Operator" char="." char1="/"/> 0125 <Detect2Chars context="#stay" attribute="Operator" char="." char1="'"/> 0126 0127 <!-- Single-character operators --> 0128 <AnyChar context="#stay" attribute="Operator" String="*+-/\&|<>~^=,;:@"/> 0129 0130 </context> 0131 0132 <!-- Context entered after encountering an ' adjoint operator --> 0133 <context name="_adjoint" attribute="Operator" lineEndContext="#pop"> 0134 <RegExpr context="#pop" attribute="Operator" String="'+" /> 0135 </context> 0136 0137 <context name="Comment" attribute="Comment" lineEndContext="#pop"> 0138 <DetectSpaces /> 0139 <IncludeRules context="##Comments"/> 0140 </context> 0141 0142 <context name="System" attribute="System" lineEndContext="#pop"/> 0143 0144 </contexts> 0145 0146 <itemDatas> 0147 <itemData name="Normal Text" defStyleNum="dsNormal" /> 0148 <itemData name="Variable" defStyleNum="dsVariable" /> 0149 <itemData name="Operator" defStyleNum="dsOperator"/> 0150 <itemData name="Number" defStyleNum="dsFloat" /> 0151 <itemData name="Delimiter" defStyleNum="dsNormal" /> 0152 <itemData name="CharVector" defStyleNum="dsSpecialString" /> 0153 <itemData name="String" defStyleNum="dsString" /> 0154 <itemData name="System" defStyleNum="dsBaseN" /> 0155 <itemData name="Incomplete CharVector" defStyleNum="dsError" /> 0156 <itemData name="Incomplete String" defStyleNum="dsError" /> 0157 <itemData name="Keyword" defStyleNum="dsKeyword" /> 0158 <itemData name="Comment" defStyleNum="dsComment" /> 0159 </itemDatas> 0160 0161 </highlighting> 0162 0163 <general> 0164 <comments> 0165 <comment name="singleLine" start="%" /> 0166 </comments> 0167 <keywords casesensitive="1" weakDeliminator=""/> 0168 </general> 0169 0170 </language> 0171 <!-- kate: replace-tabs on; tab-width 2; indent-width 2; -->