ox.sublime-syntax (3651B)
%YAML 1.2
---
name: Ox
file_extensions:
- ox
scope: source.ox
# ------------------------------------------------------------------
# Top‑level contexts – the “main” context is what Sublime loads first
# ------------------------------------------------------------------
contexts:
main:
- include: comments # block / line / shebang
- include: keywords
- include: numbers
- include: strings
- include: basic-types
- include: functions
- include: typedefs
- include: builtins
# ------------------------------------------------------------------
# Comments
# ------------------------------------------------------------------
comments:
- include: block-comment # /* … */
- match: '//.*$'
scope: comment.line.double-slash
- match: '#!.*$'
scope: comment.line.double-slash
# ------------------------------------------------------------------
# Block comments – allows nesting
# ------------------------------------------------------------------
block-comment:
- match: '/\*'
scope: punctuation.definition.comment
push:
- meta_scope: comment.block
# end of block comment – pop back to the parent context
- match: '\*/'
scope: punctuation.definition.comment
pop: true
# allow nested block comments
- include: block-comment
# ------------------------------------------------------------------
# Keywords, operators and constants
# ------------------------------------------------------------------
keywords:
- match: '\b(const|else|for|if|pkg|record|return|typedef|match|case|while)\b'
scope: keyword.control
- match: '\b(and|by|in|not|or)\b'
scope: keyword.operator
- match: '\b(false|nil|true)\b'
scope: constant.language
# ------------------------------------------------------------------
# Built‑in functions
# ------------------------------------------------------------------
builtins:
- match: '\b(abs|len|assert|print|exit|panic)\b'
scope: variable.function support.function.builtin
# ------------------------------------------------------------------
# Numbers
# ------------------------------------------------------------------
numbers:
- match: '\b([+-])?[0-9]+(\.[0-9]*(e[0-9]+))?\b'
scope: constant.numeric
- match: '\b([+-])?0x[0-9A-Fa-f]+\b'
scope: constant.numeric
# ------------------------------------------------------------------
# Basic types
# ------------------------------------------------------------------
basic-types:
- match: '\b(int|void|float|char|string|bool)\b'
scope: storage.type
# ------------------------------------------------------------------
# Function names look‑ahead for '(')
# ------------------------------------------------------------------
functions:
- match: '\b([A-Za-z_][A-Za-z0-9_]*)\s*(?=$)'
scope: entity.name.function
# ------------------------------------------------------------------
# Type names (capitalised identifiers)
# ------------------------------------------------------------------
typedefs:
- match: '\b[A-Z][A-Za-z0-9_]*\b'
scope: entity.name.type
# ------------------------------------------------------------------
# Strings (double‑quoted)
# ------------------------------------------------------------------
strings:
- begin: '"'
end: '"'
scope: string.quoted.double
# enable escape handling inside the string
escaped: true
patterns:
- match: '\\.'
scope: constant.character.escape