43 lines
1.5 KiB
YAML
43 lines
1.5 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own CMake grammar. Original work written for this project; not copied
|
|
# from any other grammar. Regexes stay linear: no nested quantifiers, so nothing backtracks far.
|
|
# Strings end at their line unless the language allows multi-line ones.
|
|
name: CMake
|
|
file_extensions: [cmake, CMakeLists.txt]
|
|
scope: source.cmake
|
|
|
|
contexts:
|
|
main:
|
|
- match: '#\[\['
|
|
scope: punctuation.definition.comment.begin
|
|
push: block0
|
|
- match: '#.*'
|
|
scope: comment.line
|
|
- match: '\$(?:ENV)?\{[^}\n]*\}'
|
|
scope: variable.other.cmake
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: '\b(?:if|elseif|else|endif|foreach|endforeach|while|endwhile|function|endfunction|macro|endmacro|block|endblock|return|break|continue|AND|OR|NOT|STREQUAL|EQUAL|MATCHES|DEFINED|EXISTS|IN_LIST|PRIVATE|PUBLIC|INTERFACE|REQUIRED|COMPONENTS|STATIC|SHARED)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:TRUE|FALSE|ON|OFF|YES|NO)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '\b[A-Za-z_]\w*(?=\s*\()'
|
|
scope: entity.name.function
|
|
block0:
|
|
- meta_scope: comment.block
|
|
- match: '\]\]'
|
|
pop: true
|
|
str-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|