Skip to content

Commit

Permalink
Implement AssEmbly syntax highlighting in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed Jun 23, 2024
1 parent 18d0969 commit 84208f1
Show file tree
Hide file tree
Showing 6 changed files with 488 additions and 149 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ jobs:
run: |
mkdir ./Documentation/ReferenceManual/Build
pandoc -s ./Documentation/ReferenceManual/ReferenceManual.md \
--highlight-style=breezedark \
--highlight-style=./Documentation/ReferenceManual/pandoc.theme \
--syntax-definition=./Documentation/ReferenceManual/AssEmblySyntax.xml \
--toc --toc-depth=6 \
--css=./Documentation/ReferenceManual/ReferenceManual.css --embed-resource \
-H ./Documentation/ReferenceManual/ReferenceManual.HtmlHeader.html \
Expand Down
108 changes: 108 additions & 0 deletions Documentation/ReferenceManual/AssEmblySyntax.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<language name="AssEmbly" version="1.0" kateversion="5.1" section="Sources" extensions="*.asm">
<highlighting>
<contexts>
<context name="Normal" attribute="Normal Text">
<IncludeRules context="Keywords"/>
<IncludeRules context="Literals"/>
<IncludeRules context="Labels"/>
<IncludeRules context="Variables"/>
<IncludeRules context="Registers"/>
<IncludeRules context="Parameters"/>
<IncludeRules context="Special"/>
<IncludeRules context="Strings"/>
<IncludeRules context="CharLiterals"/>
<IncludeRules context="Comments"/>
</context>

<context name="Keywords" attribute="Mnemonic">
<RegExpr attribute="Mnemonic" context="#stay" insensitive="true" String="^\s*!?\s*(?:HLT|NOP|JMP|JEQ|JZO|JNE|JNZ|JLT|JCA|JLE|JGT|JGE|JNC|ADD|ICR|SUB|DCR|MUL|DIV|DVR|REM|SHL|SHR|AND|ORR|XOR|NOT|RNG|TST|CMP|MVB|MVW|MVD|MVQ|PSH|POP|CAL|RET|WCN|WCB|WCX|WCC|WFN|WFB|WFX|WFC|OFL|CFL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RIDE|STOP|REPEAT|ENDREPEAT|ASM_ONCE|DEFINE|UNDEFINE|VAROP|IF|ELSE|ELSE_IF|ENDIF|WHILE|ENDWHILE)"/>
</context>

<context name="Labels" attribute="LabelReference">
<RegExpr attribute="LabelDefinition" context="#stay" insensitive="true" String="^\s*!?\s*:[A-Za-z_][A-Za-z0-9_]*"/>
<RegExpr attribute="LabelLiteral" context="#stay" insensitive="true" String=":&amp;[A-Za-z_][A-Za-z0-9_]*"/>
<RegExpr attribute="LabelReference" context="#stay" insensitive="true" String=":[A-Za-z_][A-Za-z0-9_]*"/>
</context>

<context name="Literals" attribute="NumericLiteral">
<RegExpr attribute="NumericLiteral" context="#stay" insensitive="true" String="-?0b[0-1_]+"/>
<RegExpr attribute="NumericLiteral" context="#stay" insensitive="true" String="-?0x[0-9a-fA-F_]+"/>
<RegExpr attribute="NumericLiteral" context="#stay" insensitive="true" String="[\-0-9._][0-9_.]*"/>
<RegExpr attribute="NumericLiteral" context="#stay" insensitive="true" String=":0x[0-9a-fA-F_]+"/>
<RegExpr attribute="NumericLiteral" context="#stay" insensitive="true" String=":0b[0-1_]+"/>
<RegExpr attribute="NumericLiteral" context="#stay" insensitive="true" String=":[0-9_]+"/>
</context>

<context name="Variables" attribute="AssemblerVariable">
<RegExpr attribute="AssemblerConstant" context="#stay" insensitive="true" String="@![A-Za-z0-9_]+"/>
<RegExpr attribute="AssemblerVariable" context="#stay" insensitive="true" String="@[A-Za-z0-9_]+"/>
<RegExpr attribute="PreDefinedMacro" context="#stay" String="#(?:FILE_PATH|FILE_NAME|FOLDER_PATH)"/>
</context>

<context name="Registers" attribute="Register">
<RegExpr attribute="Pointer" context="#stay" insensitive="true" String="[QqDdWwBb]?\*(?:rpo|rso|rsb|rsf|rrv|rfp|rg0|rg1|rg2|rg3|rg4|rg5|rg6|rg7|rg8|rg9)"/>
<RegExpr attribute="Register" context="#stay" insensitive="true" String="(?:rpo|rso|rsb|rsf|rrv|rfp|rg0|rg1|rg2|rg3|rg4|rg5|rg6|rg7|rg8|rg9)"/>
</context>

<context name="Parameters" attribute="MacroParameter">
<RegExpr attribute="MacroParameter" context="#stay" insensitive="true" String="\$[0-9]+!?"/>
</context>

<context name="Special" attribute="SpecialOperand">
<RegExpr attribute="SpecialOperand" context="#stay" insensitive="true" String="(?:DEF|NDEF|EQ|NEQ|GT|GTE|LT|LTE)"/>
<RegExpr attribute="SpecialOperand" context="#stay" insensitive="true" String="(?:ADD|SUB|MUL|DIV|REM|BIT_AND|BIT_OR|BIT_XOR|BIT_NOT|AND|OR|XOR|NOT|SHL|SHR|CMP_EQ|CMP_NEQ|CMP_GT|CMP_GTE|CMP_LT|CMP_LTE)"/>
<RegExpr attribute="SpecialOperand" context="#stay" insensitive="true" String="(?:error|warning|suggestion)"/>
</context>

<context name="Strings" attribute="QuotedLiteral">
<StringDetect attribute="QuotedLiteral" context="String" String="&quot;"/>
</context>

<context name="String" attribute="QuotedLiteral">
<DetectChar attribute="QuotedLiteral" char="&quot;" context="#pop"/>
<IncludeRules context="EscapeSequence"/>
<IncludeRules context="Variables"/>
</context>

<context name="CharLiterals" attribute="QuotedLiteral">
<StringDetect attribute="QuotedLiteral" context="CharLiteral" String="'"/>
</context>

<context name="CharLiteral" attribute="QuotedLiteral">
<DetectChar attribute="QuotedLiteral" char="'" context="#pop"/>
<IncludeRules context="EscapeSequence"/>
<IncludeRules context="Variables"/>
</context>

<context name="Comments" attribute="Comment">
<RegExpr attribute="Comment" context="#stay" String=";.*"/>
</context>

<context name="EscapeSequence" attribute="EscapeSequence">
<RegExpr attribute="EscapeSequence" context="#stay" String="\\(?:&quot;|'|\\|@|0|a|b|f|n|r|t|v|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"/>
</context>

</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" color="#D4D4D4"/>
<itemData name="Mnemonic" defStyleNum="dsKeyword" color="#C586C0"/>
<itemData name="Directive" defStyleNum="dsPreprocessor" color="#569CD6"/>
<itemData name="NumericLiteral" defStyleNum="dsDecVal" color="#B5CEA8"/>
<itemData name="LabelDefinition" defStyleNum="dsPreprocessor" color="#569CD6"/>
<itemData name="LabelReference" defStyleNum="dsVariable" color="#9CDCFE"/>
<itemData name="LabelLiteral" defStyleNum="dsBuiltIn" color="#4EC9B0"/>
<itemData name="AssemblerVariable" defStyleNum="dsVariable" color="#9CDCFE"/>
<itemData name="AssemblerConstant" defStyleNum="dsPreprocessor" color="#569CD6"/>
<itemData name="PreDefinedMacro" defStyleNum="dsPreprocessor" color="#569CD6"/>
<itemData name="Pointer" defStyleNum="dsBuiltIn" color="#4EC9B0"/>
<itemData name="Register" defStyleNum="dsFunction" color="#DCDCAA"/>
<itemData name="MacroParameter" defStyleNum="dsVariable" color="#9CDCFE"/>
<itemData name="SpecialOperand" defStyleNum="dsFunction" color="#DCDCAA"/>
<itemData name="QuotedLiteral" defStyleNum="dsString" color="#CE9178"/>
<itemData name="EscapeSequence" defStyleNum="dsSpecialChar" color="#D7BA7D"/>
<itemData name="Comment" defStyleNum="dsComment" color="#6A9955"/>
</itemDatas>
</highlighting>
</language>
5 changes: 5 additions & 0 deletions Documentation/ReferenceManual/ReferenceManual.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ td {
col {
width: auto !important;
}

div.sourceCode {
padding: 10px;
border-radius: 5px;
}
Loading

0 comments on commit 84208f1

Please sign in to comment.