// This is a TextMate grammar distributed by `starry-night`. // This grammar is developed at // // and licensed `apache-2.0`. // See for more info. /** * @import {Grammar} from '@wooorm/starry-night' */ /** @type {Grammar} */ const grammar = { extensions: ['.surql'], names: ['surrealql', 'surql'], patterns: [ {include: '#comment'}, {include: '#js-function'}, {include: '#function'}, {include: '#keywords'}, {include: '#operators'}, {include: '#value'} ], repository: { array: {begin: '\\[', end: '\\]', patterns: [{include: '#array-content'}]}, 'array-content': { patterns: [ {include: '$self'}, {match: ',', name: 'punctuation.separator.array'} ] }, block: { begin: '\\{', end: '\\}', name: 'surrealql.block', patterns: [{include: '#block-content'}] }, 'block-content': { patterns: [ {include: '#string'}, {include: '#object-key'}, {include: '$self'} ] }, boolean: { match: '\\b(true|TRUE|false|FALSE|True|False)\\b', name: 'constant.language.bool' }, comment: { patterns: [ {include: '#comment.line.dash'}, {include: '#comment.line.slash'}, {include: '#comment.line.hash'}, {include: '#comment.block'} ] }, 'comment.block': { begin: '/\\*', end: '\\*/', name: 'comment.block.surrealql' }, 'comment.line.dash': { begin: '--', end: '\\n', name: 'comment.line.double-dash' }, 'comment.line.hash': { begin: '#', end: '\\n', name: 'comment.line.number-sign' }, 'comment.line.slash': { begin: '//', end: '\\n', name: 'comment.line.double-slash' }, duration: {match: '(\\d+(ns|µs|ms|s|m|h|d|w|y))+', name: 'constant.other'}, function: { begin: '(?=((?:\\b\\w+(?:::\\b\\w+)+)|count|rand)\\s*\\()', beginCaptures: {1: {name: 'support.function'}}, end: '(?<=\\))', patterns: [ {include: '#comment'}, { begin: '\\(', end: '\\)', name: 'meta.function.arguments', patterns: [{include: '#value'}] } ] }, ident: { patterns: [ {begin: '`', end: '(?|->|<-|<~', name: 'keyword.operator.arrow.surrealql'}, {match: '\\b(AND|and)\\b|&&', name: 'keyword.operator.and.surrealql'}, {match: '\\b(OR|or)\\b|\\|\\|', name: 'keyword.operator.or.surrealql'}, { match: '\\b(IS NOT|is not)\\b|!=', name: 'keyword.operator.is-not.surrealql' }, {match: '\\b(IS|is)\\b|=', name: 'keyword.operator.is.surrealql'}, { match: '\\b(CONTAINSALL|containsall)\\b|⊇', name: 'keyword.operator.containsall.surrealql' }, { match: '\\b(CONTAINSANY|containsany)\\b|⊃', name: 'keyword.operator.containsany.surrealql' }, { match: '\\b(CONTAINSNONE|containsnone)\\b|⊅', name: 'keyword.operator.containsnone.surrealql' }, { match: '\\b(CONTAINSSOME|containssome)\\b', name: 'keyword.operator.containssome.surrealql' }, { match: '\\b(CONTAINSNOT|containsnot)\\b|∌', name: 'keyword.operator.containsnot.surrealql' }, { match: '\\b(CONTAINS|contains)\\b|∋', name: 'keyword.operator.contains.surrealql' }, { match: '\\b(ALLINSIDE|allinside)\\b|⊆', name: 'keyword.operator.allinside.surrealql' }, { match: '\\b(ANYINSIDE|anyinside)\\b|⊂', name: 'keyword.operator.anyinside.surrealql' }, { match: '\\b(NONEINSIDE|noneinside)\\b|⊄', name: 'keyword.operator.noneinside.surrealql' }, { match: '\\b(SOMEINSIDE|someinside)\\b', name: 'keyword.operator.someinside.surrealql' }, { match: '\\b(NOTINSIDE|notinside|NOT IN|not in)\\b|∉', name: 'keyword.operator.notinside.surrealql' }, { match: '\\b(INSIDE|inside)\\b|∈', name: 'keyword.operator.inside.surrealql' }, { match: '\\b(OUTSIDE|outside)\\b', name: 'keyword.operator.outside.surrealql' }, { match: '\\b(INTERSECTS|intersects)\\b', name: 'keyword.operator.intersects.surrealql' }, {match: '==', name: 'keyword.operator.equal.surrealql'}, {match: '\\*=', name: 'keyword.operator.all-equal.surrealql'}, {match: '\\?=', name: 'keyword.operator.any-equal.surrealql'}, {match: '!~', name: 'keyword.operator.fuzzy-inequal.surrealql'}, {match: '\\*~', name: 'keyword.operator.fuzzy-all-equal.surrealql'}, {match: '\\?~', name: 'keyword.operator.fuzzy-any-equal.surrealql'}, {match: '~', name: 'keyword.operator.fuzzy-equal.surrealql'}, {match: '<=', name: 'keyword.operator.less-or-equal.surrealql'}, {match: '<(?!-|[a-z]+[^:])', name: 'keyword.operator.less.surrealql'}, {match: '>=', name: 'keyword.operator.more-or-equal.surrealql'}, {match: '(?', name: 'keyword.operator.more.surrealql'}, {match: '\\+', name: 'keyword.operator.add.surrealql'}, {match: '-', name: 'keyword.operator.subtract.surrealql'}, {match: '\\*|×|∙', name: 'keyword.operator.multiply.surrealql'}, {match: '\\/|÷', name: 'keyword.operator.devide.surrealql'}, { captures: {1: {name: 'constant.numeric.int'}}, match: '@([0-9]+)?@', name: 'keyword.operator.matches.surrealql' }, {match: '\\?:', name: 'keyword.operator.either.surrealql'}, {match: '\\?\\?', name: 'keyword.operator.truthy.surrealql'}, { match: '\\<\\|([a-zA-Z|\\d|,])+\\|\\>', name: 'keyword.operator.knn.surrealql' } ] }, positional: { match: '\\b(AFTER|after|BEFORE|before)\\b', name: 'constant.language.positional' }, query: {patterns: [{include: '$self'}]}, record: { patterns: [ { captures: { 1: {name: 'entity.name.class'}, 2: {name: 'entity.name.class'} }, match: '(\\b\\w+\\b):⟨([^⟩]+)⟩' }, { captures: { 1: {name: 'entity.name.class'}, 2: {name: 'entity.name.class'} }, match: '(\\b\\w+\\b):`([^`]+)`' }, { begin: '(\\b\\w+\\b):(?=(\\b[\\w:]+\\b)\\s*\\()', beginCaptures: { 1: {name: 'entity.name.class'}, 2: {name: 'support.function'} }, end: '(?<=\\))', patterns: [ {include: '#comment'}, { begin: '\\(', end: '\\)', name: 'meta.function.arguments', patterns: [{include: '#value'}] } ] }, { captures: { 1: {name: 'entity.name.class'}, 2: {name: 'entity.name.class'} }, match: '(\\b\\w+\\b):(\\b\\w+\\b)' }, { begin: '(\\b\\w+\\b):\\[', captures: {1: {name: 'entity.name.class'}}, end: '\\]', patterns: [{include: '#array-content'}] }, { begin: '(\\b\\w+\\b):(?=\\{)', captures: {1: {name: 'entity.name.class'}}, end: '\\}', patterns: [{include: '#block-content'}] } ] }, string: { patterns: [ {begin: '[a-z]?"', end: '(?', name: 'entity.name.type.surrealql'}, {include: '#number'}, {include: '#void-type'} ] } }, match: '[a-z]*<[a-zA-Z][a-zA-Z0-9<>|, _]+[a-zA-Z0-9>]+>', name: 'test' }, value: { patterns: [ {include: '#comment'}, {include: '#js-function'}, {include: '#function'}, {include: '#block'}, {include: '#array'}, {include: '#var-name'}, {include: '#boolean'}, {include: '#string'}, {include: '#ident'}, {include: '#void-type'}, {include: '#positional'}, {include: '#number'}, {include: '#duration'}, {include: '#record'}, {include: '#subquery'}, {include: '#type'} ] }, 'var-name': { patterns: [ {match: '\\$\\w+', name: 'variable.name'}, {match: '\\$`\\w+`', name: 'variable.name'}, {match: '\\$⟨\\w+⟩', name: 'variable.name'} ] }, 'void-type': { match: '\\b(null|NULL|none|NONE)\\b', name: 'constant.language.void' } }, scopeName: 'source.surrealql' } export default grammar