Last active
January 18, 2022 09:45
-
-
Save kolumb/1dce434227bc2f7640f26a06aff864cf to your computer and use it in GitHub Desktop.
Syntax highlighting for Porth (https://gitlab.com/tsoding/porth) in Sublime Text
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/syntax.html | |
name: Porth | |
scope: source.porth | |
file_extensions: | |
- porth | |
variables: | |
char_escape: '\\n|\\r|\\\\|\\"|\\''' | |
contexts: | |
main: | |
# Comments begin with a '//' and finish at the end of the line | |
- match: '//' | |
scope: punctuation.definition.comment.porth | |
push: line_comment | |
# Keywords. | |
- match: '\b(if|else|while|do|include|memory|proc|const|end|offset|reset|assert|in|inline|here|addr-of|call-like)\b' | |
scope: keyword.control.porth | |
# Numbers | |
- match: '(?:^|\s)[0-9]+(?:\s|$)' | |
scope: constant.numeric.integer.porth | |
# Character literal | |
- match: (\')(?:({{char_escape}})|([^']))(\') | |
scope: string.quoted.single.porth | |
captures: | |
1: punctuation.definition.string.begin.porth | |
2: constant.character.escape.porth | |
3: constant.character.literal.porth | |
4: punctuation.definition.string.end.porth | |
# Strings begin and end with quotes, and use backslashes as an escape character | |
- match: '"' | |
scope: punctuation.definition.string.begin.porth | |
push: double_quoted_string | |
line_comment: | |
- meta_scope: comment.line.porth | |
- match: $ | |
pop: true | |
double_quoted_string: | |
- meta_scope: string.quoted.double.porth | |
- match: '"' | |
scope: punctuation.definition.string.end.porth | |
pop: true | |
- match: ({{char_escape}}) | |
scope: constant.character.escape.porth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment