Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
Last active September 15, 2021 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlidstrom/2d16f2881ab9c0cfd571cb77b145f80e to your computer and use it in GitHub Desktop.
Save dlidstrom/2d16f2881ab9c0cfd571cb77b145f80e to your computer and use it in GitHub Desktop.
SystemRPL/RPL/AssemblyLanguage syntax highlighting
{
"name": "rpl",
"version": "0.0.1",
"engines": {
"vscode": ">=0.9.0-pre.1"
},
"publisher": "me",
"contributes": {
"languages": [{
"id": "rpl",
"aliases": ["RPL", "SysRPL"],
"extensions": [".a", ".s", ".srpl",".rpl"]
}],
"grammars": [{
"language": "rpl",
"scopeName": "source.rpl",
"path": "./syntaxes/rpl.plist"
}]
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0" >
<!-- Generated via Iro -->
<dict>
<key>fileTypes</key>
<array>
<string>a</string>
<string>s</string>
<string>rpl</string>
<string>srpl</string>
</array>
<key>name</key>
<string>rpl</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#main</string>
</dict>
</array>
<key>scopeName</key>
<string>source.rpl</string>
<key>uuid</key>
<string></string>
<key>repository</key>
<dict>
<key>main</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#rpl_multi_line_comment</string>
</dict>
<dict>
<key>include</key>
<string>#numeric</string>
</dict>
<dict>
<key>include</key>
<string>#rpl_block</string>
</dict>
<dict>
<key>include</key>
<string>#assemble_block</string>
</dict>
<dict>
<key>include</key>
<string>#code_block</string>
</dict>
<dict>
<key>include</key>
<string>#define</string>
</dict>
<dict>
<key>match</key>
<string>(\b[a-zA-Z_\x{0023}\x{003d}\.]+[a-zA-Z0-9]*)</string>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<dict>
<key>begin</key>
<string>(\()</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.rpl</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#main__1</string>
</dict>
</array>
<key>end</key>
<string>(\))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.rpl</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(;)</string>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
<dict>
<key>match</key>
<string>([^\s])</string>
<key>name</key>
<string>invalid.rpl</string>
</dict>
</array>
</dict>
<key>assemble_block</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(^ASSEMBLE)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#assemble_block__1</string>
</dict>
</array>
<key>end</key>
<string>(^RPL)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>assemble_block__1</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#assembly</string>
</dict>
</array>
</dict>
<key>assembly</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#rpl_multi_line_comment</string>
</dict>
<dict>
<key>match</key>
<string>(^[^\s]+)(\s+)([^\s]+)(\s+)([^\s]+)(\s+)(.*$)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>7</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(^[^\s]+)(\s+)([^\s]+)(\s+)([^\s]+)(.*)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(\s+)([^\s]+)(\s+)([^\s]+)(.*)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(\s+)([^\s]+)([^\s]+)(.*)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>code_block</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(^\s*CODE\s*)(.*)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#code_block__1</string>
</dict>
</array>
<key>end</key>
<string>(^\s*ENDCODE\s*)(.*)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>code_block__1</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#assembly</string>
</dict>
</array>
</dict>
<key>code_word</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>([0-9A-Za-z\x{0026}\x{0023}\x{003f}\x{003c}\x{003e}\x{0040}\x{0021}\-\x{002f}\x{003a}\x{0027}\x{003d}\x{0024}\*_]+)</string>
<key>name</key>
<string>keyword.rpl</string>
</dict>
</array>
</dict>
<key>define</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(^[\x{002b}a-zA-Z0-9]+)(\s+)([^\s]+)(\s+)([^\s]+)(\s+)(.+$)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>7</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(^[\x{002b}a-zA-Z0-9]+)(\s+)([^\s]+)(\s+)([^\s]+)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>text.rpl</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>main__1</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#numeric</string>
</dict>
<dict>
<key>match</key>
<string>(,)</string>
<key>name</key>
<string>punctuation.rpl</string>
</dict>
</array>
</dict>
<key>multi_line_comment__1</key>
<dict>
<key>patterns</key>
<array>
</array>
</dict>
<key>numeric</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(\b(?:[\x{0023}\x{0025}])?[0-9A-F]+\b)</string>
<key>name</key>
<string>constant.numeric.rpl</string>
</dict>
</array>
</dict>
<key>rpl_block</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(::)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#rpl_block__1</string>
</dict>
</array>
<key>end</key>
<string>(;)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.section.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>rpl_block__1</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#rpl_block</string>
</dict>
<dict>
<key>include</key>
<string>#assemble_block</string>
</dict>
<dict>
<key>include</key>
<string>#code_block</string>
</dict>
<dict>
<key>include</key>
<string>#strings</string>
</dict>
<dict>
<key>include</key>
<string>#numeric</string>
</dict>
<dict>
<key>include</key>
<string>#rpl_comment</string>
</dict>
<dict>
<key>include</key>
<string>#rpl_multi_line_comment</string>
</dict>
<dict>
<key>include</key>
<string>#code_word</string>
</dict>
</array>
</dict>
<key>rpl_comment</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(\( )</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
<key>contentName</key>
<string>comment.rpl</string>
<key>end</key>
<string>( \))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>rpl_comment__1</key>
<dict>
<key>patterns</key>
<array>
</array>
</dict>
<key>rpl_multi_line_comment</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(^\*)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
<key>contentName</key>
<string>comment.rpl</string>
<key>end</key>
<string>(?=^[^\*])</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>comment.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>rpl_multi_line_comment__1</key>
<dict>
<key>patterns</key>
<array>
</array>
</dict>
<key>strings</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(\&quot;)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.rpl</string>
</dict>
</dict>
<key>contentName</key>
<string>text.rpl</string>
<key>end</key>
<string>(\&quot;)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.rpl</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>strings__1</key>
<dict>
<key>patterns</key>
<array>
</array>
</dict>
</dict>
</dict>
</plist>
## Iro
## * Press Ctrl + '+'/'-' To Zoom in
## * Press Ctrl + S to save and recalculate...
## * Documents are saved to web storage.
## * Only one save slot supported.
## * Matches cannot span lines.
## * Unicode chars must be defined in \u0000 to \uffff format.
## * All matches must be contained by a single group ( ... )
## * Look behinds not permitted, (?<= or (?<!
## * Look forwards are permitted (?= or (?!
## * Constants are defined as __my_const = (......)
## * The \= format allows unescaped regular expressions
## * Constants referenced by match \= $${__my_const}
## * Constants can reference other constants
## * You are free to delete all the default scopes.
## * Twitter : ainslec , Web: http://eeyo.io/iro
##
name = rpl
file_extensions [] = a, s, rpl, srpl;
# Constants
__MY_CONSTANT \= (\b[a-zA-Z_#=\.]+[a-zA-Z0-9]*)
# Styles
styles [] {
.comment : style {
color = light_green
italic = true
ace_scope = comment
textmate_scope = comment
pygments_scope = Comment
}
.keyword : style {
color = cyan
ace_scope = keyword
textmate_scope = keyword
pygments_scope = Keyword
}
.label : style {
color = light_green
ace_scope = keyword
textmate_scope = keyword
pygments_scope = Keyword
}
.numeric : style {
color = gold
ace_scope = constant.numeric
textmate_scope = constant.numeric
pygments_scope = Number
}
.punctuation : style {
color = red_2
ace_scope = punctuation
textmate_scope = punctuation
pygments_scope = Punctuation
}
.text : style {
color = brown
ace_scope = text
textmate_scope = text
pygments_scope = String
}
.entityNameSection : style {
color = white
textmate_scope = entity.name.section
}
.illegal : style {
color = white
background_color = red
ace_scope = invalid
textmate_scope = invalid
pygments_scope = Generic.Error
}
}
# Parse contexts
contexts [] {
# Rpl Block Context
rpl_block : context {
description = rpl_block
: inline_push {
regex \= (::)
styles [] = .entityNameSection;
: pop {
regex \= (;)
styles [] = .entityNameSection;
}
: include "rpl_block" ;
: include "assemble_block" ;
: include "code_block" ;
: include "strings" ;
: include "numeric" ;
: include "rpl_comment" ;
: include "rpl_multi_line_comment" ;
: include "code_word" ;
}
}
code_word : context {
# code word
: pattern {
regex \= ([0-9A-Za-z&#?<>@!\-/:'=$\*_]+)
styles [] = .keyword;
}
}
assemble_block : context {
description = assembly
: inline_push {
regex \= (^ASSEMBLE)
styles [] = .entityNameSection;
: pop {
regex = (^RPL)
styles [] = .entityNameSection;
}
: include "assembly";
}
}
code_block : context {
description = assembly
: inline_push {
regex \= (^\s*CODE\s*)(.*)
styles [] = .entityNameSection, .comment;
: pop {
regex \= (^\s*ENDCODE\s*)(.*)
styles [] = .entityNameSection, .comment;
}
: include "assembly";
}
}
define : context {
: pattern {
regex \= (^[+a-zA-Z0-9]+)(\s+)([^\s]+)(\s+)([^\s]+)(\s+)(.+$)
styles [] = .label, .text, .keyword, .text, .keyword, .text, .comment;
}
: pattern {
regex \= (^[+a-zA-Z0-9]+)(\s+)([^\s]+)(\s+)([^\s]+)
styles [] = .label, .text, .keyword, .text, .keyword;
}
}
assembly : context {
: include "rpl_multi_line_comment" ;
: pattern {
regex \= (^[^\s]+)(\s+)([^\s]+)(\s+)([^\s]+)(\s+)(.*$)
styles [] = .label, .text, .keyword, .text, .keyword, .text, .comment;
}
: pattern {
regex \= (^[^\s]+)(\s+)([^\s]+)(\s+)([^\s]+)(.*)
styles [] = .label, .text, .keyword, .text, .keyword, .comment;
}
: pattern {
regex \= (\s+)([^\s]+)(\s+)([^\s]+)(.*)
styles [] = .text, .keyword, .text, .keyword, .comment;
}
: pattern {
regex \= (\s+)([^\s]+)([^\s]+)(.*)
styles [] = .text, .keyword, .keyword, .comment;
}
}
strings : context {
# "abc" strings
: inline_push {
regex \= (\")
styles [] = .punctuation;
default_style = .text
: pop {
regex \= (\")
styles [] = .punctuation;
}
}
}
rpl_comment : context {
# ( ) comments
: inline_push {
regex \= (\( )
styles [] = .comment;
default_style = .comment
: pop {
regex \= ( \))
styles [] = .comment;
}
}
}
numeric : context {
: pattern {
regex \= (\b(?:[#%])?[0-9A-F]+\b)
styles [] = .numeric;
}
}
# Main Context - Entry point context
main : context {
# * comments
: include "rpl_multi_line_comment" ;
: include "numeric" ;
: include "rpl_block" ;
: include "assemble_block" ;
: include "code_block" ;
: include "define" ;
: pattern {
regex \= $${__MY_CONSTANT}
styles [] = .keyword;
}
# (1,2,3)
: inline_push {
regex \= (\()
styles [] = .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "numeric" ;
: pattern {
regex \= (,)
styles [] = .punctuation;
}
}
: pattern {
regex \= (;)
styles [] = .entityNameSection;
}
: pattern {
regex \= ([^\s])
styles [] = .illegal;
}
}
# End of Contexts
# Numeric Context
###########################################
## Multi Line Comment Context
###########################################
multi_line_comment : context {
description = multiline
: inline_push {
regex \= (/\*)
styles [] = .comment;
default_style = .comment
: pop {
regex \= (\*/)
styles [] = .comment;
}
}
}
rpl_multi_line_comment : context {
description = multiline
: inline_push {
regex \= (^\*)
styles [] = .comment;
default_style = .comment
: pop {
regex \= (?=^[^\*])
styles [] = .comment;
}
}
}
}
@dlidstrom
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment