%YAML 1.2
---
name: SQL (SpaceTimeDb)
file_extensions:
- sql
- stsql
scope: source.sql
variables:
ws: '[ \t]*'
wsnl: '([ \t\n])*'
int_literal: '[0-9](?:[0-9_])*'
time_hour: '[0-2][0-9]'
time_minute: '[0-5][0-9]'
time_second: '[0-6][0-9]'
time_numoffset: '[+-] {{time_hour}} : {{time_minute}}'
partial_time: '{{time_hour}} : {{time_minute}} : {{time_second}}'
full_time: '{{partial_time}} {{time_numoffset}}'
date_fullyear: '[0-9]{4}'
date_month: '[0-1][0-9]'
date_mday: '[0-3][0-9]'
full_date: '{{date_fullyear}} - {{date_month}} - {{date_mday}}'
offset_date_time: '{{full_date}} [T ] {{full_time}}'
local_date_time: '{{full_date}} [T ] {{partial_time}}'
date_time: '{{offset_date_time}} | {{local_date_time}} | {{full_date}} | {{partial_time}}'
contexts:
prototype:
- include: comments
main:
- include: keywords
- include: parens
- include: booleans
- include: numbers
- include: date-time
- include: strings
- include: ident
- match: '{{ws}}$'
pop: true
- match: '\w+|.'
scope: invalid.illegal.value.sql
pop: true
ident:
- name: variable.parameter.sql
match: \b([a-zA-Z0-9_]+)\b
keywords:
- name: keyword.operator.point.pgsql
match: \.
- name: keyword.operator.comma.pgsql
match: \,
- name: keyword.operator.semicolon.pgsql
match: \;
- name: keyword.operator.star.pgsql
match: \*
- match: '(?i)\b(select|from|insert|into|join|values|update|delete|create|where|order by)\b'
scope: keyword.control.sql
- match: '[!<>]?=|<>|<|>'
scope: keyword.operator.comparison.sql
- match: \+|\-|\*|/|\^
scope: keyword.operator.arithmetic.sql
- match: \b(and|in|not|or)\b
comment: keyword operators that evaluate to true or false
scope: keyword.operator.logical.sql
booleans:
- match: (?i)\b(true|false|null)\b
scope: constant.language.source.sql
numbers:
- match: '\b({{int_literal}}(?:\.{{int_literal}})?)f\b'
scope: constant.numeric.source.sql
- match: '\b({{int_literal}}(?:\.{{int_literal}})?)\b'
scope: constant.numeric.source.sql
strings:
- match: '"'
scope: punctuation.definition.string.begin.source.sql
push: double_quoted_string
- match: "'"
scope: punctuation.definition.string.begin.source.sql
push: single_quoted_string
double_quoted_string:
- meta_scope: string.quoted.double.source.sql
- match: '\\.'
scope: constant.character.escape.source.sql
- match: '"'
scope: punctuation.definition.string.end.source.sql
pop: true
single_quoted_string:
- meta_scope: string.quoted.double.source.sql
- match: '\\.'
scope: constant.character.escape.source.sql
- match: "'"
scope: punctuation.definition.string.end.source.sql
pop: true
date-time:
- match: "(d|t|dt)'"
scope: constant.other.datetime.begin.source.sql
push: single_quoted_date
- match: '(d|t|dt)"'
scope: constant.other.datetime.begin.source.sql
push: double_quoted_date
double_quoted_date:
- meta_scope: string.quoted.double.source.sql
- match: '(?x) {{date_time}}'
scope: constant.character.escape.source.sql
- match: '"'
scope: constant.other.datetime.end.source.sql
pop: true
single_quoted_date:
- meta_scope: string.quoted.double.source.sql
- match: '(?x) {{date_time}}'
scope: constant.character.escape.source.sql
- match: "'"
scope: constant.other.datetime.end.source.sql
pop: true
parens:
- match: \(
push: brackets
- match: \)
scope: invalid.illegal.stray-bracket-end
brackets:
- match: \)
pop: true
- include: parens
comments:
- match: '--'
scope: punctuation.definition.comment.source.sql
push:
- meta_scope: comment.line.double-slash.source.sql
- match: $\n?
pop: true