Files
clean-sheets/assets/syntaxes/Pseudo.sublime-syntax
T
2026-09-10 20:02:22 +02:00

132 lines
3.8 KiB
YAML

%YAML 1.2
---
name: Pseudocode
file_extensions:
- psd
- pseudo
- pseudocode
scope: source.pseudocode
version: 2
variables:
control_keywords: '\b(?i:(IF|THEN|ELSE|END_IF|WHILE|DO|END_WHILE|END_DO|FOR|FROM|TO|DOWNTO|BEGIN|END|IN|RETURN|BREAK|CONTINUE|EXIT))\b'
declaration_keywords: '\b(?i:(GLOBAL|DEF|PROCEDURE|PROCESS|RETURNS))\b'
io_keywords: '\b(?i:(INPUT|OUTPUT|REGISTER|READ|KEYWORD|ARGUMENT|PRINT|PRINTS))\b'
logical_keywords: '\b(?i:(AND|OR))\b'
boolean_keywords: '\b(?i:(TRUE|FALSE))\b'
builtin_keywords: '\b(?i:(LEN|LENGTH|MIN|MAX|ABS|ROUND))\b'
basic_types: '\b(?i:(INT|STRING|BOOL|BOOLEAN|FLOAT|DOUBLE|CHAR|VOID|LIST|ARRAY|DICT|DICTIONARY|SET|MAP|TUPLE|STACK|QUEUE|MUTEX))\b'
number: '\b\d+(?:\.\d+)?\b'
identifier: '[A-Za-z_][A-Za-z0-9_]*'
contexts:
prototype:
- include: at_escape
main:
- include: comments
- include: strings
- include: math_inline
- include: function_definitions
- include: keywords
- include: operators
- include: function_calls
- include: numbers
function_definitions:
- match: '(?i)\b(DEF|PROCEDURE)\b(\s+)({{identifier}})(\s*)(\()'
captures:
1: storage.type.function.pseudocode
2: text.whitespace
3: entity.name.function.pseudocode
4: text.whitespace
5: punctuation.section.group.begin.pseudocode
function_calls:
- match: '\b(?i:(LEN|MIN))\b(?=\s*\()'
scope: support.function.builtin.pseudocode
- match: '\b{{identifier}}\b(?=\s*\()'
scope: variable.function.pseudocode
keywords:
- match: '{{basic_types}}'
scope: storage.type.pseudocode
- match: '{{logical_keywords}}'
scope: keyword.operator.logical.pseudocode
- match: '{{boolean_keywords}}'
scope: constant.language.boolean.pseudocode
- match: '{{builtin_keywords}}'
scope: support.function.builtin.pseudocode
- match: '{{declaration_keywords}}'
scope: storage.type.function.pseudocode
- match: '{{io_keywords}}'
scope: support.function.builtin.pseudocode
- match: '{{control_keywords}}'
scope: keyword.control.pseudocode
operators:
- match: '(?:<<=|>>=|\+=|-=|\*=|/=|%=|&=|\|=|\^=|\+\+|--)'
scope: keyword.operator.assignment.pseudocode
- match: '=(?!=)'
scope: keyword.operator.assignment.pseudocode
- match: '(?:<=|<|>=|>|===|!==|==|!=)'
scope: keyword.operator.comparison.pseudocode
numbers:
- match: '{{number}}'
scope: constant.numeric.pseudocode
comments:
- match: '(?:\/\/|\#|\-\-|\;|REM\b)'
scope: punctuation.definition.comment.pseudocode
push: line_comment
- match: '/\*'
scope: punctuation.definition.comment.begin.pseudocode
push: block_comment
line_comment:
- meta_scope: comment.line.double-slash.pseudocode
- match: '$'
pop: true
block_comment:
- meta_scope: comment.block.pseudocode
- match: '\*/'
scope: punctuation.definition.comment.end.pseudocode
pop: true
strings:
- match: '"'
scope: punctuation.definition.string.begin.pseudocode
push: double_quoted_string
double_quoted_string:
- meta_content_scope: string.quoted.double.pseudocode
- match: '\\.'
scope: constant.character.escape.pseudocode
- match: '"'
scope: punctuation.definition.string.end.pseudocode
pop: true
at_escape:
- match: '@'
scope: punctuation.section.embedded.begin.pseudocode
push: escaped_region
escaped_region:
- meta_content_scope: meta.embedded.escape.pseudocode
- match: '@'
scope: punctuation.section.embedded.end.pseudocode
pop: true
math_inline:
- match: '\$'
scope: punctuation.section.embedded.begin.pseudocode
push: math_inline_body
math_inline_body:
- meta_content_scope: meta.embedded.math.pseudocode
- match: '\$'
scope: punctuation.section.embedded.end.pseudocode
pop: true