Guest User

Untitled

a guest
Feb 26th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 11.24 KB | None | 0 0
  1. <?xml version="1.0"?>
  2. <SyntaxDefinition name="C#" extensions=".cs" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
  3.     <!-- The named colors 'Comment' and 'String' are used in SharpDevelop to detect if a line is inside a multiline string/comment -->
  4.     <Color name="Comment" foreground="Green" exampleText="// comment" />
  5.     <Color name="String" foreground="#A31515" exampleText="string text = &quot;Hello, World!&quot;"/>
  6.     <Color name="StringInterpolation" foreground="#A31515" exampleText="string text = $&quot;Hello, {name}!&quot;"/>
  7.     <Color name="Char" foreground="#A31515" exampleText="char linefeed = '\n';"/>
  8.     <Color name="Preprocessor" foreground="Green" exampleText="#region Title" />
  9.     <Color name="Punctuation" exampleText="a(b.c);" />
  10.     <Color name="ValueTypeKeywords" foreground="Blue" exampleText="bool b = true;" />
  11.     <Color name="ReferenceTypeKeywords" foreground="Blue" exampleText="object o;" />
  12.     <!-- <Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.ToString();"/> -->
  13.     <Color name="NumberLiteral" foreground="DarkBlue" exampleText="3.1415f"/>
  14.     <Color name="ThisOrBaseReference" foreground="Blue" exampleText="this.Do(); base.Do();"/>
  15.     <Color name="NullOrValueKeywords" foreground="Blue" exampleText="if (value == null)"/>
  16.     <Color name="Keywords" foreground="Blue" exampleText="if (a) {} else {}"/>
  17.     <Color name="GotoKeywords" foreground="Blue" exampleText="continue; return null;"/>
  18.     <Color name="ContextKeywords" foreground="Blue" exampleText="var a = from x in y select z;"/>
  19.     <Color name="ExceptionKeywords" foreground="Blue" exampleText="try {} catch {} finally {}"/>
  20.     <Color name="CheckedKeyword" fontWeight="bold" foreground="DarkGray" exampleText="checked {}"/>
  21.     <Color name="UnsafeKeywords" foreground="Olive" exampleText="unsafe { fixed (..) {} }"/>
  22.     <Color name="OperatorKeywords" fontWeight="bold" foreground="Pink" exampleText="public static implicit operator..."/>
  23.     <Color name="ParameterModifiers" foreground="Blue" exampleText="(ref int a, params int[] b)"/>
  24.     <Color name="Modifiers" foreground="Blue" exampleText="static readonly int a;"/>
  25.     <Color name="Visibility" foreground="Blue" exampleText="public override void ToString();"/>
  26.     <Color name="NamespaceKeywords" foreground="Blue" exampleText="namespace A.B { using System; }"/>
  27.     <Color name="GetSetAddRemove" foreground="Blue" exampleText="int Prop { get; set; }"/>
  28.     <Color name="TrueFalse" foreground="Blue" exampleText="b = false; a = true;" />
  29.     <Color name="TypeKeywords" foreground="Blue" exampleText="if (x is int) { a = x as int; type = typeof(int); size = sizeof(int); c = new object(); }"/>
  30.     <Color name="SemanticKeywords" foreground="Blue" exampleText="if (args == null) throw new ArgumentNullException(nameof(args));" />
  31.     <Color name="ClassName" foreground="#2B91B2" exampleText="class MyClass{}; MyClass a = new Namespace.MyClass();" />
  32.  
  33.     <Property name="DocCommentMarker" value="///" />
  34.    
  35.     <RuleSet name="CommentMarkerSet">
  36.         <Keywords fontWeight="bold" foreground="Red">
  37.             <Word>TODO</Word>
  38.             <Word>FIXME</Word>
  39.         </Keywords>
  40.         <Keywords fontWeight="bold" foreground="#E0E000">
  41.             <Word>HACK</Word>
  42.             <Word>UNDONE</Word>
  43.         </Keywords>
  44.     </RuleSet>
  45.    
  46.     <!-- This is the main ruleset. -->
  47.     <RuleSet>
  48.         <Span color="Preprocessor">
  49.             <Begin>\#</Begin>
  50.             <RuleSet name="PreprocessorSet">
  51.                 <Span> <!-- preprocessor directives that allows comments -->
  52.                     <Begin fontWeight="bold">
  53.                         (define|undef|if|elif|else|endif|line)\b
  54.                     </Begin>
  55.                     <RuleSet>
  56.                         <Span color="Comment" ruleSet="CommentMarkerSet">
  57.                             <Begin>//</Begin>
  58.                         </Span>
  59.                     </RuleSet>
  60.                 </Span>
  61.                 <Span> <!-- preprocessor directives that don't allow comments -->
  62.                     <Begin fontWeight="bold">
  63.                         (region|endregion|error|warning|pragma)\b
  64.                     </Begin>
  65.                 </Span>
  66.             </RuleSet>
  67.         </Span>
  68.        
  69.         <Span color="Comment">
  70.             <Begin color="XmlDoc/DocComment">///(?!/)</Begin>
  71.             <RuleSet>
  72.                 <Import ruleSet="XmlDoc/DocCommentSet"/>
  73.                 <Import ruleSet="CommentMarkerSet"/>
  74.             </RuleSet>
  75.         </Span>
  76.        
  77.         <Span color="Comment" ruleSet="CommentMarkerSet">
  78.             <Begin>//</Begin>
  79.         </Span>
  80.        
  81.         <Span color="Comment" ruleSet="CommentMarkerSet" multiline="true">
  82.             <Begin>/\*</Begin>
  83.             <End>\*/</End>
  84.         </Span>
  85.        
  86.         <Span color="String">
  87.             <Begin>"</Begin>
  88.             <End>"</End>
  89.             <RuleSet>
  90.                 <!-- span for escape sequences -->
  91.                 <Span begin="\\" end="."/>
  92.             </RuleSet>
  93.         </Span>
  94.        
  95.         <Span color="Char">
  96.             <Begin>'</Begin>
  97.             <End>'</End>
  98.             <RuleSet>
  99.                 <!-- span for escape sequences -->
  100.                 <Span begin="\\" end="."/>
  101.             </RuleSet>
  102.         </Span>
  103.        
  104.         <Span color="String" multiline="true">
  105.             <Begin>@"</Begin>
  106.             <End>"</End>
  107.             <RuleSet>
  108.                 <!-- span for escape sequences -->
  109.                 <Span begin='""' end=""/>
  110.             </RuleSet>
  111.         </Span>
  112.        
  113.         <Span color="String">
  114.             <Begin>\$"</Begin>
  115.             <End>"</End>
  116.             <RuleSet>
  117.                 <!-- span for escape sequences -->
  118.                 <Span begin="\\" end="."/>
  119.                 <Span begin="\{\{" end=""/>
  120.                 <!-- string interpolation -->
  121.                 <Span begin="{" end="}" color="StringInterpolation" ruleSet=""/>
  122.             </RuleSet>
  123.         </Span>
  124.        
  125.         <!-- don't highlight "@int" as keyword -->
  126.         <Rule>
  127.             @[\w\d_]+
  128.         </Rule>
  129.        
  130.         <Keywords color="ThisOrBaseReference">
  131.             <Word>this</Word>
  132.             <Word>base</Word>
  133.         </Keywords>
  134.        
  135.         <Keywords color="TypeKeywords">
  136.             <Word>as</Word>
  137.             <Word>is</Word>
  138.             <Word>new</Word>
  139.             <Word>sizeof</Word>
  140.             <Word>typeof</Word>
  141.             <Word>stackalloc</Word>
  142.         </Keywords>
  143.        
  144.         <Keywords color="TrueFalse">
  145.             <Word>true</Word>
  146.             <Word>false</Word>
  147.         </Keywords>
  148.        
  149.         <Keywords color="Keywords">
  150.             <Word>else</Word>
  151.             <Word>if</Word>
  152.             <Word>switch</Word>
  153.             <Word>case</Word>
  154.             <Word>default</Word>
  155.             <Word>do</Word>
  156.             <Word>for</Word>
  157.             <Word>foreach</Word>
  158.             <Word>in</Word>
  159.             <Word>while</Word>
  160.             <Word>lock</Word>
  161.         </Keywords>
  162.        
  163.         <Keywords color="GotoKeywords">
  164.             <Word>break</Word>
  165.             <Word>continue</Word>
  166.             <Word>goto</Word>
  167.             <Word>return</Word>
  168.         </Keywords>
  169.        
  170.         <Keywords color="ContextKeywords">
  171.             <Word>yield</Word>
  172.             <Word>partial</Word>
  173.             <Word>global</Word>
  174.             <Word>where</Word>
  175.             <Word>select</Word>
  176.             <Word>group</Word>
  177.             <Word>by</Word>
  178.             <Word>into</Word>
  179.             <Word>from</Word>
  180.             <Word>ascending</Word>
  181.             <Word>descending</Word>
  182.             <Word>orderby</Word>
  183.             <Word>let</Word>
  184.             <Word>join</Word>
  185.             <Word>on</Word>
  186.             <Word>equals</Word>
  187.             <Word>var</Word>
  188.             <Word>dynamic</Word>
  189.             <Word>await</Word>
  190.         </Keywords>
  191.        
  192.         <Keywords color="ExceptionKeywords">
  193.             <Word>try</Word>
  194.             <Word>throw</Word>
  195.             <Word>catch</Word>
  196.             <Word>finally</Word>
  197.         </Keywords>
  198.        
  199.         <Keywords color="CheckedKeyword">
  200.             <Word>checked</Word>
  201.             <Word>unchecked</Word>
  202.         </Keywords>
  203.        
  204.         <Keywords color="UnsafeKeywords">
  205.             <Word>fixed</Word>
  206.             <Word>unsafe</Word>
  207.         </Keywords>
  208.        
  209.         <Keywords color="ValueTypeKeywords">
  210.             <Word>bool</Word>
  211.             <Word>byte</Word>
  212.             <Word>char</Word>
  213.             <Word>decimal</Word>
  214.             <Word>double</Word>
  215.             <Word>enum</Word>
  216.             <Word>float</Word>
  217.             <Word>int</Word>
  218.             <Word>long</Word>
  219.             <Word>sbyte</Word>
  220.             <Word>short</Word>
  221.             <Word>struct</Word>
  222.             <Word>uint</Word>
  223.             <Word>ushort</Word>
  224.             <Word>ulong</Word>
  225.         </Keywords>
  226.        
  227.         <Keywords color="ReferenceTypeKeywords">
  228.             <Word>class</Word>
  229.             <Word>interface</Word>
  230.             <Word>delegate</Word>
  231.             <Word>object</Word>
  232.             <Word>string</Word>
  233.             <Word>void</Word>
  234.         </Keywords>
  235.        
  236.         <Keywords color="OperatorKeywords">
  237.             <Word>explicit</Word>
  238.             <Word>implicit</Word>
  239.             <Word>operator</Word>
  240.         </Keywords>
  241.        
  242.         <Keywords color="ParameterModifiers">
  243.             <Word>params</Word>
  244.             <Word>ref</Word>
  245.             <Word>out</Word>
  246.         </Keywords>
  247.        
  248.         <Keywords color="Modifiers">
  249.             <Word>abstract</Word>
  250.             <Word>const</Word>
  251.             <Word>event</Word>
  252.             <Word>extern</Word>
  253.             <Word>override</Word>
  254.             <Word>readonly</Word>
  255.             <Word>sealed</Word>
  256.             <Word>static</Word>
  257.             <Word>virtual</Word>
  258.             <Word>volatile</Word>
  259.             <Word>async</Word>
  260.         </Keywords>
  261.        
  262.         <Keywords color="Visibility">
  263.             <Word>public</Word>
  264.             <Word>protected</Word>
  265.             <Word>private</Word>
  266.             <Word>internal</Word>
  267.         </Keywords>
  268.        
  269.         <Keywords color="NamespaceKeywords">
  270.             <Word>namespace</Word>
  271.             <Word>using</Word>
  272.         </Keywords>
  273.        
  274.         <Keywords color="GetSetAddRemove">
  275.             <Word>get</Word>
  276.             <Word>set</Word>
  277.             <Word>add</Word>
  278.             <Word>remove</Word>
  279.         </Keywords>
  280.        
  281.         <Keywords color="NullOrValueKeywords">
  282.             <Word>null</Word>
  283.             <Word>value</Word>
  284.         </Keywords>
  285.  
  286.         <Keywords color="SemanticKeywords">
  287.             <Word>nameof</Word>
  288.         </Keywords>
  289.        
  290.         <!-- Mark previous rule-->
  291.         <!--<Rule color="MethodCall">
  292.         \b
  293.         [\d\w_]+  # an identifier
  294.         (?=\s*\() # followed by (
  295.         </Rule>-->
  296.                
  297.         <!-- The type name in the type definition -->
  298.         <Rule color="ClassName">
  299.             (?&lt;=class|interface|enum)\s+([\d\w_]*)
  300.         </Rule>
  301.        
  302.         <!-- The type inheritions or implementations -->
  303.         <Rule color="ClassName">
  304.             (?&lt;=(class|interface)\s+[\d\w_]*\s*\:[\d\w_\,\s|.]*)
  305.             [\d\w_]+
  306.             (?=\s*($|\,|\{))
  307.         </Rule>
  308.  
  309.         <!-- The type parameters of a generic class: List<MyClass> -->
  310.         <Rule color="ClassName">
  311.             (?&lt;=&lt;[\d\w_\,\.\s&lt;&gt;]*)  #starts with &lt;
  312.             [\d\w_]+
  313.             (?=(\[\])?(&gt;|\s*\,[\s\.\d\w\,\[\]&lt;&gt;]*&gt;))        #ends with &gt;
  314.         </Rule>
  315.        
  316.         <!-- The class name of generic class example: Dictionary<string,bool> -->
  317.         <Rule color="ClassName">
  318.             \b
  319.             [\d\w_]+                            # the class name
  320.             (?=&lt;[\d\w_\,\.\s&lt;&gt;]+&gt;)  # followed by something between &lt; and &gt;
  321.         </Rule>
  322.        
  323.         <!-- The class name in any variable or property declaration, or function -->
  324.         <Rule color="ClassName">
  325.             \b
  326.             [\d\w_]+            # the class name
  327.             (?=(\s*\[[0-9]*\])?\s+[\d\w_]+(
  328.                                             \s*\=   # variable assignment
  329.                                             |
  330.                                             \;      # variable declaration
  331.                                             |
  332.                                             \s*\(   # open parethese, for return type of function
  333.                                             |
  334.                                             \s*\{   # open bracket, for properties
  335.                                             |
  336.                                             \s*$))  # end of line without anything, normaly in properties where open bracket is in the next line
  337.         </Rule>
  338.        
  339.         <!-- The class name in a cast example: (MyClass) a -->
  340.         <Rule color="ClassName">
  341.             \b
  342.             (?&lt;=\()          # starts with open parenthese
  343.             \s*
  344.             [\d\w_]+            # the class name
  345.             \s*
  346.             (?=\)\s*[\d\w_]+)   # ends with close parenthese followed by an identifier
  347.         </Rule>
  348.        
  349.         <!-- The class name of a method parameter example: (ref MyClass a, params MyClass[] b, MyClass c) -->
  350.         <Rule color="ClassName">
  351.             \b
  352.             [\d\w_]+
  353.             \s+
  354.             (?=[\d\w_]+\s*[\,\)]+)
  355.         </Rule>
  356.        
  357.         <!-- The class name in new instance -->
  358.         <Rule color="ClassName">
  359.             \b
  360.             (?&lt;=new\s+[\d\w_\.]*)
  361.             [\d\w_]+
  362.             (?=(\s*\[[0-9]*\])?(
  363.                 \s*\(   # open parethese, for constructor parameters
  364.                 |
  365.                 \s*\{   # open bracket, for properties
  366.                 |
  367.                 \s*$))  # end of line, for properties in next line
  368.         </Rule>
  369.        
  370.         <!-- Digits -->
  371.         <Rule color="NumberLiteral">
  372.             \b0[xX][0-9a-fA-F]+  # hex number
  373.         |  
  374.             (   \b\d+(\.[0-9]+)?   #number with optional floating point
  375.             |   \.[0-9]+           #or just starting with floating point
  376.             )
  377.             ([eE][+-]?[0-9]+)? # optional exponent
  378.         </Rule>
  379.        
  380.         <Rule color="Punctuation">
  381.             [?,.;()\[\]{}+\-/%*&lt;&gt;^+~!|&amp;]+
  382.         </Rule>
  383.     </RuleSet>
  384. </SyntaxDefinition>
Advertisement
Add Comment
Please, Sign In to add comment