%YAML 1.2
---
name: CEL
file_extensions: [cel]
scope: source.cel
contexts:
main:
- include: comments
- include: strings
- include: language-constants
- include: numbers
- include: reserved-identifiers
- include: function-calls
- include: object-constructions
- include: parens
- include: lists
- include: maps
- include: operators
comments:
- match: (//).*$
scope: comment.line.double-slash.cel
captures:
1: punctuation.definition.comment.cel
strings:
- match: ([rR])('{3}|"{3})
captures:
1: storage.type.raw-string.cel
push:
- meta_scope: string.quoted.triple.cel
- match: \2
pop: true
- match: ('{3}|"{3})
push:
- meta_scope: string.quoted.triple.cel
- match: \1
pop: true
- include: string-escapes
- match: ([rR])(['"])
captures:
1: storage.type.raw-string.cel
push:
- meta_scope: string.quoted.single.cel
- match: \2|$
pop: true
- match: (['"])
push:
- meta_scope: string.quoted.single.cel
- match: \1|$
pop: true
- include: string-escapes
string-escapes:
- match: \\[bfnrt"'\\]
scope: constant.character.escape.cel
- match: \\u[0-9a-fA-F]{4}
scope: constant.character.escape.cel
- match: \\U[0-9a-fA-F]{8}
scope: constant.character.escape.cel
- match: \\[xX][0-9a-fA-F]{2}
scope: constant.character.escape.cel
- match: \\0[0-8]{3}
scope: constant.character.escape.cel
language-constants:
- match: \b(true|false|null)\b
scope: constant.language.cel
numbers:
- match: '[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?'
scope: constant.numeric.floating-point.cel
- match: '[0-9]+[eE][+-]?[0-9]+'
scope: constant.numeric.floating-point.cel
- match: '(0x[0-9a-fA-F]+|[0-9]+)[uU]?'
scope: constant.numeric.integer.cel
reserved-identifiers:
- match: \b(as|break|const|continue|else|for|function|if|import|let|loop|package|namespace|return|var|void|while)\b
scope: invalid.illegal.cel
function-calls:
- match: ([_a-zA-Z][_a-zA-Z0-9]*)(?=\()
scope: variable.function.cel
object-constructions:
- match: ([_a-zA-Z][_a-zA-Z0-9]*)(\{)
captures:
1: variable.object.cel
2: punctuation.definition.object.begin.cel
push:
- meta_scope: meta.structure.object.cel
- match: \}
scope: punctuation.definition.object.end.cel
pop: true
- include: object-kv
object-kv:
- match: ([_a-zA-Z][_a-zA-Z0-9]*:)
scope: entity.name.type.attribute-name.cel
push:
- match: (,)|(?=\})
captures:
1: punctuation.separator.object.cel
pop: true
- include: main
parens:
- match: \(
scope: punctuation.parenthesis.begin.cel
push:
- match: \)
scope: punctuation.parenthesis.end.cel
pop: true
- include: main
lists:
- match: \[
scope: punctuation.definition.list.begin.cel
push:
- meta_scope: meta.structure.list.cel
- match: \]
scope: punctuation.definition.list.end.cel
pop: true
- match: ','
scope: punctuation.separator.list.cel
- include: main
maps:
- match: \{
scope: punctuation.definition.map.begin.cel
push:
- meta_scope: meta.structure.map.cel
- match: \}
scope: punctuation.definition.map.end.cel
pop: true
- match: '[,:]'
scope: punctuation.separator.map.cel
- include: main
operators:
- match: (&&|\|\|)
scope: keyword.operator.logical.cel
- match: (<=|<|>=|>|==|!=|(?<![A-Za-z_])in\b)
scope: keyword.operator.comparison.cel
- match: '(\+|\-|\*|\/|%|!)'
scope: keyword.operator.arithmetic.cel