Created
June 18, 2022 04:37
-
-
Save iacore/190adb9c3954603cf7034f9cb450fd2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%YAML 1.2 | |
--- | |
# See http://www.sublimetext.com/docs/3/syntax.html | |
file_extensions: [p6, pm6, pod6, raku, rakumod, rakudoc, rakutest, nqp, crotmp] | |
scope: source.raku | |
contexts: | |
# The prototype context is prepended to all contexts but those setting | |
# meta_include_prototype: false. | |
prototype: | |
- include: in_line_comments | |
- include: line_comments | |
- include: doc_comments | |
main: | |
# The main context is the initial starting point of our syntax. | |
# Include other contexts from here (or specify them directly). | |
- include: regex | |
- include: keywords | |
- include: numbers | |
- include: double_quote_strings | |
- include: single_qoute_strings | |
- include: built_in_consts | |
- include: vars | |
- include: storage_types | |
- include: built_in_subs | |
keywords: | |
# Keywords are if, else for and while. | |
# Note that blackslashes don't need to be escaped within single quoted | |
# strings in YAML. When using single quoted strings, only single quotes | |
# need to be escaped: this is done by using two single quotes next to each | |
# other. | |
- match: '\b(if|elsif|else|unless|with|for|given|when|default|loop|my|while|return|returns|repeat|until|orwith|without|use|is|has|try|gather|start|react|supply|tap|emit|does|self|fail)\b' | |
scope: keyword.control.raku | |
built_in_subs: | |
# 5/18/18: needs to be expanded upon quite a bit... | |
- match: '\b(say|print|uc|chars|flip|numerator|denominator|nude|is-prime|WHAT|slurp|warn|IO|lines|mkdir|rmdir|e|map|reverse|exit|sort|unique|kv|keys|values|open|get|push|prompt|run|shell|spurt|dir|die|defined|last|do)\b' | |
scope: support.function.raku | |
vars: | |
- match: '(\$|@|%)\S+?.\b' | |
captures: | |
1: punctuation.definition.variable | |
scope: variable.other.raku | |
regex: | |
- match: '(m|rx|)\/' | |
scope: string.regexp.begin.raku | |
push: | |
- meta_scope: string.regexp.raku | |
- match: '/' | |
scope: string.regexp.end.raku | |
pop: true | |
numbers: | |
- match: '\b(\-)?[0-9]*\.?[0-9]+\b' | |
scope: constant.numeric.raku | |
- match: '\b0x[0-9a-fA-F_]+\b' | |
scope: constant.numeric.raku | |
- match: '\b0b[0-1_]+\b' | |
scope: constant.numeric.raku | |
- match: '\b0o[0-7_]+\b' | |
scope: constant.numeric.raku | |
built_in_consts: | |
- match: '\b(True|False|Nil)\b' | |
scope: constant.language.raku | |
storage_types: | |
- match: '\b(Mu|Any|Cool|Str|Int|Rat|Bool|Sub|u?int8|u?int16|u?int32|u?int64|byte|num32|num64|token|regex|rule)\b' | |
scope: storage.type.raku | |
- match: '\b(sub|multi|submethod|method)\b ([A-Za-z0-9_-]+)' | |
scope: storage.type.raku | |
captures: | |
1: meta.function.raku | |
2: entity.name.function.raku | |
- match: '\b(class)\b ([A-Za-z0-9-_:]+)' | |
scope: storage.type.raku | |
captures: | |
1: meta.class.raku | |
2: entity.name.class.raku | |
- match: '\b(grammar)\b ([A-Za-z0-9_-]+)' | |
scope: storage.type.raku | |
captures: | |
1: meta.grammar.raku | |
2: entity.name.grammar.raku | |
char_escapes: | |
- match: '\\.' | |
scope: constant.character.escape.raku | |
double_quote_strings: | |
# interpolated strings begin and end with double quotes, and use backslashes as an escape | |
# character. | |
- match: '"' | |
scope: punctuation.definition.string.begin.raku | |
push: inside_double_quote_string | |
inside_double_quote_string: | |
- meta_include_prototype: false | |
- meta_scope: string.quoted.double.raku | |
- include: char_escapes | |
- match: '"' | |
scope: punctuation.definition.string.end.raku | |
pop: true | |
single_qoute_strings: | |
# literal strings begin and end with single quotes, no escapes | |
- match: '''' | |
scope: punctuation.definition.string.begin.raku | |
push: | |
- meta_include_prototype: false | |
- meta_scope: string.quoted.single.raku | |
- match: '''' | |
scope: punctuation.definition.string.end.raku | |
pop: true | |
line_comments: | |
# line_comments begin with a '#' and finish at the end of the line. | |
- match: '#' | |
scope: punctuation.definition.comment.raku | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_scope: comment.line.number-sign.raku | |
- match: $\n? | |
pop: true | |
doc_comments: | |
# doc_comments begin with a '=begin <tagname>\n' and end with a | |
# '=end <tagname>\n' string | |
- match: '^=begin \S+\n' | |
scope: punctuation.definition.comment.raku | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- meta_scope: comment.block.documentation.raku | |
- match: '^=end \S+\n' | |
pop: true | |
in_line_comments: | |
- match: '#`\(' | |
scope: punctuation.definition.comment.raku | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- meta_scope: comment.block.raku | |
- include: matching_parentheses | |
- match: '\)' | |
pop: true | |
- match: '#`\[' | |
scope: punctuation.definition.comment.raku | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- meta_scope: comment.block.raku | |
- include: matching_square_brackets | |
- match: '\]' | |
pop: true | |
- match: '#`\{' | |
scope: punctuation.definition.comment.raku | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- meta_scope: comment.block.raku | |
- include: matching_curly_brackets | |
- match: '\}' | |
pop: true | |
- match: '#`\<' | |
scope: punctuation.definition.comment.raku | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- meta_scope: comment.block.raku | |
- include: matching_angle_brackets | |
- match: '\>' | |
pop: true | |
#These contexts are pretty much exclusively for nested brackets in comments | |
matching_parentheses: | |
- match: '\(' | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- include: matching_parentheses | |
- match: '\)' | |
pop: true | |
matching_square_brackets: | |
- match: '\[' | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- include: matching_square_brackets | |
- match: '\]' | |
pop: true | |
matching_curly_brackets: | |
- match: '\{' | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- include: matching_curly_brackets | |
- match: '\}' | |
pop: true | |
matching_angle_brackets: | |
- match: '\<' | |
push: | |
# This is an anonymous context push for brevity. | |
- meta_include_prototype: false | |
- include: matching_angle_brackets | |
- match: '\>' | |
pop: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment