Skip to content

Instantly share code, notes, and snippets.

@dk949
Last active January 10, 2024 20:02
Show Gist options
  • Save dk949/60b2f575164e0fb1818bda90c3d7e00b to your computer and use it in GitHub Desktop.
Save dk949/60b2f575164e0fb1818bda90c3d7e00b to your computer and use it in GitHub Desktop.
KDE synatx highlighting file for pseudocode. Supports some commonly used pseudocode keywords, as well as structured english descriptions surrounded by double chevrons.
<!--
KDE synatx highlighting file for pseudocode (https://github.com/KDE/syntax-highlighting)
Based on the Zig highlighting file (https://raw.githubusercontent.com/KDE/syntax-highlighting/master/data/syntax/zig.xml).
Intended for use with pandoc, but will probably work with kate too
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language [
<!ENTITY bin_int "(?:[01]+(?:_[01]+)*)">
<!ENTITY oct_int "(?:[0-7]+(?:_[0-7]+)*)">
<!ENTITY dec_int "(?:[0-9]+(?:_[0-9]+)*)">
<!ENTITY hex_int "(?:[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)">
<!ENTITY exp_float "(?:[eE][+-]?&dec_int;)">
<!ENTITY exp_hexfloat "(?:[pP][-+]?&dec_int;)">
]>
<language name="Pseudocode" section="Sources" version="1" kateversion="5.62" indenter="cstyle" extensions="*.p" mimetype="text/x-pseudocode" priority="1" author="Davids Kacs" license="MIT">
<highlighting>
<list name="keywords">
<item>FUNCTION</item>
<item>STRUCT</item>
<item>ENUM</item>
<item>AND</item>
<item>OR</item>
<item>DO</item>
<item>END</item>
</list>
<list name="controlflow">
<item>WHILE</item>
<item>FOREACH</item>
<item>IN</item>
<item>BREAK</item>
<item>CONTINUE</item>
<item>IF</item>
<item>THEN</item>
<item>ELSE</item>
<item>IS</item>
<item>NOT</item>
<item>RETURN</item>
</list>
<list name="literals">
<item>FALSE</item>
<item>NULL</item>
<item>TRUE</item>
<item>UNDEFINED</item>
</list>
<contexts>
<context attribute="Normal Text" lineEndContext="#stay" name="Normal">
<DetectSpaces/>
<Detect2Chars char="/" char1="/" attribute="Comment" context="Comment"/>
<AnyChar attribute="Symbol" context="#stay" String=":!%&amp;+,-/.*=?|~^"/>
<AnyChar context="Number" String="0123456789" lookAhead="1"/>
<DetectChar attribute="String" context="DoubleQuoteString" char="&quot;"/>
<Detect2Chars attribute="String" context="AngleKW" char="&lt;" char1="&lt;"/>
<DetectChar attribute="Character" context="SingleQuoteString" char="'"/>
<Detect2Chars char="\" char1="\" attribute="String" context="Multiline String"/>
<keyword String="keywords" attribute="Keyword" context="#stay"/>
<keyword attribute="Constant" context="#stay" String="literals"/>
<keyword attribute="Control Flow" context="#stay" String="controlflow"/>
<WordDetect attribute="Self Variable" String="self"/>
<!-- <AnyChar context="SpecialType" String="iu" lookAhead="1"/> -->
<DetectIdentifier/>
</context>
<context attribute="String" lineEndContext="#pop" name="AngleKW">
<Detect2Chars attribute="String" context="#pop" char="&gt;" char1="&gt;"/>
</context>
<!-- Strings -->
<context attribute="String" lineEndContext="#pop" name="DoubleQuoteString">
<DetectChar context="EscapeChar" char="\" lookAhead="1"/>
<DetectChar attribute="String" context="#pop" char="&quot;"/>
</context>
<context attribute="Character" lineEndContext="#pop" name="SingleQuoteString">
<DetectChar context="EscapeChar" char="\" lookAhead="1"/>
<DetectChar attribute="Character" context="#pop" char="'"/>
</context>
<context attribute="String" lineEndContext="#pop" name="Multiline String"/>
<context attribute="String Char" lineEndContext="#pop" name="EscapeChar">
<RegExpr attribute="String Char" context="#pop" String="\\([nrt'&quot;\\]|x[0-9a-fA-F]{2}|u\{[0-9a-fA-F]+\})"/>
<RegExpr attribute="Error" context="#pop" String="\\(x[0-9a-fA-F]?|u\{[0-9a-fA-F]{0,8}\}?)?"/>
</context>
<!-- Comment -->
<context attribute="Comment" lineEndContext="#pop" name="Comment">
<DetectSpaces attribute="Comment"/>
<IncludeRules context="##Comments"/>
<DetectIdentifier attribute="Comment"/>
</context>
<!-- Integer / Float -->
<context name="Number" attribute="Normal Text" lineEndContext="#pop">
<RegExpr attribute="Float" context="#pop!SuffixNumber" String="&dec_int;(\.&dec_int;&exp_float;?|&exp_float;)"/>
<RegExpr attribute="Decimal" context="#pop!SuffixNumber" String="0(?=[^xob]|$)|(?=0[xob])|&dec_int;"/>
<RegExpr attribute="Hex Float" context="#pop!SuffixNumber" String="0x&hex_int;(\.&hex_int;&exp_hexfloat;?|&exp_hexfloat;)"/>
<RegExpr attribute="Hex" context="#pop!SuffixNumber" String="0x&hex_int;"/>
<RegExpr attribute="Octal" context="#pop!SuffixNumber" String="0o&oct_int;"/>
<RegExpr attribute="Binary" context="#pop!SuffixNumber" String="0b&bin_int;"/>
<DetectChar attribute="Decimal" context="#pop!SuffixNumber" char="0"/>
</context>
<context name="SuffixNumber" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
<AnyChar attribute="Error" String=".0123456789" context="#pop"/>
<DetectIdentifier attribute="Error" context="#pop"/>
</context>
<!-- Integer type -->
<!-- i or u followed by digits. The maximum allowed bit-width of an integer type is 65535 -->
<!--<context name="SpecialType" attribute="Normal Text" lineEndContext="#pop">
<RegExpr attribute="Type" context="#pop" String="\b[ui]([0-9]{1,4}|[1-5][0-9]{4}|6([0-4][0-9]{3}|5([0-4][0-9]{2}|5([0-2][0-9]|3[0-5]))))\b"/>
<DetectIdentifier attribute="Normal Text" context="#pop"/>
</context>-->
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal"/>
<itemData name="Self Variable" defStyleNum="dsVariable" spellChecking="false"/>
<itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
<itemData name="Type" defStyleNum="dsDataType" spellChecking="false"/>
<itemData name="Builtin Functions" defStyleNum="dsBuiltIn" spellChecking="false"/>
<itemData name="Constant" defStyleNum="dsConstant" spellChecking="false"/>
<itemData name="Control Flow" defStyleNum="dsControlFlow" spellChecking="false"/>
<itemData name="Modifiers" defStyleNum="dsAttribute" spellChecking="false"/>
<itemData name="Comment" defStyleNum="dsComment" spellChecking="true"/>
<itemData name="Binary" defStyleNum="dsBaseN" spellChecking="false"/>
<itemData name="Octal" defStyleNum="dsBaseN" spellChecking="false"/>
<itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false"/>
<itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false"/>
<itemData name="Float" defStyleNum="dsFloat" spellChecking="false"/>
<itemData name="Hex Float" defStyleNum="dsFloat" spellChecking="false"/>
<itemData name="String" defStyleNum="dsString"/>
<itemData name="String Char" defStyleNum="dsSpecialChar"/>
<itemData name="Character" defStyleNum="dsChar" spellChecking="false"/>
<itemData name="Symbol" defStyleNum="dsOperator" spellChecking="false"/>
<itemData name="Error" defStyleNum="dsError" spellChecking="false"/>
</itemDatas>
</highlighting>
<general>
<comments>
<comment name="singleLine" start="//"/>
</comments>
<keywords casesensitive="true"/>
</general>
</language>
<!--
Copyright 2023 Waqar Ahmed
Copyright 2023 Jonathan Poelen
Copyright 2023 Christoph Cullmann
Copyright 2023-2024 David K
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<!-- kate: replace-tabs on; tab-width 4; indent-width 4; -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment