├── .eslintrc.yaml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── channels └── sublime │ └── package-control.json ├── doc └── preview │ ├── macaron-dark │ ├── shex.png │ ├── sparql.png │ └── turtle.png │ └── macaron-light │ ├── shex.png │ ├── sparql.png │ └── turtle.png ├── emk.js ├── package-lock.json ├── package.json ├── push-assets.sh └── src ├── ace └── mode.jmacs.js ├── channel └── package-control.js ├── color-schemes ├── base │ ├── dark.js │ └── light.js ├── macaron-dark.js ├── macaron-light.js └── shared │ └── regex-scopes.js ├── main ├── ace-syntax.js ├── color-scheme.js ├── sublime-syntax.js └── turtle.js ├── supplementals ├── comments.preferences.yaml ├── completions.js └── settings.jmacs.sublime-settings └── syntax ├── human-readable.syntax-source ├── n-quads.syntax-source ├── n-triples.syntax-source ├── notation3.syntax-source ├── shex.syntax-source ├── sparql.syntax-source ├── t-family.syntax-source ├── terse.syntax-source ├── trig.syntax-source ├── turtle.syntax-source └── verbose.syntax-source /.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | parserOptions: 3 | ecmaVersion: 9 4 | sourceType: module 5 | env: 6 | es6: true 7 | browser: true 8 | node: true 9 | commonjs: true 10 | extends: 11 | - 'eslint:recommended' 12 | # - 'plugin:jmacs/all' 13 | # - 'plugin:elite/all' 14 | rules: 15 | 16 | # "Possible Errors" 17 | for-direction: error 18 | getter-return: 19 | - error 20 | - allowImplicit: true 21 | no-await-in-loop: off 22 | no-cond-assign: 23 | - error 24 | - except-parens 25 | no-console: 26 | - warn 27 | - allow: 28 | - time 29 | - warn 30 | - error 31 | - assert 32 | no-control-regex: off 33 | no-debugger: 34 | - warn 35 | no-empty: 36 | - error 37 | - allowEmptyCatch: true 38 | # no-extra-parens: 39 | # - warn 40 | # - all 41 | # - nestedBinaryExpressions: false 42 | no-template-curly-in-string: warn 43 | valid-jsdoc: 44 | - warn 45 | - requireReturn: false 46 | valid-typeof: 47 | - error 48 | - requireStringLiterals: true 49 | 50 | # "Best Practices" 51 | # accessor-pairs: 52 | # - warn 53 | # - getWithoutSet: true 54 | array-callback-return: error 55 | class-methods-use-this: warn 56 | curly: 57 | - error 58 | - multi-line 59 | - consistent 60 | default-case: error 61 | dot-location: 62 | - error 63 | - property 64 | dot-notation: error 65 | eqeqeq: error 66 | no-caller: error 67 | no-extend-native: error 68 | no-extra-bind: error 69 | no-extra-label: warn 70 | no-implied-eval: error 71 | no-invalid-this: error 72 | no-iterator: error 73 | no-loop-func: error 74 | no-multi-spaces: 75 | - warn 76 | - ignoreEOLComments: true 77 | no-multi-str: error 78 | no-new: error 79 | no-new-func: error 80 | no-new-wrappers: error 81 | no-octal-escape: error 82 | no-proto: error 83 | # no-return-assign: 84 | # - warn 85 | # - except-parens 86 | no-script-url: error 87 | no-self-assign: 88 | - warn 89 | no-self-compare: error 90 | no-sequences: error 91 | no-throw-literal: error 92 | no-unmodified-loop-condition: error 93 | no-unused-expressions: error 94 | no-unused-labels: warn 95 | no-useless-call: error 96 | no-useless-concat: warn 97 | no-useless-escape: warn 98 | no-void: error 99 | no-warning-comments: warn 100 | no-with: error 101 | prefer-promise-reject-errors: warn 102 | require-await: error 103 | wrap-iife: 104 | - error 105 | - inside 106 | yoda: 107 | - warn 108 | - always 109 | - onlyEquality: true 110 | 111 | # "Variables" 112 | no-label-var: error 113 | no-restricted-globals: error 114 | no-shadow: error 115 | no-shadow-restricted-names: error 116 | no-undef-init: error 117 | no-undefined: error 118 | no-unused-vars: warn 119 | no-use-before-define: 120 | - error 121 | - classes: false 122 | variables: false 123 | functions: false 124 | 125 | # "Node.js and CommonJS" 126 | global-require: warn 127 | handle-callback-err: 128 | - warn 129 | - "^e_" 130 | no-buffer-constructor: error 131 | no-new-require: error 132 | no-path-concat: error 133 | 134 | # "Stylistic Issues" 135 | array-bracket-spacing: 136 | - error 137 | - never 138 | brace-style: 139 | - error 140 | - stroustrup 141 | - allowSingleLine: true 142 | # capitalized-comments: 143 | # - warn 144 | # - never 145 | # - ignoreConsecutiveComments: true 146 | comma-dangle: 147 | - warn 148 | - always-multiline 149 | comma-spacing: error 150 | comma-style: error 151 | computed-property-spacing: error 152 | eol-last: error 153 | func-call-spacing: error 154 | # id-match: 155 | # - warn 156 | # - "^[a-z$]{1,4}(_[a-z0-9]+)?|[A-Z$]{1,4}_[A-Z0-9$]+$" 157 | implicit-arrow-linebreak: error 158 | indent: 159 | - warn 160 | - tab 161 | - SwitchCase: 1 162 | VariableDeclarator: 0 163 | ignoreComments: true 164 | key-spacing: 165 | - warn 166 | - singleLine: 167 | beforeColon: false 168 | afterColon: false 169 | multiLine: 170 | beforeColon: false 171 | afterColon: true 172 | keyword-spacing: 173 | - warn 174 | - overrides: 175 | if: 176 | after: false 177 | for: 178 | after: false 179 | while: 180 | after: false 181 | switch: 182 | after: false 183 | catch: 184 | after: false 185 | linebreak-style: error 186 | # lines-around-comment: 187 | # - warn 188 | # - beforeLineComment: true 189 | # allowBlockStart: true 190 | # allowClassStart: true 191 | # allowObjectStart: true 192 | # allowArrayStart: true 193 | # allowBeforeElse: true 194 | lines-between-class-members: 195 | - warn 196 | - always 197 | - exceptAfterSingleLine: true 198 | multiline-ternary: 199 | - warn 200 | - always-multiline 201 | new-cap: 202 | - error 203 | - newIsCap: false 204 | capIsNewExceptionPattern: "^[A-Z$_][A-Z$_0-9]*" 205 | capIsNew: true 206 | properties: false 207 | new-parens: error 208 | # newline-per-chained-call: 209 | # - warn 210 | # - ignoreChainWithDepth: 4 211 | no-array-constructor: error 212 | no-lonely-if: warn 213 | no-mixed-operators: warn 214 | no-mixed-spaces-and-tabs: warn 215 | no-multiple-empty-lines: 216 | - warn 217 | - max: 3 218 | # no-nested-ternary: error 219 | no-new-object: error 220 | # no-plusplus: 221 | # - warn 222 | # - allowForLoopAfterthoughts: true 223 | no-trailing-spaces: warn 224 | no-unneeded-ternary: 225 | - warn 226 | - defaultAssignment: false 227 | no-whitespace-before-property: error 228 | nonblock-statement-body-position: 229 | - error 230 | - beside 231 | object-curly-newline: 232 | - off 233 | # - warn 234 | # - ObjectExpression: 235 | # multiline: true 236 | # ObjectPattern: 237 | # multiline: true 238 | object-curly-spacing: warn 239 | object-property-newline: 240 | - warn 241 | - allowAllPropertiesOnSameLine: true 242 | one-var: 243 | - warn 244 | - initialized: never 245 | operator-assignment: warn 246 | operator-linebreak: 247 | - error 248 | - before 249 | padded-blocks: 250 | - warn 251 | - never 252 | # padding-line-between-statements 253 | quote-props: 254 | - warn 255 | - as-needed 256 | quotes: 257 | - warn 258 | - single 259 | - avoidEscape: true 260 | allowTemplateLiterals: true 261 | semi: 262 | - error 263 | - always 264 | semi-spacing: 265 | - warn 266 | - before: false 267 | after: true 268 | semi-style: error 269 | space-before-blocks: 270 | - warn 271 | - always 272 | space-before-function-paren: 273 | - warn 274 | - never 275 | space-in-parens: 276 | - warn 277 | - never 278 | space-unary-ops: 279 | - warn 280 | - words: true 281 | nonwords: false 282 | spaced-comment: 283 | - warn 284 | - always 285 | - exceptions: 286 | - "-*" 287 | switch-colon-spacing: warn 288 | template-tag-spacing: warn 289 | 290 | # "ECMAScript 6" 291 | arrow-body-style: 292 | - warn 293 | - as-needed 294 | arrow-parens: 295 | - warn 296 | - as-needed 297 | - requireForBlockBody: true 298 | arrow-spacing: warn 299 | generator-star-spacing: 300 | - warn 301 | - named: after 302 | anonymous: before 303 | method: after 304 | no-useless-computed-key: warn 305 | no-useless-constructor: warn 306 | no-var: error 307 | prefer-arrow-callback: 308 | - warn 309 | - allowNamedFunctions: true 310 | prefer-spread: warn 311 | # prefer-template: warn 312 | rest-spread-spacing: 313 | - warn 314 | - never 315 | symbol-description: warn 316 | template-curly-spacing: warn 317 | yield-star-spacing: warn 318 | 319 | no-fallthrough: warn 320 | 321 | # Custom Rules 322 | 323 | 324 | # unspecified: 325 | # padding-line-between-statements 326 | # array-bracket-newline 327 | # array-element-newline 328 | # camel-case -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .git-* 3 | *.ignore 4 | build/ 5 | node_modules/ 6 | scrap/ 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '14' 4 | env: 5 | global: 6 | - secure: bOThtfGKwzKz4ZYjTRF61VelU2MMCNU5Y0DA3oFhJulk8kF2wXwojGJeK8K16Ny6yn5suVW49SUqdNh/RasyaWGwRiAGFPacUTwMW7PccMZ2OIEtFvrEe0G2fMrMwfd9wUtm7llGNe/4WDYUodXMTfwQl0gBPtqK+y87aZbKchpqoQlNKMHnBskA3VdZ5WRzCHZkP0eQheI44LKsmDimwLK5YbNoH2vXU4wv23tiBSWmgNk1UHWMyz/SGoDo8AkP51Y5ej8MbQOxHzfB4S+x0yPs7kEFQ9ieNL0SFzeFd3LET8c06YhADm6bGfylPzd/h8//vN6JzNAAtVBeI72kno8FCRw2/nod6ZGlrKzUoZfELB3qMnhqtxXnyDu9E2hHgjZpWPxgnTU5mig8Tn+p+Nl7VOQ96njmGomylmRvSw8yjc9OinBcrzG2WP9c+kKhkFmLCJhg7rwxzhYcggPaLdPXY7vjsaEtb+FROX98Qgq6ydk7m0Vpfep1M1Yn0hHGnCR7YSeiOzQcza+VgxKKehKC3DIUvGQUKSqvCOqsJruzJTouptp8We9e1lIFnpKvCPRgd4SNqxytCd6MNW/ncOJrtYQhLuI2EMmhJYcgfra/Wt6yVu8m2NTgTUy8B9tCQwyiT5MqcXTs0TxCwqZAOY4mWP0M8Ial5Q4HTc3kPPo= 7 | deploy: 8 | provider: releases 9 | api_key: 10 | secure: UBDeFtv8vBWhWy0FvAFEnwKTfldPqRuQ3M0mSljeSDWJMeKgW28ew4QCYTVXwmWPpJLPZLObyq19R6DW0qT3VM52/eKtGZwOLRIhgtCLUUu8jY6dIx9b411OQ990aAAS06HJ1eomrpFXIoVrz8wiPpwRaPYFW1d9H9J6v8cn6XSmujO1bi/sagAnE4YmHilgC/zCbF63lExAOJd/sAfJTSzWUP8RTB7HJ4WZvPPzswjFouunPOXSF5tZREoFIDX1iuzvunOdpcLzuiP22VRTWYd1rHYyHj5WOxWki57HrK+BaL7YUpcvRJ4qspEpxwpUTJCLP3qhyPXvUBK1BpzHi3r6RQl1ts23teVBtfYMZT8x/vPLizj46w/8aaRbWBxYL7LGwiTnCPXz5bbICdDJ9WrVMa0tYb+IetMDhG3Y/x7XpQuVf15H0BnbHhpoqZFQZF1aT52/bC5osQ2lzNnTr6noLpueT52UwMZ8kK59qGmg1q0bkIMhJkKjf23Y+VAk7IFZ1CwLqnofqPcJj7uG8MfVbnDV+Q94zd1s9bpNa9FvlHvzGTLb+yMfZ3Zr3Y0uE7TkVMMWt3VKjIJ7BC3m5C50Cc/bDn8zqdwc4suetlLLZi9YomMgvmOeeFMG4uQfi4Ma0CF1oyuXnacnB7WbuWOsPoBah4WtbDLZoupPE98= 11 | file_glob: true 12 | file: build/sublime_*/* 13 | skip_cleanup: true 14 | on: 15 | tags: true 16 | after_deploy: 17 | - ./push-assets.sh 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Blake Regalia 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Syntax highlighting for Linked Data developers 2 | 3 | Each syntax highlighter in this package covers the *entire* grammar specification for its language. This provides very high-resolution scopes and immediately shows invalid syntax using special alert highlighting and [all tokens are inspectable](https://superuser.com/questions/848836/how-do-i-see-what-the-current-scope-is-in-sublimetext). 4 | 5 | ### Install: 6 | Available on [Package Control](https://packagecontrol.io/packages/LinkedData) as `LinkedData` . 7 | 8 | Alternatively, you can download the `.sublime-package` file (or the source code archives) from the [Releases](https://github.com/blake-regalia/linked-data.syntaxes/releases). 9 | 10 | #### Features: 11 | - Highly-resolution scoping allows for very detailed color schemes. 12 | - Malformed syntax detection. Expected token(s) are [inspectable via scope name](https://superuser.com/questions/848836/how-do-i-see-what-the-current-scope-is-in-sublimetext). 13 | - Auto-completion and validation for prefix mappings registered on [prefix.cc](http://prefix.cc). 14 | 15 | #### Currently supported languages: 16 | - [SPARQL 1.1](https://www.w3.org/TR/sparql11-query/) and [SPARQL*](https://blog.liu.se/olafhartig/2019/01/10/position-statement-rdf-star-and-sparql-star/) 17 | - [RDF 1.1 Turtle](https://www.w3.org/TR/turtle/) (TTL), [Turtle*](https://blog.liu.se/olafhartig/2019/01/10/position-statement-rdf-star-and-sparql-star/), and [RDF 1.1 TriG](https://www.w3.org/TR/trig/) 18 | - [ShExC 2.1](https://shex.io/shex-semantics/#shexc) 19 | - [RDF 1.1 N-Triples](https://www.w3.org/TR/n-triples/) (NT) and [RDF 1.1 N-Quads](https://www.w3.org/TR/n-quads/) (NQ) 20 | - [Notation3](https://www.w3.org/TeamSubmission/n3/) (N3) 21 | 22 | #### Currently supported platforms: 23 | - Sublime Text 3 24 | 25 | #### Currently supported color themes: 26 | - Macaron Dark 27 | - Macaron Light (in beta) 28 | 29 | #### *Planned langauage support*: 30 | - OWL Manchester 31 | - OWL Functional-Style 32 | - RDFa 33 | - JSON-LD 34 | 35 | #### *Planned platform support*: 36 | - Atom 37 | - CodeMirror 38 | - Emacs 39 | - minted (LaTeX) 40 | - ~Ace~ 41 | 42 | #### *Planned color theme support* 43 | - *Suggestions?* 44 | 45 | 46 | ### Activating the Light Color Scheme 47 | This package ships with two color schemes which were designed specifically for the high-resolution scopes that the syntax highlighting definitions create. By default, this package will use the [Macaron Dark](#macaron-dark) color scheme. If you prefer to use [Macaron Light](#macaron-light), you'll need to create a settings file to override the syntaxes defined below: 48 | 49 | First, create a new file in Sublime and paste these contents into it: 50 | ```json 51 | // These settings will override both User and Default settings for the specific LinkedData syntaxes 52 | { 53 | "color_scheme": "Packages/LinkedData/macaron-light.sublime-color-scheme" 54 | } 55 | ``` 56 | 57 | Next, save this file as `LinkedData.sublime-settings` under the `User/` folder in the [Sublime Text 3 Packages directory](https://stackoverflow.com/a/49967132/1641160). That is, the path should end with: `[...]/Packages/User/LinkedData.sublime-settings` . 58 | 59 | Finally, create a new symbolic link to this file for each syntax. The files should be in the same `User` subdirectory as the other file: 60 | 61 | For Linux and Mac, open terminal in this directory and run: 62 | ```bash 63 | ln -s LinkedData.sublime-settings n-triples.sublime-settings 64 | ln -s LinkedData.sublime-settings n-quads.sublime-settings 65 | ln -s LinkedData.sublime-settings turtle.sublime-settings 66 | ln -s LinkedData.sublime-settings trig.sublime-settings 67 | ln -s LinkedData.sublime-settings notation3.sublime-settings 68 | ln -s LinkedData.sublime-settings shex.sublime-settings 69 | ln -s LinkedData.sublime-settings sparql.sublime-settings 70 | ``` 71 | 72 | For Windows, open command prompt in this directory and run: 73 | ```cmd 74 | mklink n-triples.sublime-settings LinkedData.sublime-settings 75 | mklink n-quads.sublime-settings LinkedData.sublime-settings 76 | mklink turtle.sublime-settings LinkedData.sublime-settings 77 | mklink trig.sublime-settings LinkedData.sublime-settings 78 | mklink notation3.sublime-settings LinkedData.sublime-settings 79 | mklink shex.sublime-settings LinkedData.sublime-settings 80 | mklink sparql.sublime-settings LinkedData.sublime-settings 81 | ``` 82 | 83 | This will override the default color scheme when any of these syntaxes are loaded in the current view. 84 | 85 | 86 | --- 87 | 88 | ## Previews: 89 | 90 | ### Macaron Dark 91 | 92 | #### Turtle: 93 | ![Turtle Preview](doc/preview/macaron-dark/turtle.png) 94 | 95 | #### SPARQL: 96 | ![SPARQL Preview](doc/preview/macaron-dark/sparql.png) 97 | 98 | #### ShExC: 99 | ![ShExC Preview](doc/preview/macaron-dark/shex.png) 100 | 101 | ### Macaron Light 102 | 103 | #### Turtle: 104 | ![Turtle Preview](doc/preview/macaron-light/turtle.png) 105 | 106 | #### SPARQL: 107 | ![SPARQL Preview](doc/preview/macaron-light/sparql.png) 108 | 109 | #### ShExC: 110 | ![ShExC Preview](doc/preview/macaron-light/shex.png) 111 | 112 | -------------------------------------------------------------------------------- /channels/sublime/package-control.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema_version": "3.0.0", 3 | "packages": [ 4 | { 5 | "name": "LinkedData", 6 | "details": "https://github.com/blake-regalia/linked-data.syntaxes", 7 | "labels": [ 8 | "semantic web", 9 | "linked data", 10 | "rdf", 11 | "n-triples", 12 | "n-quads", 13 | "turtle", 14 | "trig", 15 | "n3", 16 | "notation3", 17 | "sparql" 18 | ], 19 | "releases": [ 20 | { 21 | "version": "1.0.4", 22 | "sublime_text": ">=3092 <4000", 23 | "url": "https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/assets/build/sublime_3/LinkedData.sublime-package", 24 | "date": "2021-11-18 18:40:43" 25 | }, 26 | { 27 | "version": "1.0.4", 28 | "sublime_text": ">=4000", 29 | "url": "https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/assets/build/sublime_4/LinkedData.sublime-package", 30 | "date": "2021-11-18 18:40:43" 31 | } 32 | ] 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /doc/preview/macaron-dark/shex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/d8ba9f81c6233cf5f041ba4561b8c0576bbdba37/doc/preview/macaron-dark/shex.png -------------------------------------------------------------------------------- /doc/preview/macaron-dark/sparql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/d8ba9f81c6233cf5f041ba4561b8c0576bbdba37/doc/preview/macaron-dark/sparql.png -------------------------------------------------------------------------------- /doc/preview/macaron-dark/turtle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/d8ba9f81c6233cf5f041ba4561b8c0576bbdba37/doc/preview/macaron-dark/turtle.png -------------------------------------------------------------------------------- /doc/preview/macaron-light/shex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/d8ba9f81c6233cf5f041ba4561b8c0576bbdba37/doc/preview/macaron-light/shex.png -------------------------------------------------------------------------------- /doc/preview/macaron-light/sparql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/d8ba9f81c6233cf5f041ba4561b8c0576bbdba37/doc/preview/macaron-light/sparql.png -------------------------------------------------------------------------------- /doc/preview/macaron-light/turtle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/d8ba9f81c6233cf5f041ba4561b8c0576bbdba37/doc/preview/macaron-light/turtle.png -------------------------------------------------------------------------------- /emk.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | const p_prefixes_jsonld = 'http://prefix.cc/context.jsonld'; 4 | const p_package = 'development' === process.env.NODE_ENV? 'Packages/User/linked-data': 'Packages/LinkedData'; 5 | 6 | 7 | const A_SYNTAX_DEPS_ALL = [ 8 | 'build/context.jsonld', 9 | ]; 10 | 11 | const G_SYNTAX_DEPS = { 12 | get human_readable() { 13 | return [ 14 | ...A_SYNTAX_DEPS_ALL, 15 | `src/syntax/human-readable.syntax-source`, 16 | ]; 17 | }, 18 | get terse() { 19 | return [ 20 | ...this.human_readable, 21 | 'src/syntax/terse.syntax-source', 22 | ]; 23 | }, 24 | get verbose() { 25 | return [ 26 | ...this.human_readable, 27 | 'src/syntax/verbose.syntax-source', 28 | ]; 29 | }, 30 | get t_family() { 31 | return [ 32 | ...this.terse, 33 | 'src/syntax/t-family.syntax-source', 34 | ]; 35 | }, 36 | }; 37 | 38 | const G_SYNTAXES = { 39 | 'n-triples': { 40 | supplementals: {}, 41 | dependencies: G_SYNTAX_DEPS.verbose, 42 | }, 43 | 'n-quads': { 44 | supplementals: {}, 45 | dependencies: G_SYNTAX_DEPS.verbose, 46 | }, 47 | sparql: { 48 | supplementals: {}, 49 | dependencies: G_SYNTAX_DEPS.terse, 50 | }, 51 | notation3: { 52 | supplementals: {}, 53 | dependencies: G_SYNTAX_DEPS.terse, 54 | }, 55 | turtle: { 56 | supplementals: {}, 57 | dependencies: G_SYNTAX_DEPS.t_family, 58 | }, 59 | trig: { 60 | supplementals: {}, 61 | dependencies: G_SYNTAX_DEPS.t_family, 62 | }, 63 | shex: { 64 | supplementals: {}, 65 | dependencies: G_SYNTAX_DEPS.terse, 66 | }, 67 | }; 68 | 69 | const A_COLOR_SCHEMES = [ 70 | 'macaron-dark', 71 | 'macaron-light', 72 | ]; 73 | 74 | const sublime_build = s_version => ({ 75 | 'LinkedData.sublime-package': () => ({ 76 | deps: [`build/sublime_${s_version}/assets/*`], 77 | run: /* syntax: bash */ ` 78 | cd $(dirname $@) 79 | zip -r $(basename $@) assets/ 80 | `, 81 | }), 82 | 83 | assets: { 84 | LICENSE: () => ({ 85 | copy: 'LICENSE', 86 | }), 87 | 88 | ':syntax': [s_syntax => ({ 89 | [`${s_syntax}.sublime-syntax`]: () => ({ 90 | deps: [ 91 | 'src/main/sublime-syntax.js', 92 | `src/syntax/${s_syntax}.syntax-source`, 93 | ...G_SYNTAXES[s_syntax].dependencies, 94 | ], 95 | 96 | run: /* syntax: bash */ ` 97 | node $1 $2 < $3 > $@ 98 | `, 99 | }), 100 | 101 | [`${s_syntax}.sublime-settings`]: () => ({ 102 | deps: [ 103 | 'src/supplementals/settings.jmacs.sublime-settings', 104 | ], 105 | 106 | run: /* syntax: bash */ ` 107 | npx jmacs -g '${/* eslint-disable indent */JSON.stringify({ 108 | PACKAGE_PATH: p_package, 109 | COLOR_SCHEME: A_COLOR_SCHEMES[0], 110 | })}' $1 > $@ 111 | `, 112 | }), 113 | 114 | ...G_SYNTAXES[s_syntax].supplementals, 115 | })], 116 | 117 | 'prefix-declarations.:declaration_type.sublime-completions': h => ({ 118 | deps: [ 119 | 'src/supplementals/completions.js', 120 | 'build/context.jsonld', 121 | ], 122 | 123 | run: /* syntax: bash */ ` 124 | node $1 '${h.declaration_type}' < $2 > $@ 125 | `, 126 | }), 127 | 128 | ':color_scheme.sublime-color-scheme': h => ({ 129 | deps: [ 130 | 'src/main/color-scheme.js', 131 | `src/color-schemes/${h.color_scheme}.js`, 132 | 'src/color-schemes/base/dark.js', 133 | 'src/color-schemes/base/light.js', 134 | ], 135 | 136 | run: /* syntax: bash */ ` 137 | node $1 ${h.color_scheme} ${s_version} > $@ 138 | `, 139 | }), 140 | 141 | 'linked-data.:preference.tmPreferences': h => ({ 142 | deps: [ 143 | `src/supplementals/${h.preference}.preferences.yaml`, 144 | ], 145 | 146 | run: /* syntax: bash */ ` 147 | npx syntax-source convert --from=yaml --to=plist < $1 > $@ 148 | `, 149 | }), 150 | }, 151 | }); 152 | 153 | module.exports = { 154 | defs: { 155 | color_scheme: A_COLOR_SCHEMES, 156 | 157 | syntax: Object.keys(G_SYNTAXES), 158 | 159 | declaration_type: [ 160 | 'sparql', 161 | 'at', 162 | ], 163 | 164 | preference: fs.readdirSync('src/supplementals') 165 | .filter(s => s.endsWith('.preferences.yaml')) 166 | .map(s => s.replace(/\.preferences\.yaml$/, '')), 167 | 168 | version_bump: [ 169 | 'patch', 170 | 'minor', 171 | 'major', 172 | ], 173 | }, 174 | 175 | tasks: { 176 | all: 'build/**', 177 | 178 | release: 'channels/**', 179 | 180 | syntax: { 181 | ':syntax': h => `build/${h.syntax}.sublime-syntax`, 182 | }, 183 | }, 184 | 185 | outputs: { 186 | channels: { 187 | sublime: { 188 | 'package-control.json': () => ({ 189 | deps: [ 190 | 'src/channel/package-control.js', 191 | 'package.json', 192 | 'build/sublime_3/**', 193 | 'build/sublime_4/**', 194 | ], 195 | run: /* syntax: bash */ ` 196 | node $1 < $2 > $@ 197 | `, 198 | }), 199 | }, 200 | }, 201 | 202 | build: { 203 | 'context.jsonld': () => ({ 204 | run: /* syntax: bash */ ` 205 | curl ${p_prefixes_jsonld} > $@ 206 | `, 207 | }), 208 | 209 | sublime_3: sublime_build('3'), 210 | sublime_4: sublime_build('4'), 211 | 212 | 213 | // ace: { 214 | // ':syntax': [s_syntax => ({ 215 | // [`${s_syntax}.js`]: () => ({ 216 | // deps: [ 217 | // 'src/ace/mode.jmacs.js', 218 | // ], 219 | 220 | // run: /* syntax: bash */ ` 221 | // npx jmacs -g '{SYNTAX:"${s_syntax}"}' $1 > $@ 222 | // `, 223 | // }), 224 | 225 | // [`${s_syntax}_highlight_rules.js`]: () => ({ 226 | // deps: [ 227 | // 'src/main/ace-syntax.js', 228 | // `src/syntax/${s_syntax}.syntax-source`, 229 | // ...G_SYNTAXES[s_syntax].dependencies, 230 | // ], 231 | 232 | // run: /* syntax: bash */ ` 233 | // node $1 $2 < $3 > $@ 234 | // node_exit=$? 235 | // if [ $node_exit -ne 0 ]; then exit $node_exit; fi 236 | 237 | // eslint --fix --color --rule 'no-debugger: off' $@ 238 | // eslint_exit=$? 239 | // # do not fail on warnings 240 | // if [ $eslint_exit -eq 2 ]; then 241 | // exit 0 242 | // fi 243 | // exit $eslint_exit 244 | // `, 245 | // }), 246 | // })], 247 | // }, 248 | }, 249 | }, 250 | }; 251 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linked-data.syntaxes", 3 | "version": "1.0.4", 4 | "private": true, 5 | "license": "ISC", 6 | "author": { 7 | "name": "Blake Regalia", 8 | "email": "blake.regalia@gmail.com" 9 | }, 10 | "scripts": { 11 | "build": "npx emk && npx emk && npx emk", 12 | "test": "npm run build" 13 | }, 14 | "repository": "blake-regalia/linked-data.syntaxes", 15 | "devDependencies": { 16 | "emk": "^2.0.0", 17 | "eslint": "^7.7.0", 18 | "jmacs": "^1.4.0", 19 | "js-yaml": "^3.14.0", 20 | "syntax-source": "^0.4.3" 21 | }, 22 | "dependencies": {} 23 | } 24 | -------------------------------------------------------------------------------- /push-assets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PACKAGE_VERSION="${TRAVIS_COMMIT_MESSAGE}" 3 | git checkout --orphan assets 4 | git reset --hard 5 | git rm --cached -r . 6 | git add build/sublime_3/LinkedData.sublime-package 7 | git add build/sublime_4/LinkedData.sublime-package 8 | git commit -m "v${PACKAGE_VERSION}" 9 | git remote add github-asset "https://blake-regalia:${GITHUB_OAUTH_TOKEN}@github.com/blake-regalia/linked-data.syntaxes.git" 10 | git push -f github-asset assets 11 | -------------------------------------------------------------------------------- /src/ace/mode.jmacs.js: -------------------------------------------------------------------------------- 1 | /* global define */ 2 | let a_imports = [ 3 | 'ace/lib/oop', 4 | 'ace/mode/text_highlight_rules', 5 | 'ace/mode/sparql_highlight_rules', 6 | ]; 7 | 8 | require('brace').define('ace/mode/@{SYNTAX}', a_imports, (ace_require, exports, module) => { 9 | const oop = ace_require('ace/lib/oop'); 10 | const TextMode = ace_require('ace/mode/text').Mode; 11 | const HighlightRules = ace_require('ace/mode/@{SYNTAX}_highlight_rules').HighlightRules; 12 | // let JavaFoldMode = require('./folding/java').FoldMode; 13 | 14 | let Mode = function() { 15 | this.HighlightRules = HighlightRules; 16 | // this.foldingRules = new JavaFoldMode(); 17 | }; 18 | oop.inherits(Mode, TextMode); 19 | 20 | (function() { 21 | // this.createWorker = function(session) { 22 | // return null; 23 | // }; 24 | 25 | this.$id = 'ace/mode/@{SYNTAX}'; 26 | }).call(Mode.prototype); 27 | 28 | exports.Mode = Mode; 29 | }); 30 | -------------------------------------------------------------------------------- /src/channel/package-control.js: -------------------------------------------------------------------------------- 1 | let s_package = ''; 2 | process.stdin.setEncoding('utf8'); 3 | process.stdin 4 | .on('data', (s_chunk) => { 5 | s_package += s_chunk; 6 | }) 7 | .on('end', () => { 8 | let g_package = JSON.parse(s_package); 9 | 10 | // generate channel json for package 11 | let g_channel = { 12 | schema_version: '3.0.0', 13 | packages: [ 14 | { 15 | name: 'LinkedData', 16 | details: 'https://github.com/blake-regalia/linked-data.syntaxes', 17 | labels: [ 18 | 'semantic web', 'linked data', 'rdf', 19 | 'n-triples', 20 | 'n-quads', 21 | 'turtle', 22 | 'trig', 23 | 'n3', 'notation3', 24 | 'sparql', 25 | ], 26 | releases: [ 27 | { 28 | version: g_package.version, 29 | sublime_text: '>=3092 <4000', 30 | url: 'https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/assets/build/sublime_3/LinkedData.sublime-package', 31 | date: (new Date()).toISOString().replace(/T/, ' ').replace(/\.\d+Z/, ''), 32 | }, 33 | { 34 | version: g_package.version, 35 | sublime_text: '>=4000', 36 | url: 'https://raw.githubusercontent.com/blake-regalia/linked-data.syntaxes/assets/build/sublime_4/LinkedData.sublime-package', 37 | date: (new Date()).toISOString().replace(/T/, ' ').replace(/\.\d+Z/, ''), 38 | }, 39 | ], 40 | }, 41 | ], 42 | }; 43 | 44 | // dump to output 45 | process.stdout.write(JSON.stringify(g_channel, null, '\t')); 46 | }); 47 | -------------------------------------------------------------------------------- /src/color-schemes/base/dark.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | globals: { 3 | foreground: '#bebbb0', 4 | background: '#252525', 5 | gutter: '#323232', 6 | caret: '#c9c9c3', 7 | accent: '#ff00ff', 8 | 9 | bracket_contents_options: 'stippled_underline', 10 | brackets_options: 'stippled_underline', 11 | 12 | guide: '#323334', 13 | stack_guide: '#3b3c3d', 14 | active_guide: '#48494a', 15 | 16 | line_highlight: '#3e3e3e', 17 | multi_edit_highlight: '#a5eb5144', 18 | find_highlight: '#e9ee5f99', 19 | selection: '#575757', 20 | }, 21 | 22 | rules: [ 23 | // comment 24 | { 25 | foreground: '#758b99', 26 | font_style: 'italic', 27 | scope: 'comment', 28 | }, 29 | 30 | // invalid 31 | { 32 | background: '#7f225a', 33 | foreground: '#bd5393', 34 | scope: 'invalid', 35 | }, 36 | ], 37 | }; 38 | -------------------------------------------------------------------------------- /src/color-schemes/base/light.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | globals: { 3 | foreground: '#333366', 4 | background: '#eff1f5', 5 | gutter: '#c0c5ce', 6 | caret: '#666666', 7 | accent: '#333333', 8 | invisibles: '#bbbbcc77', 9 | 10 | // bracket_contents_options: 'stippled_underline', 11 | // brackets_options: 'stippled_underline', 12 | 13 | // guide: '#323334', 14 | // stack_guide: '#3b3c3d', 15 | // active_guide: '#48494a', 16 | 17 | line_highlight: '#a7adba', 18 | multi_edit_highlight: '#a5eb5144', 19 | find_highlight: '#ffe792', 20 | find_highlight_foreground: '#ffe792', 21 | 22 | selection: '#dfe1e8', 23 | selection_border: '#b0cde7', 24 | shadow: '#dfe1e8', 25 | }, 26 | 27 | rules: [ 28 | // comment 29 | { 30 | foreground: 'hsla(0, 70%, 26%, 0.7)', 31 | font_style: 'italic', 32 | scope: 'comment', 33 | }, 34 | 35 | // invalid 36 | { 37 | foreground: '#6600771b', 38 | background: '#ff6677dd', 39 | scope: 'invalid', 40 | }, 41 | ], 42 | }; 43 | -------------------------------------------------------------------------------- /src/color-schemes/macaron-dark.js: -------------------------------------------------------------------------------- 1 | const a_regex_scopes = require('./shared/regex-scopes.js'); 2 | 3 | /* eslint-disable global-require */ 4 | module.exports = { 5 | // base color scheme def 6 | base: { 7 | ...require('./base/dark.js'), 8 | name: 'Macaron Dark (LinkedData)', 9 | variables: { 10 | root: 'hsl(199, 56%, 73%)', 11 | scape: 'hsl(344, 81%, 81%)', 12 | flare: 'hsl(42, 98%, 83%)', 13 | echo: 'hsl(175, 54%, 69%)', 14 | chip: 'hsl(250, 48%, 92%)', 15 | 16 | root_boost: 'hsl(199, 85%, 73%)', 17 | scape_boost: 'hsl(314, 94%, 83%)', 18 | flare_boost: 'hsl(32, 100%, 81%)', 19 | echo_boost: 'hsl(175, 85%, 69%)', 20 | chip_boost: 'hsl(250, 83%, 87%)', 21 | }, 22 | }, 23 | 24 | // extra rules to append 25 | rules: [ 26 | // registered prefixes 27 | { 28 | scope: 'meta.prefix-declaration.either.registered', 29 | background: 'hsla(220, 23%, 10%, 0.62)', 30 | }, 31 | 32 | // inverse path 33 | { 34 | scope: 'meta.path.inverse', 35 | background: 'hsla(226, 94%, 12%, 0.28)', 36 | font_style: 'italic', 37 | }, 38 | 39 | // negated path 40 | { 41 | scope: 'meta.path.negated', 42 | background: 'hsla(290, 84%, 10%, 0.38)', 43 | }, 44 | 45 | // plus quantifier 46 | { 47 | scope: 'keyword.operator.path.quantifier.one-or-more', 48 | font_style: 'bold', 49 | }, 50 | 51 | // storage modifier 52 | { 53 | scope: 'storage.modifier', 54 | font_style: 'italic', 55 | }, 56 | 57 | // annotation 58 | { 59 | scope: 'meta.annotation', 60 | font_style: 'italic', 61 | background: 'hsla(0, 0%, 0%, 0.1)', 62 | foreground_adjust: 'saturation(35%)', 63 | }, 64 | 65 | // { 66 | // scope: 'meta.term.role.label.shape-expression.declaration', 67 | // font_style: 'bold', 68 | // }, 69 | 70 | { 71 | scope: 'meta.term.role.label.triple-expression', 72 | background: 'hsla(260, 50%, 50%, 0.1)', 73 | foreground_adjust: 'saturation(55%)', 74 | }, 75 | 76 | // shape-definition inclusion 77 | { 78 | scope: 'meta.term.role.include', 79 | background: 'hsla(252, 24%, 7%, 0.28)', 80 | // background: 'hsla(252, 24%, 50%, 0.1)', 81 | }, 82 | 83 | // value-set exclusion 84 | { 85 | scope: 'meta.term.role.exclusion', 86 | background: 'hsla(12, 74%, 14%, 0.6)', 87 | // background: 'hsla(252, 24%, 50%, 0.1)', 88 | }, 89 | 90 | // reified statement 91 | { 92 | scope: 'meta.triple.reified', 93 | background: 'hsla(280, 70%, 10%, 0.2)', 94 | }, 95 | 96 | // nested reified statement 97 | { 98 | scope: 'meta.triple.reified-nested', 99 | background: 'hsla(280, 70%, 10%, 0.4)', 100 | }, 101 | 102 | 103 | // shared regex scopes 104 | ...a_regex_scopes, 105 | ], 106 | 107 | // blends 108 | blends: { 109 | root: { 110 | // `@` as in `@prefix` 111 | 'punctuation.definition.storage storage.type': -25, 112 | 113 | // prefix / base 114 | 'storage.type': -20, 115 | 116 | // distinct / reduced 117 | 'storage.modifier': -8, 118 | 119 | // all 'other' keywords (namely modifiers) 120 | 'keyword.operator': 5, 121 | 122 | // 123 | 'keyword.operator.quantifier': 70, 124 | 125 | // `graph` 126 | 'keyword.control': -15, 127 | 128 | 'punctuation.section.formula': -20, 129 | }, 130 | 131 | root_boost: { 132 | // qualifier keywords 133 | 'keyword.operator.word.qualifier': -10, 134 | 135 | // where clause brace 136 | 'punctuation.section, meta.clause.where': 10, 137 | 138 | // built-ins 139 | 'support.function': 0, 140 | 'punctuation.definition.expression': -15, 141 | 'punctuation.definition.arguments': 25, 142 | 143 | // `as` 144 | 'storage.type.variable': -15, 145 | 146 | 'keyword.operator.path': 0, 147 | 'punctuation.section.group': -20, 148 | 'punctuation.section.block': -15, 149 | 'meta.path.negated punctuation.section.group': -10, 150 | 'meta.path.inverse punctuation.section.group': -10, 151 | 152 | // constants `true` and `false` 153 | 'constant.language': -5, 154 | 155 | // n3 predicates 156 | 'keyword.operator.predicate': 0, 157 | 158 | 'keyword.operator.unary.label': 15, 159 | }, 160 | 161 | scape: { 162 | // prefixes 163 | 'variable.other.readwrite.prefixed-name.namespace': -25, 164 | 'punctuation.separator.prefixed-name': -10, 165 | 'variable.other.member.prefixed-name.local': 10, 166 | 167 | 168 | 'constant.character.escape.prefixed-name': -5, 169 | 170 | // `a` 171 | 'support.constant.predicate.a': -50, 172 | 173 | 'keyword.operator.unary.exclusion': -30, 174 | 'punctuation.terminator.exclusion': 15, 175 | }, 176 | 177 | scape_boost: { 178 | 'variable.other.member.barename': 20, 179 | 180 | 'keyword.operator.unary.reference.shape': -5, 181 | 182 | 'meta.term.role.include punctuation.definition.iri': -60, 183 | 'meta.term.role.include string.unquoted.iri': 15, 184 | 185 | 'meta.term.role.label.shape-expression.declaration variable.other.readwrite.prefixed-name.namespace': -20, 186 | 'meta.term.role.label.shape-expression.declaration variable.other.member.prefixed-name.local': 45, 187 | }, 188 | 189 | flare: { 190 | // datatype symbol `^^` 191 | 'punctuation.separator.datatype.symbol': -65, 192 | 193 | // prefixed-names 194 | 'meta.datatype variable.other.readwrite.prefixed-name.namespace': -50, 195 | 'meta.datatype variable.other.member.prefixed-name.local': -35, 196 | 197 | // iri datatypes 198 | 'meta.datatype string.unquoted.iri': -25, 199 | 'meta.datatype constant.character.escape.iri': -40, 200 | 'meta.datatype punctuation.definition.iri': -50, 201 | 202 | // shex value set 203 | 'punctuation.section.value-set': -20, 204 | 205 | // blank node property list 206 | 'punctuation.definition.blank-node-property-list': 5, 207 | 'punctuation.definition.property-list': 5, // n3 208 | 'punctuation.definition.anonymous-blank-node': -45, 209 | 210 | // terminators and separators 211 | 'punctuation.separator.object': -40, 212 | 'punctuation.separator.pair': -20, 213 | 'punctuation.separator.predicate-object-list': -40, 214 | 'punctuation.separator.property-list': -40, // n3 215 | 'punctuation.separator.triple-expression': -40, // shexc 216 | 'punctuation.terminator.triple': 100, 217 | 'punctuation.terminator.statement': 100, // n3 218 | 'punctuation.terminator.graph-pattern': -60, 219 | 'punctuation.terminator.prefix-declaration': 40, 220 | 'punctuation.terminator.shape-atom': -20, 221 | }, 222 | 223 | flare_boost: { 224 | // variables 225 | 'variable.other.readwrite.var': -15, 226 | 227 | // 228 | // 'punctuation.definition.value-set': -15, 229 | 230 | 'meta.term.role.include variable.other.readwrite.prefixed-name.namespace': -25, 231 | 'meta.term.role.include variable.other.member.prefixed-name.local': 10, 232 | 233 | }, 234 | 235 | echo: { 236 | // literasls 237 | 'string.quoted.double.literal, string.quoted.single.literal': -15, 238 | 'punctuation.definition.string': -35, 239 | 'constant.character.escape.literal': -50, 240 | 241 | // regex 242 | 'string.regexp': -10, 243 | 244 | // language-tags 245 | 'string.unquoted.language-tag': -5, 246 | 'punctuation.separator.language-tag.symbol': -60, 247 | 'string.unquoted.barename': -30, 248 | 249 | // numerics 250 | 'keyword.operator.arithmetic': -0, 251 | 'constant.numeric': -15, 252 | 'meta.numeric.exponent': -40, 253 | 254 | // shex 255 | 'punctuation.definition.repeat-range': -45, 256 | 'punctuation.separator.repeat-range': -55, 257 | 258 | 259 | }, 260 | 261 | echo_boost: { 262 | 'support.constant': -15, 263 | 264 | 'text.plain': 35, 265 | }, 266 | 267 | chip: { 268 | // iris 269 | 'string.unquoted.iri': -20, 270 | 'constant.character.escape.iri': -40, 271 | 'punctuation.definition.iri': -55, 272 | 273 | // collection punctuation 274 | 'punctuation.definition.collection': 20, 275 | 276 | // blank nodes 277 | 'variable.other.readwrite.blank-node.underscore': -45, 278 | 'variable.other.member.blank-node.label': -10, 279 | 280 | // rdf-star 281 | 'punctuation.definition.triple-x': -30, 282 | }, 283 | 284 | chip_boost: { 285 | 'meta.directive': -45, 286 | 'punctuation.definition.annotation': -30, 287 | 288 | 'keyword.operator.unary.include': -15, 289 | 290 | 'meta.term.role.label.shape-expression.declaration punctuation.definition.iri': -60, 291 | 'meta.term.role.label.shape-expression.declaration string.unquoted.iri': 20, 292 | }, 293 | 294 | }, 295 | }; 296 | -------------------------------------------------------------------------------- /src/color-schemes/macaron-light.js: -------------------------------------------------------------------------------- 1 | const a_regex_scopes = require('./shared/regex-scopes.js'); 2 | 3 | /* eslint-disable global-require */ 4 | module.exports = { 5 | // base color scheme def 6 | base: { 7 | ...require('./base/light.js'), 8 | name: 'Macaron Light (LinkedData)', 9 | variables: { 10 | root: 'hsl(199, 56%, 51%)', 11 | scape: 'hsl(344, 81%, 65%)', 12 | flare: 'hsl(42, 98%, 66%)', 13 | echo: 'hsl(175, 58%, 53%)', 14 | chip: 'hsl(250, 48%, 69%)', 15 | 16 | root_boost: 'hsl(199, 85%, 53%)', 17 | scape_boost: 'hsl(316, 94%, 31%)', 18 | flare_boost: 'hsl(42, 100%, 61%)', 19 | echo_boost: 'hsl(175, 85%, 53%)', 20 | chip_boost: 'hsl(250, 83%, 67%)', 21 | }, 22 | }, 23 | 24 | // extra rules to append 25 | rules: [ 26 | // registered prefixes 27 | { 28 | scope: 'meta.prefix-declaration.either.registered', 29 | background: 'hsla(220, 63%, 89%, 0.61)', 30 | }, 31 | 32 | // inverse path 33 | { 34 | scope: 'meta.path.inverse', 35 | background: 'hsla(226, 94%, 62%, 0.12)', 36 | font_style: 'italic', 37 | }, 38 | 39 | // negated path 40 | { 41 | scope: 'meta.path.negated', 42 | background: 'hsla(290, 84%, 70%, 0.38)', 43 | }, 44 | 45 | // plus quantifier 46 | { 47 | scope: 'keyword.operator.path.quantifier.one-or-more', 48 | font_style: 'bold', 49 | }, 50 | 51 | // storage modifier 52 | { 53 | scope: 'storage.modifier', 54 | font_style: 'italic', 55 | }, 56 | 57 | // annotation 58 | { 59 | scope: 'meta.annotation', 60 | font_style: 'italic', 61 | background: 'hsla(0, 20%, 50%, 0.1)', 62 | foreground_adjust: 'saturation(20%)', 63 | }, 64 | 65 | { 66 | scope: 'meta.term.role.label.triple-expression', 67 | background: 'hsla(120, 80%, 50%, 0.1)', 68 | foreground_adjust: 'saturation(55%)', 69 | }, 70 | 71 | // shape-definition inclusion 72 | { 73 | scope: 'meta.term.role.include', 74 | background: 'hsla(52, 74%, 76%, 0.38)', 75 | // background: 'hsla(252, 24%, 50%, 0.1)', 76 | }, 77 | 78 | // value-set exclusion 79 | { 80 | scope: 'meta.term.role.exclusion', 81 | background: 'hsla(342, 74%, 84%, 0.35)', 82 | // background: 'hsla(252, 24%, 50%, 0.1)', 83 | }, 84 | 85 | // rdf-star 86 | { 87 | scope: 'meta.triple.reified', 88 | background: 'hsla(140, 80%, 70%, 0.2)', 89 | foreground_adjust: 'saturation(55%)', 90 | }, 91 | 92 | // nested reified statement 93 | { 94 | scope: 'meta.triple.reified-nested', 95 | background: 'hsla(140, 80%, 70%, 0.4)', 96 | foreground_adjust: 'saturation(55%)', 97 | }, 98 | 99 | 100 | // shared regex scopes 101 | ...a_regex_scopes, 102 | ], 103 | 104 | // blends 105 | blends: { 106 | root: { 107 | // `@` as in `@prefix` 108 | 'punctuation.definition.storage storage.type': -25, 109 | 110 | // prefix / base 111 | 'storage.type': -20, 112 | 113 | // distinct / reduced 114 | 'storage.modifier': -8, 115 | 116 | // all 'other' keywords (namely modifiers) 117 | 'keyword.operator': 15, 118 | 119 | // `graph` 120 | 'keyword.control': -15, 121 | }, 122 | 123 | root_boost: { 124 | // qualifier keywords 125 | 'keyword.operator.word.qualifier': -10, 126 | 127 | // where clause brace 128 | 'punctuation.section, meta.clause.where': 10, 129 | 130 | // built-ins 131 | 'support.function': 0, 132 | 'punctuation.definition.expression': -15, 133 | 'punctuation.definition.arguments': 25, 134 | 135 | // `as` 136 | 'storage.type.variable': -15, 137 | 138 | 'keyword.operator.path': 0, 139 | 'punctuation.section.group': -20, 140 | 'punctuation.section.block': -15, 141 | 'meta.path.negated punctuation.section.group': -10, 142 | 'meta.path.inverse punctuation.section.group': -10, 143 | 144 | // constants `true` and `false` 145 | 'constant.language': -5, 146 | 147 | // n3 predicates 148 | 'keyword.operator.predicate': 0, 149 | 150 | // shex 151 | 'keyword.operator.unary.label': 15, 152 | }, 153 | 154 | scape: { 155 | // prefixes 156 | 'variable.other.readwrite.prefixed-name.namespace': -25, 157 | 'punctuation.separator.prefixed-name': -10, 158 | 'variable.other.member.prefixed-name.local': 0, 159 | 160 | 'constant.character.escape.prefixed-name': -5, 161 | 162 | // `a` 163 | 'support.constant.predicate.a': -50, 164 | 165 | 'keyword.operator.unary.exclusion': -30, 166 | 'punctuation.terminator.exclusion': 15, 167 | }, 168 | 169 | scape_boost: { 170 | 'variable.other.member.barename': 20, 171 | 172 | 'keyword.operator.unary.reference.shape': -5, 173 | 174 | 'meta.term.role.include punctuation.definition.iri': -60, 175 | 'meta.term.role.include string.unquoted.iri': 15, 176 | 177 | 'meta.term.role.label.shape-expression.declaration variable.other.readwrite.prefixed-name.namespace': -20, 178 | 'meta.term.role.label.shape-expression.declaration variable.other.member.prefixed-name.local': 45, 179 | 180 | }, 181 | 182 | flare: { 183 | // datatype symbol `^^` 184 | 'punctuation.separator.datatype.symbol': -60, 185 | 186 | // prefixed-names 187 | 'meta.datatype variable.other.readwrite.prefixed-name.namespace': -50, 188 | 'meta.datatype variable.other.member.prefixed-name.local': -35, 189 | 'meta.datatype punctuation.separator.prefixed-name': -50, 190 | 191 | // iri datatypes 192 | 'meta.datatype string.unquoted.iri': -25, 193 | 'meta.datatype constant.character.escape.iri': -40, 194 | 'meta.datatype punctuation.definition.iri': -50, 195 | 196 | // blank node property list 197 | 'punctuation.definition.blank-node-property-list': -30, 198 | 'punctuation.definition.property-list': -30, // n3 199 | 'punctuation.definition.anonymous-blank-node': -45, 200 | 201 | // terminators and separators 202 | 'punctuation.separator.object': -40, 203 | 'punctuation.separator.pair': -20, 204 | 'punctuation.separator.predicate-object-list': -40, 205 | 'punctuation.separator.property-list': -40, // n3 206 | 'punctuation.terminator.triple': -100, 207 | 'punctuation.terminator.statement': -100, // n3 208 | 'punctuation.terminator.graph-pattern': -60, 209 | 'punctuation.terminator.prefix-declaration': -60, 210 | 'punctuation.terminator.shape-atom': -20, 211 | }, 212 | 213 | flare_boost: { 214 | // variables 215 | 'variable.other.readwrite.var': -15, 216 | 217 | 'meta.term.role.include variable.other.readwrite.prefixed-name.namespace': -40, 218 | 'meta.term.role.include variable.other.member.prefixed-name.local':-20, 219 | }, 220 | 221 | echo: { 222 | // literasls 223 | 'string.quoted.double.literal, string.quoted.single.literal': -15, 224 | 'punctuation.definition.string': -35, 225 | 'constant.character.escape.literal': -40, 226 | 227 | // regex 228 | 'string.regexp': -10, 229 | 230 | // language-tags 231 | 'string.unquoted.language-tag': -5, 232 | 'punctuation.separator.language-tag.symbol': -35, 233 | 234 | // numerics 235 | 'keyword.operator.arithmetic': -0, 236 | 'constant.numeric': -15, 237 | 'meta.numeric.exponent': -40, 238 | 239 | // shex 240 | 'punctuation.definition.repeat-range': -45, 241 | 'punctuation.separator.repeat-range': -55, 242 | }, 243 | 244 | echo_boost: { 245 | 'support.constant': -15, 246 | 247 | 'text.plain': -25, 248 | }, 249 | 250 | chip: { 251 | // iris 252 | 'string.unquoted.iri': -20, 253 | 'constant.character.escape.iri': -40, 254 | 'punctuation.definition.iri': -55, 255 | 256 | // collection punctuation 257 | 'punctuation.definition.collection': 20, 258 | 259 | // blank nodes 260 | 'variable.other.readwrite.blank-node.underscore': -45, 261 | 'variable.other.member.blank-node.label': -10, 262 | }, 263 | 264 | chip_boost: { 265 | 'meta.directive': -45, 266 | 267 | 'punctuation.definition.annotation': -30, 268 | 269 | 'keyword.operator.unary.include': -15, 270 | 271 | 'meta.term.role.label.shape-expression.declaration punctuation.definition.iri': -60, 272 | 'meta.term.role.label.shape-expression.declaration string.unquoted.iri': 20, 273 | 274 | }, 275 | 276 | }, 277 | }; 278 | -------------------------------------------------------------------------------- /src/color-schemes/shared/regex-scopes.js: -------------------------------------------------------------------------------- 1 | // special thanks to @bathos 2 | module.exports = [ 3 | { 4 | name: 'Regex Char Classes & Punctuation', 5 | scope: 'string.regexp constant.other.character-class.predefined, string.regexp constant.other.character-class punctuation, string.regexp constant.other.character-class.set', 6 | foreground: '#8ABA8A', 7 | }, 8 | { 9 | name: 'Regex Char Class Dash', 10 | scope: 'punctuation.definition.character-class.dash.regexp', 11 | foreground: '#577557', 12 | }, 13 | { 14 | name: 'Regex Char Class Negation', 15 | scope: 'keyword.operator.negation.regexp', 16 | foreground: '#C59764', 17 | }, 18 | { 19 | name: 'Regex Char Classes (Predefined) & Escapes', 20 | scope: 'string.regexp constant.other.character-class.predefined, string.regexp constant.character.escape, string.regexp keyword.other.back-reference', 21 | font_style: 'bold', 22 | }, 23 | { 24 | name: 'Regex Char Classes (Character Property)', 25 | scope: 'meta.character-property constant, meta.character-property punctuation', 26 | font_style: 'italic', 27 | foreground: '#75CEA4', 28 | }, 29 | { 30 | name: 'Regex Char Classes (Character Property, Delimiters)', 31 | scope: 'meta.character-property punctuation', 32 | foreground: '#9AD8BB', 33 | }, 34 | { 35 | name: 'Regex Char Escapes', 36 | scope: 'string.regexp constant.character.escape', 37 | foreground: '#73D226', 38 | }, 39 | { 40 | name: 'Regex Backrefs', 41 | scope: 'string.regexp keyword.other.back-reference', 42 | background: '#173A0A', 43 | foreground: '#37BC46', 44 | }, 45 | { 46 | name: 'Regex Quantifiers', 47 | scope: 'keyword.operator.quantifier.regexp', 48 | foreground: '#7D9B6D', 49 | }, 50 | { 51 | name: 'Group Punctuation', 52 | scope: 'string.regexp meta.group punctuation', 53 | foreground: '#59A233', 54 | }, 55 | { 56 | name: 'Regex Positive Assertions', 57 | scope: 'keyword.control.anchor.regexp, string.regexp punctuation.definition.assertion.positive', 58 | foreground: '#75CEA4', 59 | }, 60 | { 61 | name: 'Regex Positive Assertion Text', 62 | scope: 'meta.group.assertion.positive.regexp', 63 | foreground: '#5FC983', 64 | }, 65 | { 66 | name: 'Regex Negative Assertions', 67 | scope: 'string.regexp punctuation.definition.assertion.negative', 68 | foreground: '#ED804A', 69 | }, 70 | { 71 | name: 'Regex Negative Assertion Text', 72 | scope: 'meta.group.assertion.negative.regexp', 73 | foreground: '#AF9547', 74 | }, 75 | { 76 | name: 'Regex Capturing Groups 1', 77 | scope: 'meta.group.capturing.regexp', 78 | background: '#7BB66420', 79 | }, 80 | { 81 | name: 'Regex Capturing Groups 2', 82 | scope: 'meta.group.capturing.regexp meta.group.capturing.regexp', 83 | background: '#7BB66435', 84 | }, 85 | { 86 | name: 'Regex Capturing Groups 3', 87 | scope: 'meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp', 88 | background: '#7BB6644A', 89 | }, 90 | { 91 | name: 'Regex Capturing Groups 4', 92 | scope: 'meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp', 93 | background: '#7BB6645F', 94 | }, 95 | { 96 | name: 'Regex Capturing Groups 5', 97 | scope: 'meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp', 98 | background: '#7BB66474', 99 | }, 100 | { 101 | name: 'Regex Capturing Groups 6+', 102 | scope: 'meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp meta.group.capturing.regexp', 103 | background: '#7BB66489', 104 | }, 105 | { 106 | name: 'Regex Outer Punc', 107 | scope: 'punctuation.definition.string.regexp', 108 | foreground: '#496549', 109 | }, 110 | { 111 | name: 'Regex Flags', 112 | scope: 'string.regexp.flags', 113 | font_style: 'italic', 114 | foreground: '#406E40', 115 | }, 116 | ]; 117 | -------------------------------------------------------------------------------- /src/main/ace-syntax.js: -------------------------------------------------------------------------------- 1 | const util = require('util'); 2 | const transform = require('./transform.js'); 3 | 4 | transform.build().then((k_syntax) => { 5 | // write data to stream 6 | process.stdout.write(/* syntax: js */ ` 7 | /* global define */ 8 | 9 | let a_imports = [ 10 | 'ace/lib/oop', 11 | 'ace/mode/text_highlight_rules', 12 | ]; 13 | 14 | require('brace').define('ace/mode/sparql_highlight_rules', a_imports, function(ace_require, exports) { 15 | "use strict"; 16 | 17 | var oop = ace_require("ace/lib/oop"); 18 | var TextHighlightRules = ace_require("ace/mode/text_highlight_rules").TextHighlightRules; 19 | 20 | function next_states(a_states) { 21 | return function(s_state, a_stack) { 22 | a_stack.shift(); 23 | a_stack.unshift(...[...a_states].reverse()); 24 | return a_stack[0]; 25 | }; 26 | } 27 | 28 | function push_states(a_states) { 29 | return function(s_state, a_stack) { 30 | a_stack.unshift(...[...a_states].reverse()); 31 | return a_stack[0]; 32 | }; 33 | } 34 | 35 | var SPARQLgraphyHighlightRules = function() { 36 | // regexp must not have capturing parentheses. Use (?:) instead. 37 | // regexps are ordered -> the first match is used 38 | 39 | this.$rules = ${/* eslint-disable indent */ util.inspect({ 40 | start: [{regex:/(?=[\S\s])/, push:'main'}], 41 | ...k_syntax.export_ace_rules({ 42 | no_unicode_mode: true, 43 | }), 44 | }, { 45 | depth: Infinity, 46 | maxArrayLength: Infinity, 47 | breakLength: Infinity, 48 | compact: false, 49 | }) /* eslint-enable */} 50 | 51 | this.normalizeRules(); 52 | }; 53 | 54 | SPARQLgraphyHighlightRules.metaData = { 55 | fileTypes: ['rq', 'sparql'], 56 | name: 'SPARQL', 57 | scopeName: 'source.rq' 58 | }; 59 | 60 | oop.inherits(SPARQLgraphyHighlightRules, TextHighlightRules); 61 | 62 | exports.HighlightRules = SPARQLgraphyHighlightRules; 63 | }); 64 | `); 65 | }); 66 | -------------------------------------------------------------------------------- /src/main/color-scheme.js: -------------------------------------------------------------------------------- 1 | // color palette names: 2 | // 0: root 3 | // 1: scape 4 | // 2: flare 5 | // 3: echo 6 | // 4: chip 7 | 8 | // version string 9 | const s_version = process.argv[3]; 10 | 11 | // import def from src file 12 | const g_def = require(`../color-schemes/${process.argv[2]}.js`); 13 | 14 | // blend function 15 | const blend = (s_name, x_blend) => ({ 16 | foreground: `color(var(${s_name}) blend(${x_blend >= 0? '#fff': '#000'} ${Math.abs(x_blend)}% hsl))`, 17 | }); 18 | 19 | // create new scheme object 20 | let g_scheme = { 21 | ...g_def.base, 22 | }; 23 | 24 | // create rules by merging 25 | let a_rules = g_scheme.rules = [ 26 | ...(g_def.base.rules || []), 27 | ...(g_def.rules || []), 28 | ]; 29 | 30 | // ref blends from def 31 | let h_blends = g_def.blends; 32 | 33 | // each blend 34 | for(let [s_name, h_scopes] of Object.entries(h_blends)) { 35 | // each scope 36 | for(let [si_scope, x_blend] of Object.entries(h_scopes)) { 37 | // add rule 38 | a_rules.push({ 39 | scope: si_scope, 40 | ...blend(s_name, x_blend), 41 | }); 42 | } 43 | } 44 | 45 | // apply pre-blending 46 | PREBLEND: { 47 | const R_COLOR = /^color\((.+)\)$/; 48 | const R_MOD = /^var\((.+?)\)\s+(.+)$/; 49 | 50 | const R_HSL = /^hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)$/; 51 | const R_BLEND = /^blend\((.+?)\s+(\d+)%\s+hsl\)$/; 52 | 53 | const lerp = (x_a, x_b, x_t) => (1 - x_t) * x_a + x_t * x_b; 54 | 55 | const render_fix_color = (g_rule, s_property) => { 56 | const sx_color = g_rule[s_property]; 57 | 58 | const m_color = R_COLOR.exec(sx_color); 59 | if(!m_color) return; 60 | 61 | const m_mod = R_MOD.exec(m_color[1]); 62 | if(!m_mod) return; 63 | 64 | const [, si_var, sx_fun] = m_mod; 65 | const sx_base = g_scheme.variables[si_var]; 66 | 67 | const [, s_base_hue, s_base_sat, s_base_lum] = R_HSL.exec(sx_base); 68 | let x_base_hue = +s_base_hue; 69 | let x_base_sat = (+s_base_sat) / 100; 70 | let x_base_lum = (+s_base_lum) / 100; 71 | 72 | const m_blend = R_BLEND.exec(sx_fun); 73 | if(m_blend) { 74 | const [, s_blend_color, s_blend_pct] = m_blend; 75 | 76 | let x_factor = (+s_blend_pct) / 100; 77 | 78 | let x_blend_hue = 0; 79 | let x_blend_sat = 0; 80 | let x_blend_lum = 0; 81 | if('#fff' === s_blend_color) { 82 | x_blend_lum = 1; 83 | } 84 | 85 | if(x_base_hue > x_blend_hue) { 86 | x_factor = 1 - x_factor; 87 | } 88 | 89 | if(Math.abs(x_base_hue - x_blend_hue) > 180) { 90 | if(x_base_hue < x_blend_hue) { 91 | x_base_hue += 360; 92 | } 93 | else { 94 | x_blend_hue += 360; 95 | } 96 | } 97 | 98 | const x_new_hue = Math.abs(x_base_hue * x_factor + x_blend_hue * (1 - x_factor)) % 360; 99 | const x_new_sat = lerp(x_base_sat, x_blend_sat, 1 - x_factor) * 100; 100 | const x_new_lum = lerp(x_base_lum, x_blend_lum, 1 - x_factor) * 100; 101 | 102 | // apply new hsl 103 | g_rule[s_property] = `hsl(${x_new_hue}, ${Math.round(x_new_sat)}%, ${Math.round(x_new_lum)}%)`; 104 | } 105 | }; 106 | 107 | // apply bugged hsl blending 108 | for(const g_rule of g_scheme.rules) { 109 | render_fix_color(g_rule, 'foreground'); 110 | render_fix_color(g_rule, 'background'); 111 | } 112 | } 113 | 114 | // stringify result 115 | process.stdout.write(JSON.stringify(g_scheme, null, '\t')); 116 | -------------------------------------------------------------------------------- /src/main/sublime-syntax.js: -------------------------------------------------------------------------------- 1 | const syntax_source = require('syntax-source'); 2 | const export_sublime_syntax = syntax_source.export['sublime-syntax']; 3 | 4 | (async() => { 5 | // consume prefixes on stdin 6 | let h_prefixes = {}; 7 | { 8 | let s_prefixes = ''; 9 | for await(let s_chunk of process.stdin) { 10 | s_prefixes += s_chunk; 11 | } 12 | h_prefixes = JSON.parse(s_prefixes)['@context']; 13 | } 14 | 15 | // load syntax source from a path string 16 | let k_syntax = await syntax_source.transform({ 17 | path: process.argv[2], 18 | extensions: { 19 | // insert all registered prefixe declaration productions in the appearing context 20 | _registeredPrefixDeclarations: (k_context, k_rule, s_version) => { 21 | let s_ext = k_context.syntax.ext; 22 | 23 | // remove source rule from context 24 | let i_rule = k_context.drop(k_rule); 25 | 26 | // each prefix in environment 27 | for(let [si_prefix, p_prefix_iri] of Object.entries(h_prefixes)) { 28 | // create new rule for prefix mapping 29 | k_context.insert(i_rule++, { 30 | match: `(((${syntax_source.string_to_regex(si_prefix)})(:))\\s*(<)(${syntax_source.string_to_regex(p_prefix_iri)})(>))`, 31 | captures: [ 32 | `meta.prefix-declaration.either.registered.SYNTAX`, 33 | `meta.prefix-declaration.${s_version}.namespace.SYNTAX`, 34 | `variable.other.readwrite.prefixed-name.namespace.prefix-declaration.SYNTAX`, 35 | `punctuation.separator.prefixed-name.prefix-declaration.SYNTAX`, 36 | // `meta.prefix-declaration.${s_version}.iri.SYNTAX`, 37 | `punctuation.definition.iri.begin.prefix-declaration.SYNTAX`, 38 | `string.unquoted.iri.prefix-declaration.SYNTAX`, 39 | `punctuation.definition.iri.end.prefix-declaration.SYNTAX`, 40 | ], 41 | pop: true, 42 | }); 43 | } 44 | 45 | return i_rule; 46 | }, 47 | }, 48 | }); 49 | 50 | // write to stdout 51 | process.stdout.write(export_sublime_syntax(k_syntax, { 52 | post: g_yaml => ({ 53 | ...g_yaml, 54 | name: `${g_yaml.name} (LinkedData)`, 55 | }), 56 | })); 57 | })().catch((e_compile) => { 58 | console.error(e_compile.stack); 59 | process.exit(1); 60 | }); 61 | -------------------------------------------------------------------------------- /src/main/turtle.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const yaml = require('js-yaml'); 3 | 4 | let p_file = process.argv[2]; 5 | 6 | // load ecmascript syntax file contents 7 | let s_syntax = fs.readFileSync(p_file, 'utf8'); 8 | 9 | // parse syntax def as yaml 10 | let g_syntax = yaml.safeLoad(s_syntax, { 11 | filename: p_file, 12 | }); 13 | 14 | 15 | const string_to_regex = s => s.replace(/([.|?*+[\](){}\\^$])/g, '\\$1'); 16 | const captures_to_map = (a_captures) => { 17 | let h_map = {}; 18 | for(let i_capture=0; i_capture { 29 | s_prefixes_jsonld += s_chunk; 30 | }) 31 | .on('end', () => { 32 | let g_jsonld = JSON.parse(s_prefixes_jsonld); 33 | let a_rules_prefixes = g_syntax.contexts.prefixDeclaration_AFTER_KEYWORD; 34 | 35 | for(let [si_prefix, p_prefix_iri] of Object.entries(g_jsonld['@context'])) { 36 | // let si_context_registered_iri = `prefixDeclarat\ion_AFTER_NAME_REGISTERED_${si_prefix.replace(/[^a-z]/g, '_').toUpperCase()}`; 37 | 38 | a_rules_prefixes.unshift({ 39 | match: `((${string_to_regex(si_prefix)})(:)\\s*(<)(${string_to_regex(p_prefix_iri)})(>))`, 40 | captures: captures_to_map([ 41 | 'meta.prefix-declaration.registered.ttl', 42 | 'variable.other.readwrite.prefix-name.namespace.prefix-declaration.ttl', 43 | 'punctuation.separator.prefix-name.prefix-declaration.ttl', 44 | 'punctuation.definition.iri.begin.prefix-declaration.ttl', 45 | 'string.unquoted.iri.prefix-declaration.ttl', 46 | 'punctuation.definition.iri.end.prefix-declaration.ttl', 47 | ]), 48 | pop: true, 49 | // set: si_context_registered_iri, 50 | }); 51 | 52 | // g_syntax.contexts[si_context_registered_iri] = [ 53 | // { 54 | // match: `(<)(${string_to_regex(p_prefix_iri)})(>)`, 55 | // captures: captures_to_map([ 56 | // 'punctuation.definition.iri.begin.prefix-declaration.ttl', 57 | // 'constant.other.iri.prefix-declaration.registered.ttl', 58 | // 'punctuation.definition.iri.end.prefix-declaration.ttl', 59 | // ]), 60 | // pop: true, 61 | // }, 62 | // { 63 | // include: 'prefixDeclaration_UNREGISTERED_POP', 64 | // }, 65 | // ]; 66 | } 67 | 68 | 69 | // reserialize syntax def; dump changes 70 | process.stdout.write(`%YAML 1.2\n---\n${yaml.safeDump(g_syntax)}`); 71 | }); 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/supplementals/comments.preferences.yaml: -------------------------------------------------------------------------------- 1 | name: Comments 2 | scope: source.rq, source.ttl, source.trig, source.nt, source.nq, source.n3, source.shex 3 | settings: 4 | shellVariables: 5 | - name: TM_COMMENT_START 6 | value: '# ' 7 | -------------------------------------------------------------------------------- /src/supplementals/completions.js: -------------------------------------------------------------------------------- 1 | 2 | const completions = (s_type, h_prefixes) => JSON.stringify({ 3 | scope: `meta.prefix-declaration.${s_type}`, 4 | completions: Object.entries(h_prefixes).reduce((a_completions, [s_namespace, p_iri]) => [ 5 | ...a_completions, 6 | { 7 | trigger: `${s_namespace}:`, 8 | contents: `${s_namespace}: <${p_iri}>${'at' === s_type? ' .': ''}\n`, 9 | }, 10 | ], []), 11 | }, null, '\t'); 12 | 13 | // consume prefix context from stdin 14 | let s_prefixes_jsonld = ''; 15 | process.stdin.setEncoding('utf8'); 16 | process.stdin 17 | .on('data', (s_chunk) => { 18 | s_prefixes_jsonld += s_chunk; 19 | }) 20 | .on('end', () => { 21 | // prefix-declaration type 22 | let s_type = process.argv[2] || 'sparql'; 23 | 24 | // json-ld (and its context) 25 | let g_jsonld = JSON.parse(s_prefixes_jsonld); 26 | let h_prefixes = g_jsonld['@context']; 27 | 28 | // build syntax 29 | process.stdout.write(completions(s_type, h_prefixes)); 30 | }); 31 | -------------------------------------------------------------------------------- /src/supplementals/settings.jmacs.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "color_scheme": "@{PACKAGE_PATH}/@{COLOR_SCHEME}.sublime-color-scheme" 3 | } 4 | -------------------------------------------------------------------------------- /src/syntax/human-readable.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | 4 | lookaheads: 5 | 6 | stringLiteral: '["'']' 7 | 8 | anonymousBlankNode: '\[' 9 | 10 | blankNode: 11 | - anonymousBlankNode 12 | - labeledBlankNode 13 | 14 | variables: 15 | 16 | KEYWORD_BOUNDARY: '[\s{(\[<*#$?^/="''>\])}]' 17 | 18 | PN_CHARS_BASE: '[A-Za-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{02FF}\x{0370}-\x{037D}\x{037F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]' 19 | PN_CHARS_U: '(?:{{PN_CHARS_BASE}}|_)' 20 | PN_CHARS: '(?:{{PN_CHARS_U}}|\-|[0-9\x{00B7}\x{0300}-\x{036F}\x{203F}\x{2040}])' 21 | 22 | HEX: '(?:[0-9A-Fa-f])' 23 | UCHAR: '(?:\\u{{HEX}}{4}|\\U{{HEX}}{8})' 24 | 25 | IRI_CONTENTS: '(?:[^\x{00}-\x{20}<>"{}|^`\\]*)' 26 | 27 | BLANK_NODE_LABEL: '(?:{{PN_CHARS_U}}|[0-9])(?:(?:{{PN_CHARS}}|\.)*{{PN_CHARS}})?' 28 | 29 | ECHAR: '(?:\\[tbnrf"''\\])' 30 | 31 | 32 | contexts: 33 | 34 | whitespace: 35 | - meta_include_prototype: false 36 | - match: '\s+' 37 | scope: meta.whitespace.SYNTAX 38 | 39 | comment: 40 | - meta_include_prototype: false 41 | - match: '#' 42 | scope: punctuation.definition.comment.SYNTAX 43 | push: line_comment 44 | 45 | line_comment: 46 | - meta_include_prototype: false 47 | - meta_scope: comment.line.SYNTAX 48 | - include: whitespace 49 | - match: '$' 50 | pop: true 51 | - match: '{{_SOMETHING}}' 52 | 53 | triple_TERMINATE: 54 | - match: '\.' 55 | scope: punctuation.terminator.triple.SYNTAX 56 | pop: true 57 | - retry 58 | 59 | rdfLiteral: 60 | - goto: [rdfLiteral_AFTER_STRING_LITERAL, stringLiteral] 61 | 62 | rdfLiteral_AFTER_STRING_LITERAL: 63 | - meta_include_prototype: false 64 | - include: comment 65 | - switch: 66 | - languageTag 67 | - match: '\^\^' 68 | scope: punctuation.separator.datatype.symbol.SYNTAX 69 | set: datatype 70 | - bail 71 | 72 | languageTag: 73 | - lookahead: '@[a-zA-Z]' 74 | - match: '@' 75 | scope: punctuation.separator.language-tag.symbol.SYNTAX 76 | set: languageTag_AFTER_AT 77 | 78 | languageTag_AFTER_AT: 79 | - meta_include_prototype: false 80 | - meta_scope: string.unquoted.language-tag.SYNTAX 81 | - match: '[a-zA-Z]+' 82 | scope: meta.language-tag.primary.SYNTAX 83 | set: languageTag_AFTER_PRIMARY 84 | 85 | languageTag_AFTER_PRIMARY: 86 | - meta_include_prototype: false 87 | - match: '-' 88 | scope: punctuation.separator.language-tag.hyphen.SYNTAX 89 | set: languageTag_AFTER_SEPARATOR 90 | - bail 91 | 92 | languageTag_AFTER_SEPARATOR: 93 | - meta_include_prototype: false 94 | - meta_scope: string.unquoted.language-tag.SYNTAX 95 | - match: '[a-zA-Z0-9]+' 96 | scope: meta.language-tag.subtag.SYNTAX 97 | set: languageTag_AFTER_PRIMARY 98 | 99 | iriRef: 100 | - match: '<' 101 | scope: punctuation.definition.iri.begin.SYNTAX 102 | set: iriRef_AFTER_BEGIN 103 | 104 | iriRef_AFTER_BEGIN: 105 | - meta_include_prototype: false 106 | - match: '{{IRI_CONTENTS}}' 107 | scope: string.unquoted.iri.SYNTAX 108 | - match: '{{UCHAR}}' 109 | scope: constant.character.escape.iri.SYNTAX 110 | - match: '>' 111 | scope: punctuation.definition.iri.end.SYNTAX 112 | pop: true 113 | - match: '\s' 114 | scope: invalid.illegal.token.expected.iriRef_AFTER_BEGIN.SYNTAX 115 | - bail 116 | 117 | labeledBlankNode: 118 | - match: '_:' 119 | scope: variable.other.readwrite.blank-node.underscore.SYNTAX 120 | set: labeledBlankNode_AFTER_NAMESPACE 121 | 122 | labeledBlankNode_AFTER_NAMESPACE: 123 | - match: '{{BLANK_NODE_LABEL}}' 124 | scope: variable.other.member.blank-node.label.SYNTAX 125 | pop: true 126 | -------------------------------------------------------------------------------- /src/syntax/n-quads.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: N-Quads 4 | file_extensions: 5 | - nq 6 | scope: source.nq 7 | extends: verbose.syntax-source 8 | 9 | contexts: 10 | main: 11 | - goto: quads 12 | 13 | quads: 14 | - goto: [quad_TERMINATE, graph?, object, predicate, subject] 15 | 16 | graph: 17 | - switch: 18 | - iriRef 19 | - labeledBlankNode 20 | mask: meta.term.role.graph.SYNTAX 21 | 22 | quad_TERMINATE: 23 | - match: '\.' 24 | scope: punctuation.terminator.quad.SYNTAX 25 | pop: true 26 | - retry 27 | -------------------------------------------------------------------------------- /src/syntax/n-triples.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: N-Triples 4 | file_extensions: 5 | - nt 6 | scope: source.nt 7 | extends: verbose.syntax-source 8 | 9 | contexts: 10 | main: 11 | - goto: triple 12 | 13 | triple: 14 | - goto: [triple_TERMINATE, object, predicate, subject] 15 | -------------------------------------------------------------------------------- /src/syntax/notation3.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: Notation3 4 | file_extensions: 5 | - n3 6 | scope: source.n3 7 | extends: terse.syntax-source 8 | 9 | 10 | lookaheads: 11 | qName: ':|{{leadChar}}' 12 | symbol: '<|{{qName_LOOKAHEAD}}' 13 | 14 | statement_LOOKAHEAD: 15 | - declaration 16 | - existential 17 | - universal 18 | - pathItem 19 | 20 | pathItem: '[(\[{"<]|{{boolean}}|{{numericLiteral}}|{{quickVariable}}|{{prefix}}|{{qName}}' 21 | 22 | predicate: 'a{{KEYWORD_BOUNDARY}}|@(?:(?:a|has|is){{KEYWORD_BOUNDARY}})||{{pathItem_LOOKAHEAD}}' 23 | 24 | 25 | variables: 26 | leadChar: '[A-Z_a-z\x{00c0}-\x{00d6}\x{00d8}-\x{00f6}\x{00f8}-\x{02ff}\x{0370}-\x{037d}\x{037f}-\x{1fff}\x{200c}-\x{200d}\x{2070}-\x{218f}\x{2c00}-\x{2fef}\x{3001}-\x{d7ff}\x{f900}-\x{fdcf}\x{fdf0}-\x{fffd}\x{00010000}-\x{000effff}]' 27 | followChar: '[\-0-9A-Z_a-z\x{00b7}\x{00c0}-\x{00d6}\x{00d8}-\x{00f6}\x{00f8}-\x{037d}\x{037f}-\x{1fff}\x{200c}-\x{200d}\x{203f}-\x{2040}\x{2070}-\x{218f}\x{2c00}-\x{2fef}\x{3001}-\x{d7ff}\x{f900}-\x{fdcf}\x{fdf0}-\x{fffd}\x{00010000}-\x{000effff}]' 28 | 29 | barename: '({{leadChar}}{{followChar}}*)' 30 | 31 | prefix: '{{barename}}?(:)' 32 | 33 | quickVariable: '\?{{barename}}' 34 | 35 | qName: '(?:{{prefix}}){{barename}}|{{barename}}' 36 | 37 | symbol: '<|{{qName}}' 38 | 39 | boolean: '@(true|false){{KEYWORD_BOUNDARY}}' 40 | 41 | baseDeclaration: '@base{{KEYWORD_BOUNDARY}}' 42 | keywordsDeclaration: '@keywords{{KEYWORD_BOUNDARY}}' 43 | prefixDeclaration: '@prefix{{KEYWORD_BOUNDARY}}' 44 | 45 | existential: '@forSome{{KEYWORD_BOUNDARY}}' 46 | universal: '@forAll{{KEYWORD_BOUNDARY}}' 47 | 48 | numericLiteral: '[-+]?[0-9]' 49 | 50 | 51 | 52 | contexts: 53 | prototype: 54 | - include: whitespace 55 | - include: comment 56 | 57 | main: 58 | - goto.push: [statement_TERMINATE, statement] 59 | 60 | iriRef: 61 | - match: '(<)([^>]*)(>)' 62 | captures: 63 | 1: punctuation.definition.iri.begin.n3 64 | 2: string.unquoted.iri.SYNTAX 65 | 3: punctuation.definition.iri.end.n3 66 | pop: true 67 | 68 | boolean: 69 | - match: '((@)true)' 70 | captures: 71 | 1: constant.language.boolean.true.n3 72 | 2: punctuation.definition.keyword.boolean.n3 73 | pop: true 74 | - match: '((@)false)' 75 | captures: 76 | 1: constant.language.boolean.false.n3 77 | 2: punctuation.definition.keyword.boolean.n3 78 | pop: true 79 | 80 | declaration: 81 | - switch: 82 | - baseDeclaration 83 | - keywordsDeclaration 84 | - prefixDeclaration 85 | 86 | baseDeclaration: 87 | - match: '((@)base)\b' 88 | captures: 89 | 1: storage.type.base.n3 90 | 2: punctuation.definition.keyword.base.n3 91 | set: iriRef 92 | 93 | keywordsDeclaration: 94 | - match: '((@)keywords)\b' 95 | captures: 96 | 1: storage.type.keywords.n3 97 | 2: punctuation.definition.keyword.keywords.n3 98 | set: barenameCsl 99 | 100 | prefixDeclaration: 101 | - match: '((@)prefix)\b' 102 | captures: 103 | 1: storage.type.prefix.n3 104 | 2: punctuation.definition.keyword.prefix.n3 105 | set: [iriRef, prefix] 106 | 107 | barename: 108 | - match: '{{barename}}' 109 | scope: string.unquoted.barename.n3 110 | pop: true 111 | 112 | barenameCsl: 113 | - match: '{{barename}}' 114 | scope: string.unquoted.barename.n3 115 | set: barenameCslTail 116 | - bail 117 | 118 | barenameCslTail: 119 | - match: ',' 120 | scope: punctuation.separator.barename.n3 121 | push: barename 122 | - bail 123 | 124 | prefix: 125 | - match: '(({{PN_PREFIX}}?)(:))' 126 | captures: 127 | 1: meta.prefix-declaration.at.namespace.n3 128 | 2: variable.other.readwrite.prefixed-name.namespace.prefix-declaration.n3 129 | 3: punctuation.separator.prefixed-name.namespace.prefix-declaration.n3 130 | pop: true 131 | 132 | statement: 133 | - switch: 134 | - declaration 135 | - universal 136 | - existential 137 | - simpleStatement 138 | - retry 139 | 140 | statement_TERMINATE: 141 | - match: '\.' 142 | scope: punctuation.terminator.statement.n3 143 | pop: true 144 | - retry 145 | 146 | statementList: 147 | - switch: 148 | - statement: [statementTail, statement] 149 | - bail 150 | 151 | statementTail: 152 | - match: '(?=\.)' 153 | set: [statementList, statement_TERMINATE] 154 | - bail 155 | 156 | expression: 157 | - goto: [pathTail, pathItem] 158 | 159 | quickVariable: 160 | - match: '{{quickVariable}}' 161 | scope: variable.other.readwrite.quick-variable.n3 162 | pop: true 163 | 164 | formulaContent: 165 | - goto: [statementList] 166 | 167 | pathItem: 168 | - open.paren: section.path 169 | set: [pathItem_AFTER_PATH_LIST, pathList] 170 | - open.bracket: definition.property-list 171 | set: [pathItem_AFTER_PROPERTY_LIST, propertyList] 172 | - open.brace: section.formula 173 | set: [pathItem_AFTER_FORMULA_CONTENT, formulaContent] 174 | - switch: 175 | - boolean 176 | - rdfLiteral 177 | - numericLiteral 178 | - quickVariable 179 | - symbol 180 | - retry 181 | 182 | pathItem_AFTER_PATH_LIST: 183 | - close.paren: section.path 184 | pop: true 185 | - retry 186 | 187 | pathItem_AFTER_PROPERTY_LIST: 188 | - close.bracket: definition.property-list 189 | pop: true 190 | - retry 191 | 192 | pathItem_AFTER_FORMULA_CONTENT: 193 | - close.brace: section.formula 194 | pop: true 195 | - retry 196 | 197 | pathList: 198 | - switch: 199 | - pathItem: [pathList, expression] 200 | - bail 201 | 202 | pathTail: 203 | - match: '!' 204 | scope: keyword.operator.path.logical.not.rq meta.path.negated.rq 205 | set: expression 206 | - match: '\^' 207 | scope: keyword.operator.path.inverse.rq meta.path.inverse.rq 208 | set: expression 209 | - bail 210 | 211 | predicate: 212 | - match: '<=' 213 | scope: keyword.operator.predicate.is-implied-by.n3 214 | pop: true 215 | - match: '=>' 216 | scope: keyword.operator.predicate.implies.n3 217 | pop: true 218 | - match: '=' 219 | scope: keyword.operator.predicate.same-as.n3 220 | pop: true 221 | - match: '((@)?a)\b' 222 | captures: 223 | 1: support.constant.predicate.a.n3 224 | 2: punctuation.definition.keyword.predicate.a.n3 225 | pop: true 226 | - match: '((@)has)\b' 227 | captures: 228 | 1: support.function.built-in.has.n3 229 | 2: punctuation.definition.keyword.predicate.has.n3 230 | set: expression 231 | pop: true 232 | - match: '((@)?is)\b' 233 | captures: 234 | 1: support.function.built-in.is.n3 235 | 2: punctuation.definition.keyword.predicate.is.n3 236 | set: [predicate_EXPECT_OF, expression] 237 | pop: true 238 | - include: expression 239 | 240 | predicate_EXPECT_OF: 241 | - match: '((@)?of)\b' 242 | captures: 243 | 1: support.constant.predicate.of.n3 244 | 2: punctuation.definition.keyword.predicate.of.n3 245 | pop: true 246 | 247 | propertyList: 248 | - switch: 249 | - predicate: [propertyList_MORE, objectList, predicate] 250 | - bail 251 | 252 | propertyList_MORE: 253 | - match: ';' 254 | scope: punctuation.separator.property-list.n3 255 | set: propertyList 256 | - bail 257 | 258 | objectList: 259 | - goto: [objectList_MORE, expression] 260 | 261 | objectList_MORE: 262 | - match: ',' 263 | scope: punctuation.separator.object-list.n3 264 | set: objectList 265 | - bail 266 | 267 | 268 | simpleStatement: 269 | - goto: [propertyList, expression] 270 | 271 | symbol: 272 | - switch: 273 | - iriRef 274 | - qName 275 | - match: '[A-Za-z]+' 276 | scope: word 277 | pop: true 278 | 279 | qName: 280 | - match: '{{qName}}' 281 | captures: 282 | 1: variable.other.readwrite.prefixed-name.namespace.n3 283 | 2: punctuation.separator.prefixed-name.namespace.SYNTAX 284 | 3: variable.other.member.prefixed-name.local.SYNTAX 285 | 4: variable.other.member.barename.SYNTAX 286 | pop: true 287 | 288 | symbolCsl: 289 | - switch: 290 | - symbol: [symbolCslTail, symbol] 291 | - bail 292 | 293 | symbolCslTail: 294 | - match: ',' 295 | scope: punctuation.separator.symbol.n3 296 | push: symbol 297 | - bail 298 | 299 | stringLiteral: 300 | - match: '"""' 301 | scope: punctuation.definition.string.begin.literal.double.long.n3 302 | set: [rdfLiteral_AFTER_STRING_LITERAL, stringLiteralLongDouble] 303 | - match: '"' 304 | scope: punctuation.definition.string.begin.literal.double.short.n3 305 | set: [rdfLiteral_AFTER_STRING_LITERAL, stringLiteralShortDouble] 306 | - retry 307 | 308 | datatype: 309 | - meta_include_prototype: false 310 | - switch: 311 | - symbol 312 | 313 | numericLiteral: 314 | # decimal 315 | - match: '((?:(\+)|(-))?([0-9]+)(?:(\.)([0-9]+))?)' 316 | captures: 317 | 1: constant.numeric.decimal.n3 318 | 2: keyword.operator.arithmetic.sign.positive.n3 319 | 3: keyword.operator.arithmetic.sign.negative.n3 320 | 4: meta.numeric.decimal.characteristic.n3 321 | 5: punctuation.decimal.n3 322 | 6: meta.numeric.decimal.mantissa.n3 323 | pop: true 324 | # double 325 | - match: '((?:(\+)|(-))?([0-9]+)(?:(\.)([0-9]+)){{EXPONENT}})' 326 | captures: 327 | 1: constant.numeric.decimal.n3 328 | 2: keyword.operator.arithmetic.sign.positive.n3 329 | 3: keyword.operator.arithmetic.sign.negative.n3 330 | 4: meta.numeric.decimal.characteristic.n3 331 | 5: punctuation.decimal.n3 332 | 6: meta.numeric.decimal.mantissa.n3 333 | 7: meta.numeric.exponent.e.n3 334 | 8: meta.numeric.exponent.sign.n3 335 | 9: meta.numeric.exponent.digit.n3 336 | pop: true 337 | # integer 338 | - match: '((?:(\+)|(-))?([0-9]+))' 339 | captures: 340 | 1: constant.numeric.integer.n3 341 | 2: keyword.operator.arithmetic.sign.positive.n3 342 | 3: keyword.operator.arithmetic.sign.negative.n3 343 | 4: meta.numeric.decimal.integer.n3 344 | set: rational_AFTER_INTEGER 345 | 346 | rational_AFTER_INTEGER: 347 | - match: '/' 348 | scope: keyword.operator.arithmetic.division.n3 349 | set: rational_AFTER_DIVISION 350 | - bail 351 | 352 | rational_AFTER_DIVISION: 353 | - match: '[0-9]+' 354 | scope: constant.numeric.integer.n3 355 | pop: true 356 | - retry 357 | 358 | existential: 359 | - match: '((@)forSome)' 360 | captures: 361 | 1: support.function.built-in.for-some.n3 362 | 2: punctuation.definition.keyword.for-some.n3 363 | set: symbolCsl 364 | - retry 365 | 366 | universal: 367 | - match: '((@)forAll)' 368 | captures: 369 | 1: support.function.built-in.for-all.n3 370 | 2: punctuation.definition.keyword.all.n3 371 | set: symbolCsl 372 | 373 | 374 | -------------------------------------------------------------------------------- /src/syntax/shex.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: ShExC 4 | file_extensions: 5 | - shex 6 | scope: source.shex 7 | extends: terse.syntax-source 8 | 9 | variables: 10 | 11 | UNICODE: '[^%\\]|\\[%\\]|{{UCHAR}}' 12 | 13 | # borrowed from 14 | ID_Continue: '{{ID_Start}}\p{Mn}\p{Mc}\p{Nd}\p{Pc}{{Other_ID_Continue}}' 15 | ID_Start: '\p{L}\p{Nl}{{Other_ID_Start}}' 16 | Other_ID_Continue: '··፩-፱᧚' 17 | Other_ID_Start: '℘℮゛゜' 18 | 19 | identifierName: '{{identifierStart}}{{identifierPart}}' 20 | identifierPart: '(?:[\$_‍‍{{ID_Continue}}]|{{unicodeEscape}})*' # ZWN?J after _ 21 | identifierStart: '(?:[\$_{{ID_Start}}]|{{unicodeEscape}})' 22 | unicodeEscape: '\\u(?:\h{4}|\{\h+\})' 23 | 24 | contexts: 25 | prototype: 26 | - include: whitespace 27 | - include: comment 28 | 29 | main: 30 | - goto: shexDoc 31 | flush: yes 32 | 33 | # [1] 34 | shexDoc: 35 | - goto: [shexDoc_AFTER_DIRECTIVE, directive*] 36 | 37 | shexDoc_AFTER_DIRECTIVE: 38 | - switch: 39 | - shexDoc_ACTIONS: [statement*, shexDoc_ACTIONS] 40 | - bail 41 | 42 | shexDoc_ACTIONS: 43 | - switch: 44 | - notStartAction 45 | - startActions 46 | 47 | # [2] 48 | directive: 49 | - include: baseDeclarationSparql 50 | - include: prefixDeclarationSparql 51 | - word: import 52 | scope: support.function.directive.import.SYNTAX 53 | set: iriRef 54 | mask: meta.term.role.import.SYNTAX 55 | 56 | # [5] 57 | notStartAction: 58 | - switch: 59 | - start 60 | - shapeExprDecl 61 | 62 | # [6] 63 | start: 64 | - word: start 65 | scope: keyword.control.start.SYNTAX 66 | set: start_AFTER_START 67 | 68 | start_AFTER_START: 69 | - match: '=' 70 | scope: keyword.operator.assignment.start.SYNTAX 71 | set: inlineShapeExpression 72 | 73 | # [7] 74 | startActions: 75 | - goto: codeDecl+ 76 | 77 | # [8] 78 | statement: 79 | - switch: 80 | - directive 81 | - notStartAction 82 | 83 | # [9] 84 | shapeExprDecl: 85 | - goto: [shapeExprDecl_AFTER_LABEL, shapeExprDecl_LABEL] 86 | 87 | shapeExprDecl_LABEL: 88 | - goto: shapeExprLabel 89 | mask: meta.term.role.label.shape-expression.declaration.SYNTAX 90 | 91 | shapeExprDecl_AFTER_LABEL: 92 | - switch: 93 | - shapeExpression 94 | - word: external 95 | scope: storage.modifier.shape-expression.external.SYNTAX 96 | pop: true 97 | 98 | # [10] 99 | shapeExpression: 100 | - goto: shapeOr 101 | 102 | shapeExpressionGroup: 103 | - open.paren: section.shape-expression 104 | set: [shapeExpressionGroup_CLOSE, shapeExpression] 105 | 106 | shapeExpressionGroup_CLOSE: 107 | - close.paren: section.shape-expression 108 | pop: true 109 | 110 | # [11] 111 | inlineShapeExpression: 112 | - goto: inlineShapeOr 113 | 114 | # [12] 115 | shapeOr: 116 | - goto: [shapeOr_MORE, shapeAnd] 117 | 118 | shapeOr_MORE: 119 | - word: or 120 | scope: keyword.operator.word.or.SYNTAX 121 | set: shapeOr 122 | - bail 123 | 124 | # [13] 125 | inlineShapeOr: 126 | - goto: [inlineShapeOr_MORE, inlineShapeAnd] 127 | 128 | inlineShapeOr_MORE: 129 | - word: or 130 | scope: keyword.operator.word.or.SYNTAX 131 | set: inlineShapeOr 132 | - bail 133 | 134 | # [14] 135 | shapeAnd: 136 | - goto: [shapeAnd_MORE, shapeNot] 137 | 138 | # [15] 139 | shapeAnd_MORE: 140 | - word: and 141 | scope: keyword.operator.word.and.SYNTAX 142 | set: shapeAnd 143 | - bail 144 | 145 | inlineShapeAnd: 146 | - goto: [inlineShapeAnd_MORE, inlineShapeNot] 147 | 148 | inlineShapeAnd_MORE: 149 | - word: and 150 | scope: keyword.operator.word.and.SYNTAX 151 | set: inlineShapeAnd 152 | - bail 153 | 154 | # [16] 155 | shapeNot: 156 | - lookaheads: 157 | - shapeAtom 158 | - not 159 | - goto: [shapeAtom, not] 160 | 161 | # [17] 162 | inlineShapeNot: 163 | - lookaheads: 164 | - inlineShapeAtom 165 | - not 166 | - goto: [inlineShapeAtom, not] 167 | 168 | not: 169 | - word: not 170 | scope: keyword.operator.word.not.SYNTAX 171 | pop: true 172 | - bail 173 | 174 | # [18] 175 | shapeAtom: 176 | - include: shapeAtomCommon 177 | - switch: 178 | - shapeOrRef: [nonLitNodeConstraint?, shapeOrRef] 179 | - include: shapeAtomGlobal 180 | 181 | # [19] 182 | shapeAtomNoRef: 183 | - include: shapeAtomCommon 184 | - switch: 185 | - shapeDefinition: [nonLitNodeConstraint?, shapeDefinition] 186 | - include: shapeAtomGlobal 187 | 188 | # [20] 189 | inlineShapeAtom: 190 | - switch: 191 | - nonLitNodeConstraint: [inlineShapeOrRef?, nonLitNodeConstraint] 192 | - litNodeConstraint 193 | - inlineShapeOrRef: [nonLitNodeConstraint?, inlineShapeOrRef] 194 | - include: shapeAtomGlobal 195 | 196 | shapeAtomCommon: 197 | - switch: 198 | - nonLitNodeConstraint: [shapeOrRef?, nonLitNodeConstraint] 199 | - litNodeConstraint 200 | 201 | shapeAtomGlobal: 202 | - switch: 203 | - shapeExpressionGroup 204 | - shapeAtomGlobal_CLOSE 205 | 206 | shapeAtomGlobal_CLOSE: 207 | - match: \. 208 | scope: punctuation.terminator.shape-atom.SYNTAX 209 | pop: true 210 | 211 | # [21] 212 | shapeOrRef: 213 | - switch: 214 | - shapeDefinition 215 | - shapeRef 216 | 217 | # [22] 218 | inlineShapeOrRef: 219 | - switch: 220 | - inlineShapeDefinition 221 | - shapeRef 222 | 223 | # [23] 224 | shapeRef: 225 | # ATPNAME_LN 226 | - match: '@(?={{prefixedNameLocal_LOOKAHEAD}}{{KEYWORD_BOUNDARY}})' 227 | scope: keyword.operator.unary.reference.shape.SYNTAX 228 | set: prefixedNameLocal 229 | mask: meta.term.role.reference.shape.SYNTAX 230 | # ATPNAME_NS 231 | - match: '@(?={{prefixedNameNamespace_LOOKAHEAD}}{{KEYWORD_BOUNDARY}})' 232 | scope: keyword.operator.unary.reference.shape.SYNTAX 233 | set: prefixedNameNamespace 234 | mask: meta.term.role.reference.shape.SYNTAX 235 | - match: '@' 236 | scope: keyword.operator.unary.reference.shape.SYNTAX 237 | set: shapeExprLabel 238 | mask: meta.term.role.label.shape-expression.reference.SYNTAX 239 | 240 | # [24] 241 | litNodeConstraint: 242 | - word: literal 243 | scope: storage.type.constraint.WORD.SYNTAX 244 | set: xsFacet* 245 | - switch: 246 | - datatype: [xsFacet*, datatype] 247 | - valueSet: [xsFacet*, valueSet] 248 | - numericFacet: numericFacet+ 249 | 250 | # [25] 251 | nonLitNodeConstraint: 252 | - switch: 253 | - nonLiteralKind: [stringFacet*, nonLiteralKind] 254 | - stringFacet: stringFacet+ 255 | 256 | # [26] 257 | nonLiteralKind: 258 | - words.camel: 259 | - iri 260 | - bNode 261 | - nonLiteral 262 | scope: storage.type.constraint.kind.WORD.SYNTAX 263 | pop: true 264 | 265 | # [27] 266 | xsFacet: 267 | - switch: 268 | - stringFacet 269 | - numericFacet 270 | 271 | # [28] 272 | stringFacet: 273 | - switch: 274 | - stringLength: [integer, stringLength] 275 | - regexp 276 | 277 | # [29] 278 | stringLength: 279 | - words.camel: 280 | - length 281 | - minLength 282 | - maxLength 283 | scope: support.function.constraint.string.WORD.SYNTAX 284 | pop: true 285 | 286 | # [30] 287 | numericFacet: 288 | - switch: 289 | - numericRange: [numericLiteral, numericRange] 290 | - numericLength: [integer, numericLength] 291 | 292 | # [31] 293 | numericRange: 294 | - words.camel: 295 | - minInclusive 296 | - minExclusive 297 | - maxInclusive 298 | - maxExclusive 299 | scope: support.function.constraint.numeric.range.WORD.SYNTAX 300 | pop: true 301 | 302 | # [32] 303 | numericLength: 304 | - words.camel: 305 | - totalDigits 306 | - fractionDigits 307 | scope: support.function.constraint.numeric.length.WORD.SYNTAX 308 | pop: true 309 | 310 | # [33] 311 | shapeDefinition: 312 | - goto: [semanticActions, annotation*, inlineShapeDefinition] 313 | 314 | # [34] 315 | inlineShapeDefinition: 316 | - switch.push: 317 | - extraPropertySet 318 | - word: closed 319 | scope: storage.modifier.shape.WORD.SYNTAX 320 | - goto: inlineShapeDefinition_AFTER_PROPERTY_SET 321 | 322 | inlineShapeDefinition_AFTER_PROPERTY_SET: 323 | - open.brace: section.group.triple-expression 324 | set: [inlineShapeDefinition_CLOSE, tripleExpression?] 325 | 326 | inlineShapeDefinition_CLOSE: 327 | - close.brace: section.group.triple-expression 328 | pop: true 329 | 330 | # [35] 331 | extraPropertySet: 332 | - word: extra 333 | scope: storage.type.property-set.extra.SYNTAX 334 | set: predicate+ 335 | 336 | # [36] 337 | tripleExpression: 338 | - switch: 339 | - groupTripleExpr: [tripleExpression_MORE, groupTripleExpr] 340 | 341 | tripleExpression_MORE: 342 | - match: '\|' 343 | scope: keyword.operator.logical.or.SYNTAX 344 | set: tripleExpression 345 | - bail 346 | 347 | # [40] 348 | groupTripleExpr: 349 | - goto: naryElementGroup 350 | # - switch: 351 | # - naryElementGroup 352 | # - singleElementGroup 353 | # - multiElementGroup 354 | 355 | naryElementGroup: 356 | - switch: 357 | - unaryTripleExpr: [naryElementGroup_MORE, unaryTripleExpr] 358 | 359 | naryElementGroup_MORE: 360 | - match: ';' 361 | scope: punctuation.separator.triple-expression.SYNTAX 362 | set: naryElementGroup? 363 | - bail 364 | 365 | # [43] 366 | unaryTripleExpr: 367 | - match: '\$' 368 | scope: keyword.operator.unary.label.triple-expression.SYNTAX 369 | set: [unaryTripleExpr_AFTER_LABEL, unaryTripleExpr_LABEL] 370 | # set: [unaryTripleExpr_AFTER_LABEL, tripleExprLabel] 371 | - include: unaryTripleExpr_AFTER_LABEL 372 | - switch: 373 | - include 374 | 375 | unaryTripleExpr_LABEL: 376 | - goto: tripleExprLabel 377 | mask: meta.term.role.label.triple-expression.SYNTAX 378 | 379 | unaryTripleExpr_AFTER_LABEL: 380 | - switch: 381 | - tripleConstraint 382 | - bracketedTripleExpr 383 | 384 | # [44] 385 | bracketedTripleExpr: 386 | - open.paren: section.group.triple-expression 387 | set: [bracketedTripleExpr_AFTER_EXPR, tripleExpression] 388 | 389 | bracketedTripleExpr_AFTER_EXPR: 390 | - close.paren: section.group.triple-expression 391 | set: [semanticActions, annotation*, cardinality] 392 | 393 | # [45] 394 | tripleConstraint: 395 | - match: '\^' 396 | scope: keyword.operator.unary.sense-flag.SYNTAX meta.path.inverse.SYNTAX 397 | set: [tripleConstraint_AFTER_PREDICATE, predicateInverse] 398 | - goto: [tripleConstraint_AFTER_PREDICATE, predicate] 399 | 400 | predicateInverse: 401 | - goto: predicate 402 | mask: meta.path.inverse.SYNTAX 403 | 404 | tripleConstraint_AFTER_PREDICATE: 405 | - goto: [semanticActions, annotation*, cardinality, inlineShapeExpression] 406 | 407 | # [46] 408 | cardinality: 409 | - match: '\*' 410 | scope: keyword.operator.quantifier.zero-or-more.SYNTAX 411 | pop: true 412 | - match: '\+' 413 | scope: keyword.operator.quantifier.one-or-more.SYNTAX 414 | pop: true 415 | - match: '\?' 416 | scope: keyword.operator.quantifier.existential.SYNTAX 417 | - open.brace: definition.repeat-range 418 | set: repeatRange_AFTER_OPEN 419 | - bail 420 | 421 | # [48] 422 | valueSet: 423 | - open.bracket: section.value-set 424 | set: [valueSet_END, valueSetValue*] 425 | 426 | valueSet_END: 427 | - close.bracket: section.value-set 428 | pop: true 429 | 430 | # [49] 431 | valueSetValue: 432 | - switch: 433 | - iriRange 434 | - literalRange 435 | - languageRange 436 | - exclusion: exclusion+ 437 | 438 | # [50] 439 | exclusion: 440 | - match: '\.' 441 | scope: keyword.operator.unary.exclusion-prefix.SYNTAX 442 | set: exclusionNegation 443 | - goto: exclusionNegation 444 | 445 | exclusionNegation: 446 | - match: '-' 447 | scope: keyword.operator.unary.exclusion.SYNTAX 448 | set: [exclusion_END, exclusion_AFTER_DASH] 449 | 450 | exclusion_AFTER_DASH: 451 | - switch: 452 | - namedNode 453 | - literal 454 | - languageTag 455 | mask: meta.term.role.exclusion.value-set.SYNTAX 456 | 457 | exclusion_END: 458 | - match: '~' 459 | scope: punctuation.terminator.exclusion.SYNTAX 460 | pop: true 461 | - bail 462 | 463 | # [51] 464 | iriRange: 465 | - goto: [iriRange_AFTER_IRI, namedNode] 466 | 467 | iriRange_AFTER_IRI: 468 | - match: '~' 469 | scope: punctuation.terminator.exclusion.named-node.SYNTAX 470 | set: exclusion* 471 | - bail 472 | 473 | # [52] 474 | iriExclusion: 475 | - match: '-' 476 | scope: keyword.operator.unary.exclusion.SYNTAX 477 | set: [exclusion_END, iriExclusion_NODE] 478 | 479 | iriExclusion_NODE: 480 | - goto: namedNode 481 | mask: meta.term.role.exclusion.value-set.SYNTAX 482 | 483 | # [53] 484 | literalRange: 485 | - goto: [literalRange_AFTER_LITERAL, literal] 486 | 487 | literalRange_AFTER_LITERAL: 488 | - match: '~' 489 | scope: punctuation.terminator.exclusion.language-range.SYNTAX 490 | set: literalExclusion* 491 | - bail 492 | 493 | # [54] 494 | literalExclusion: 495 | - match: '-' 496 | scope: keyword.operator.unary.exclusion.SYNTAX 497 | set: [exclusion_END, literalExclusion_LITERAL] 498 | 499 | literalExclusion_LITERAL: 500 | - goto: literal 501 | mask: meta.term.role.exclusion.value-set.SYNTAX 502 | 503 | # [55] 504 | languageRange: 505 | - switch: 506 | - languageTag: [languageRange_AFTER_AT?, languageTag] 507 | - match: '@' 508 | scope: support.constant.symbol.language-range.SYNTAX 509 | set: languageRange_AFTER_AT^ 510 | 511 | languageRange_AFTER_AT: 512 | - match: '~' 513 | scope: punctuation.terminator.exclusion.language-range.SYNTAX 514 | set: languageExclusion* 515 | 516 | # [56] 517 | languageExclusion: 518 | - match: '-' 519 | scope: keyword.operator.unary.exclusion.SYNTAX 520 | set: [exclusion_END, languageExclusion_LANGUAGE] 521 | 522 | languageExclusion_LANGUAGE: 523 | - goto: languageTag 524 | mask: meta.term.role.exclusion.value-set.SYNTAX 525 | 526 | # [57] 527 | include: 528 | - meta_scope: meta.shape-definition.inclusion.SYNTAX 529 | - match: '&' 530 | scope: keyword.operator.unary.include.SYNTAX 531 | set: tripleExprLabel 532 | mask: meta.term.role.include.triple-expression.SYNTAX 533 | 534 | # [58] 535 | annotation: 536 | - match: '//' 537 | scope: punctuation.definition.annotation.begin.SYNTAX 538 | set: [object, predicate] 539 | mask: meta.annotation.SYNTAX 540 | 541 | # [59] 542 | semanticActions: 543 | - goto: codeDecl* 544 | 545 | # [60] 546 | codeDecl: 547 | - match: '%' 548 | scope: punctuation.section.code.begin.SYNTAX 549 | set: [codeDecl_AFTER_IRI, codeDecl_AFTER_OPEN] 550 | 551 | codeDecl_AFTER_OPEN: 552 | - goto: namedNode 553 | mask: meta.term.role.name.code.SYNTAX 554 | 555 | codeDecl_AFTER_IRI: 556 | - switch: 557 | - code 558 | - match: '%' 559 | scope: punctuation.section.code.end.SYNTAX 560 | pop: true 561 | 562 | # [61] 563 | predicate: 564 | - switch: 565 | - verb 566 | 567 | object: 568 | - switch: 569 | - namedNode 570 | - literal 571 | 572 | node: 573 | - switch: 574 | - namedNode 575 | - labeledBlankNode 576 | 577 | # [63] 578 | shapeExprLabel: 579 | - goto: node 580 | 581 | # [64] 582 | tripleExprLabel: 583 | - goto: node 584 | 585 | code: 586 | - open.brace: section.code-block 587 | set: [code_END, codeContent] 588 | 589 | codeContent: 590 | # - switch: 591 | # - codeContent_DIRECTIVE 592 | - match: '{{UNICODE}}*' 593 | scope: text.plain 594 | - bail 595 | 596 | # codeContent_DIRECTIVE: 597 | # - meta_scope: comment.block.code-content.SYNTAX 598 | # - match: '((/\*))(\s*)(@syntax)(\s*)(:)(\s*)' 599 | # captures: 600 | # 1: meta.comment.border.SYNTAX 601 | # 2: punctuation.definition.comment.begin.SYNTAX 602 | # 3: meta.whitespace.SYNTAX 603 | # 4: meta.directive.code-content.syntax.keyword.SYNTAX 604 | # 5: meta.whitespace.SYNTAX 605 | # 6: punctuation.separator.directive.code-content.SYNTAX 606 | # 7: meta.whitespace.SYNTAX 607 | # set: codeContent_SYNTAX 608 | 609 | # codeContent_SYNTAX: 610 | # - match: 'J[Ss]|js|[Jj]ava[Ss]cript' 611 | # scope: meta.directive.code-content.syntax.language.SYNTAX 612 | # set: [scope:source.js, codeContent_DIRECTIVE_END] 613 | # with_prototype: 614 | # - match: '(?=\%\})' 615 | # pop: true 616 | 617 | codeContent_DIRECTIVE_END: 618 | - meta_scope: comment.block.code-content.SYNTAX 619 | - match: '((\*/))' 620 | captures: 621 | 1: meta.comment.border.SYNTAX 622 | 2: punctuation.definition.comment.end.SYNTAX 623 | pop: true 624 | 625 | code_END: 626 | - match: '%' 627 | scope: punctuation.section.code.end.SYNTAX 628 | set: code_END_1 629 | 630 | code_END_1: 631 | - close.brace: section.code-block 632 | pop: true 633 | 634 | repeatRange_AFTER_OPEN: 635 | - goto: [repeatRange_END, repeatRange_AFTER_INTEGER, integer] 636 | 637 | repeatRange_AFTER_INTEGER: 638 | - match: ',' 639 | scope: punctuation.separator.repeat-range.SYNTAX 640 | set: repeatRange_AFTER_COMMA 641 | - bail 642 | 643 | repeatRange_AFTER_COMMA: 644 | - switch: 645 | - integer 646 | - match: '\*' 647 | scope: support.constant.repeat-range.infinity.SYNTAX 648 | pop: true 649 | - bail 650 | 651 | repeatRange_END: 652 | - close.brace: definition.repeat-range 653 | pop: true 654 | 655 | regexp: 656 | - match: '/(?!/)' 657 | scope: punctuation.definition.string.regexp.begin.SYNTAX 658 | set: regex_AFTER_OPEN 659 | 660 | regex_AFTER_OPEN: 661 | - meta_scope: string.regexp.SYNTAX 662 | - meta_include_prototype: false 663 | # It’s okay to put this here; comments are always matched first. 664 | - include: regex_COMMON_NOT_IN_CLASS_SET 665 | - continue 666 | 667 | regex_ANY_CHILD_CONTEXT: 668 | # Child contexts are tricky here because we need to be able to terminate 669 | # the parent context from anywhere. Since the conditions of termination are 670 | # simple enough, we can just include this lookahead in any child context. 671 | # The regex root context will then handle the ‘actual’ termination. 672 | - match: '(?=[\n\/])' 673 | pop: true 674 | 675 | regex_COMMON_NOT_IN_CLASS_SET: 676 | - include: regex_COMMON 677 | # DISJUNCTION 678 | - match: '\|' 679 | scope: keyword.operator.or.regexp 680 | # QUANTIFIERS 681 | - match: '[\?\*\+]|\{\d+\s*(?:,\s*\d*\s*)?\}' 682 | scope: keyword.operator.quantifier.regexp 683 | # CHARACTER CLASSES 684 | - match: '\[' 685 | scope: punctuation.definition.character-class.begin.regexp 686 | push: regexp_AFTER_BRACKET 687 | # ASSERTIONS 688 | - match: '\(\?)' # technically slightly off 696 | captures: 697 | 1: punctuation.definition.group.capturing.begin.regexp 698 | 2: variable.other.named-capture.regexp 699 | 3: punctuation.definition.group.capturing.begin.regexp 700 | push: regex_AFTER_CAPTURE_OPEN 701 | - match: '\(\?:' 702 | scope: punctuation.definition.group.non-capturing.begin.regexp 703 | push: regex_AFTER_NON_CAPTURE_OPEN 704 | - match: '\(' 705 | scope: punctuation.definition.group.capturing.begin.regexp 706 | push: regex_AFTER_CAPTURE_OPEN 707 | 708 | regex_COMMON: 709 | - match: '\/' 710 | scope: punctuation.definition.string.regexp.end.SYNTAX 711 | set: regex_AFTER_PATTERN 712 | - match: '\n' 713 | scope: invalid.illegal.newline.SYNTAX 714 | pop: true 715 | # ASSERTIONS 716 | - match: '\\[Bb]|[\$\^]' 717 | scope: keyword.control.anchor.regexp 718 | # CHARACTER CLASSES 719 | - match: '\.|\\[DdSsWw]' 720 | scope: constant.other.character-class.predefined.regexp 721 | # PROPERTY CLASSES 722 | - match: '\\[Pp]\{' 723 | scope: punctuation.definition.character-property.regexp.begin.SYNTAX 724 | push: regex_PROPERTY 725 | # BACKREFERENCE 726 | - match: '\\k<({{identifierName}})>' 727 | scope: keyword.other.back-reference.regexp 728 | captures: 729 | 1: variable.other.named-capture.regexp 730 | - match: '\\[1-9]\d*' 731 | scope: keyword.other.back-reference.regexp 732 | # ESCAPES 733 | - match: '\\(c[A-Za-z]|[tnvfr])' 734 | scope: constant.character.escape.control-char.regexp 735 | - match: '\\x\h\h' 736 | scope: constant.character.escape.hexadecimal.regexp 737 | - match: '\\0(?!\d)' 738 | scope: constant.character.escape.null.regexp 739 | - match: '{{unicodeEscape}}' 740 | scope: constant.character.escape.unicode.regexp 741 | - match: '\\\/' 742 | scope: constant.character.escape.regexp 743 | - match: '\\.' 744 | scope: constant.character.escape.pointless.regexp 745 | 746 | regex_PROPERTY: 747 | - meta_scope: meta.character-property.regexp 748 | - match: '([A-Za-z_]+)(=)([A-Za-z\d]+)' 749 | captures: 750 | 1: constant.other.character-class.unicode-property-name.regexp 751 | 2: punctuation.separator.character-property-name-value.regexp 752 | 3: constant.other.character-class.unicode-property-value.regexp 753 | set: regex_PROPERTY_END 754 | - match: '[A-Za-z_\d]+' 755 | scope: constant.other.character-class.unicode-property-value.regexp 756 | set: regex_PROPERTY_END 757 | - match: '\}' 758 | scope: invalid.illegal.token 759 | pop: true 760 | - continue 761 | 762 | regex_PROPERTY_END: 763 | - meta_scope: meta.character-property.regexp 764 | - match: '\}' 765 | scope: punctuation.definition.character-property.regexp.end.SYNTAX 766 | pop: true 767 | - continue 768 | 769 | regexp_AFTER_BRACKET: 770 | - meta_scope: constant.other.character-class.set.regexp 771 | - meta_include_prototype: false 772 | - match: '(?<=\[)\^' 773 | scope: keyword.operator.negation.regexp 774 | - match: '(?- 827 | (?x) (( 828 | ([smix]) 829 | (?: 830 | (?!\3) ([smix]) 831 | (?: 832 | (?!\3|\4) ([smix]) 833 | (?: 834 | (?!\3|\4|\5) ([smix]) 835 | (?: 836 | (?!\3|\4|\5|\6) ([smix]) 837 | ( 838 | (?!\3|\4|\5|\6\7) ([smix]) 839 | )? 840 | )? 841 | )? 842 | )? 843 | )? 844 | )) 845 | {{_WORD_BOUNDARY}} 846 | scope: string.regexp.flags.SYNTAX 847 | pop: true 848 | - match: '\w+' 849 | scope: invalid.illegal.regex-flags.SYNTAX 850 | pop: true 851 | - bail 852 | 853 | -------------------------------------------------------------------------------- /src/syntax/sparql.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: SPARQL 4 | file_extensions: 5 | - rq 6 | scope: source.rq 7 | extends: terse.syntax-source 8 | 9 | 10 | lookaheads: 11 | 12 | 13 | numericLiteralPositive: '\+\.?[0-9]' 14 | numericLiteralNegative: '\-\.?[0-9]' 15 | 16 | node: [namedNode, blankNode] 17 | 18 | namedNodeOrVar: [namedNode, var] 19 | verb: [namedNodeOrVar, a] 20 | 21 | triplesSameSubject: [varOrTerm, triplesNode] 22 | triplesSameSubjectPath: [var, node, triplesNode] 23 | 24 | term: [node, literal] 25 | 26 | unitDirective: '#\s*@unit{{KEYWORD_BOUNDARY}}' 27 | 28 | path: >- 29 | (?x) 30 | [!(^] 31 | |{{namedNode_LOOKAHEAD}} 32 | |a{{KEYWORD_BOUNDARY}} 33 | 34 | 35 | lookaheads.i: 36 | 37 | aggregateFunction: >- 38 | (?x) 39 | (?: 40 | count 41 | |sum 42 | |min 43 | |max 44 | |avg 45 | |sample 46 | |group_concat 47 | )\s*\( 48 | |{{functionCall_LOOKAHEAD}} 49 | 50 | builtInCall: >- 51 | (?x) 52 | {{aggregateFunction_LOOKAHEAD}} 53 | |(?: 54 | str 55 | |lang(?:matches)? 56 | |datatype 57 | |bound 58 | |[iu]ri 59 | |bnode 60 | |rand 61 | |abs 62 | |ceil 63 | |floor 64 | |round 65 | |concat 66 | |substr 67 | |replace 68 | |[ul]case 69 | |encode_for_uri 70 | |contains 71 | |str(?:len|starts|ends|before|after|uuid|lang|dt) 72 | |year 73 | |month 74 | |day 75 | |hours 76 | |minutes 77 | |seconds 78 | |timezone 79 | |tz 80 | |now 81 | |md5 82 | |sha(?:1|256|384|512) 83 | |coalesce 84 | |if 85 | |sameTerm 86 | |is(?:[iu]ri|blank|literal|numeric) 87 | |regex 88 | )\s*\( 89 | |(?:not|exists){{KEYWORD_BOUNDARY}} 90 | 91 | 92 | variables: 93 | 94 | varNameStart: '(?:{{PN_CHARS_U}}|[0-9])' 95 | varName: '{{varNameStart}}(?:{{varNameStart}}|\x{00b7}|\x{0300}-\x{036f}|\x{203f}-\x{2040})*' 96 | 97 | 98 | contexts: 99 | prototype: 100 | - match: '{{unitDirective_LOOKAHEAD}}' 101 | pop: true 102 | - include: whitespace 103 | - include: comment 104 | 105 | main: 106 | - alone 107 | - match: '(#(\s*)(@prologue)(\s*))' 108 | captures: 109 | 1: comment.line.SYNTAX 110 | 2: meta.whitespace.SYNTAX 111 | 3: meta.directive.prologue.SYNTAX 112 | 4: meta.whitespace.SYNTAX 113 | push: line_comment 114 | - include: prototype 115 | - goto.push: query 116 | 117 | query: 118 | - alone 119 | - lookaheads: 120 | - selectQuery 121 | - constructQuery 122 | - describeQuery 123 | - askQuery 124 | - goto: [unit_AFTER_QUERY_UPDATE, unit_AFTER_PROLOGUE, prologue] 125 | 126 | prologue: 127 | - alone 128 | - meta_scope: meta.prologue.SYNTAX 129 | - switch.push: 130 | - baseDeclaration 131 | - prefixDeclaration 132 | - match: '(#(\s*)(@unit)(\s*))' 133 | captures: 134 | 1: comment.line.SYNTAX 135 | 2: meta.whitespace.SYNTAX 136 | 3: meta.directive.unit.SYNTAX 137 | 4: meta.whitespace.SYNTAX 138 | set: line_comment 139 | - include: prototype 140 | - bail 141 | 142 | baseDeclaration: 143 | - include: baseDeclarationSparql 144 | 145 | prefixDeclaration: 146 | - include: prefixDeclarationSparql 147 | 148 | unit_AFTER_PROLOGUE: 149 | - match: '(#(\s*)(@unit)(\s*))' 150 | captures: 151 | 1: comment.line.SYNTAX 152 | 2: meta.whitespace.SYNTAX 153 | 3: meta.directive.prologue.SYNTAX 154 | 4: meta.whitespace.SYNTAX 155 | set: [unit_AFTER_PROLOGUE, line_comment] 156 | - switch: 157 | - query: [valuesClause, query_AFTER_PROLOGUE] 158 | - update_AFTER_PROLOGUE 159 | - retry 160 | 161 | unit_AFTER_QUERY_UPDATE: 162 | - alone 163 | - match: '(#(\s*)(@unit)(\s*))' 164 | captures: 165 | 1: comment.line.SYNTAX 166 | 2: meta.whitespace.SYNTAX 167 | 3: meta.directive.prologue.SYNTAX 168 | 4: meta.whitespace.SYNTAX 169 | set: [unit_AFTER_PROLOGUE, line_comment] 170 | - include: prototype 171 | - bail 172 | 173 | query_AFTER_PROLOGUE: 174 | - switch: 175 | - selectQuery 176 | - constructQuery 177 | - describeQuery 178 | - askQuery 179 | 180 | selectQuery: 181 | - lookahead.i: 'select{{KEYWORD_BOUNDARY}}' 182 | - goto: [solutionModifier, whereClause, datasetClause, selectClause] 183 | 184 | subSelect: 185 | - goto: [valuesClause, solutionModifier, whereClause, selectClause] 186 | 187 | selectClause: 188 | - meta_content_scope: meta.clause.select.SYNTAX 189 | - word: select 190 | type: qualifier 191 | set: selectClause_AFTER_SELECT 192 | - retry 193 | 194 | selectClause_AFTER_SELECT: 195 | - word: distinct 196 | scope: storage.modifier.distinct.SYNTAX 197 | set: selectClause_AFTER_SELECT_MODIFIER 198 | - word: reduced 199 | scope: storage.modifier.reduced.SYNTAX 200 | set: selectClause_AFTER_SELECT_MODIFIER 201 | - goto: selectClause_AFTER_SELECT_MODIFIER 202 | 203 | selectClause_AFTER_SELECT_MODIFIER: 204 | - match: '\*' 205 | scope: keyword.operator.star.select-clause.SYNTAX 206 | pop: true 207 | - goto: selectClause_AFTER_NOT_STAR 208 | 209 | selectClause_AFTER_NOT_STAR: 210 | - switch.push: 211 | - selectClauseExpressionBinding 212 | - var 213 | - bail 214 | 215 | selectClauseExpressionBinding: 216 | - switch: 217 | - selectClauseExpressionBinding_AFTER_META 218 | mask: meta.group.expression-binding.select-clause.SYNTAX 219 | 220 | selectClauseExpressionBinding_AFTER_META: 221 | - open.paren: definition.expression 222 | set: [selectClauseExpressionBinding_TERMINATE, selectClauseExpressionBinding_AFTER_EXPRESSION, expression] 223 | 224 | selectClauseExpressionBinding_AFTER_EXPRESSION: 225 | - word: as 226 | scope: storage.type.variable.as.select-clause.SYNTAX 227 | set: var 228 | - retry 229 | 230 | selectClauseExpressionBinding_TERMINATE: 231 | - close.paren: definition.expression 232 | pop: true 233 | 234 | constructQuery: 235 | - word: construct 236 | type: qualifier 237 | set: constructQuery_AFTER_CONSTRUCT 238 | 239 | constructQuery_AFTER_CONSTRUCT: 240 | - switch: 241 | - constructTemplate: [solutionModifier, whereClause, datasetClause, constructTemplate_AFTER_TRIPLES, constructTemplate] 242 | - datasetClause: [constructQuery_ALTERNATE_AFTER_DATASET_CLAUSE, datasetClause] 243 | 244 | constructQuery_ALTERNATE_AFTER_DATASET_CLAUSE: 245 | - word: where 246 | type: qualifier 247 | set: constructQuery_ALTERNATE_AFTER_WHERE 248 | 249 | constructQuery_ALTERNATE_AFTER_WHERE: 250 | - open.brace: section.triples 251 | set: [constructQuery_ALTERNATE_AFTER_TRIPLES_TEMPLATE, triplesTemplate] 252 | 253 | constructQuery_ALTERNATE_AFTER_TRIPLES_TEMPLATE: 254 | - close.brace: section.triples 255 | set: solutionModifier 256 | 257 | describeQuery: 258 | - word: describe 259 | type: qualifier 260 | set: [solutionModifier, whereClause_OPTIONAL, datasetClause, describeQuery_AFTER_DESCRIBE] 261 | 262 | describeQuery_AFTER_DESCRIBE: 263 | - match: '\*' 264 | scope: keyword.operator.star.describe.SYNTAX 265 | pop: true 266 | - goto: describeQuery_TARGET+ 267 | 268 | describeQuery_TARGET: 269 | - switch: 270 | - namedNode 271 | - var 272 | 273 | askQuery: 274 | - word: ask 275 | type: qualifier 276 | set: [solutionModifier, whereClause, datasetClause] 277 | 278 | datasetClause: 279 | - meta_content_scope: meta.clause.dataset.SYNTAX 280 | - word: from 281 | type: modifier 282 | push: datasetClause_AFTER_FROM 283 | - bail 284 | 285 | datasetClause_AFTER_FROM: 286 | - word: named 287 | type: modifier 288 | set: namedNode 289 | mask: meta.term.role.dataset.from-named.SYNTAX 290 | - goto: [namedNode] 291 | mask: meta.term.role.dataset.from-default.SYNTAX 292 | 293 | whereClause_OPTIONAL: 294 | - match: '(?=\{|(?i:where{{KEYWORD_BOUNDARY}}))' 295 | set: whereClause 296 | - bail 297 | 298 | whereClause: 299 | - word: where 300 | type: qualifier 301 | set: groupGraphPattern 302 | - goto: groupGraphPattern 303 | 304 | solutionModifier: 305 | - goto: [limitOffsetClauses, orderClause, havingClause, groupClause] 306 | 307 | groupClause: 308 | - word: group 309 | set: groupClause_AFTER_GROUP 310 | - bail 311 | 312 | groupClause_AFTER_GROUP: 313 | - word: by 314 | set: groupCondition+ 315 | 316 | groupCondition: 317 | - open.paren: definition.arguments 318 | set: [groupCondition_TERMINATE_BINDING, groupCondition_AFTER_EXPRESSION, expression] 319 | - switch: 320 | - var 321 | - functionCall 322 | - builtInCall 323 | 324 | groupCondition_AFTER_EXPRESSION: 325 | - word: as 326 | type: modifier 327 | set: var 328 | - bail 329 | 330 | groupCondition_TERMINATE_BINDING: 331 | - close.paren: definition.arguments 332 | pop: true 333 | 334 | havingClause: 335 | - word: having 336 | type: modifier 337 | set: [constraint+] 338 | - bail 339 | 340 | orderClause: 341 | - word: order 342 | type: modifier 343 | set: orderClause_AFTER_ORDER 344 | - bail 345 | 346 | orderClause_AFTER_ORDER: 347 | - word: by 348 | type: modifier 349 | set: orderCondition+ 350 | 351 | orderCondition: 352 | - word: asc 353 | scope: support.function.built-in.sort.asc.SYNTAX 354 | set: brackettedExpression 355 | - word: desc 356 | scope: support.function.built-in.sort.desc.SYNTAX 357 | set: brackettedExpression 358 | - switch: 359 | - constraint: constraint^ 360 | - var 361 | 362 | limitOffsetClauses: 363 | - switch: 364 | - limitClause: [offsetClause?, limitClause^] 365 | - offsetClause: [limitClause?, offsetClause^] 366 | - bail 367 | 368 | limitClause: 369 | - word: limit 370 | type: modifier 371 | set: integer 372 | 373 | offsetClause: 374 | - word: offset 375 | type: modifier 376 | set: integer 377 | 378 | valuesClause: 379 | - word: values 380 | type: qualifier 381 | set: dataBlock 382 | - bail 383 | 384 | update: 385 | - goto: [update_AFTER_PROLOGUE, prologue] 386 | 387 | update_AFTER_PROLOGUE: 388 | - switch: 389 | - load: [update_AFTER_UPDATE_1, load] 390 | - clear: [update_AFTER_UPDATE_1, clear] 391 | - drop: [update_AFTER_UPDATE_1, drop] 392 | - add: [update_AFTER_UPDATE_1, add] 393 | - move: [update_AFTER_UPDATE_1, move] 394 | - copy: [update_AFTER_UPDATE_1, copy] 395 | - create: [update_AFTER_UPDATE_1, create] 396 | - insert: [update_AFTER_UPDATE_1, insert] 397 | - delete: [update_AFTER_UPDATE_1, delete] 398 | - modify: [update_AFTER_UPDATE_1, modify] 399 | 400 | update_AFTER_UPDATE_1: 401 | - match: ';' 402 | scope: punctuation.terminator.update.SYNTAX 403 | set: update 404 | - bail 405 | 406 | load: 407 | - word: load 408 | type: qualifier 409 | set: [load_AFTER_NAMED_NODE, namedNode, silent_OPTIONAL] 410 | 411 | load_AFTER_NAMED_NODE: 412 | - word: into 413 | type: modifier 414 | set: graphRef 415 | - bail 416 | 417 | silent_OPTIONAL: 418 | - word: silent 419 | type: modifier 420 | pop: true 421 | - bail 422 | 423 | clear: 424 | - word: clear 425 | type: qualifier 426 | set: [graphRefAll, silent_OPTIONAL] 427 | 428 | drop: 429 | - word: drop 430 | type: qualifier 431 | set: [graphRefAll, silent_OPTIONAL] 432 | 433 | add: 434 | - word: add 435 | type: qualifier 436 | set: addMoveCopy_AFTER_ACTION 437 | 438 | move: 439 | - word: move 440 | type: qualifier 441 | set: addMoveCopy_AFTER_ACTION 442 | 443 | addMoveCopy_AFTER_ACTION: 444 | - goto: [addMoveCopy_AFTER_GRAPH_OR_DEFAULT, graphOrDefault] 445 | 446 | addMoveCopy_AFTER_GRAPH_OR_DEFAULT: 447 | - word: to 448 | type: qualifier 449 | set: graphOrDefault 450 | 451 | copy: 452 | - word: copy 453 | type: qualifier 454 | set: addMoveCopy_AFTER_ACTION 455 | 456 | create: 457 | - word: create 458 | type: qualifier 459 | set: [graphRef, silent_OPTIONAL] 460 | 461 | insert: 462 | - word: insert 463 | type: qualifier 464 | set: insert_AFTER_INSERT 465 | 466 | insert_AFTER_INSERT: 467 | - include: insertDeleteData_AFTER_ACTION 468 | - switch: 469 | - quadPatternData: [modify_AFTER_INSERT_CLAUSE, quadPatternData] 470 | 471 | insertDeleteData_AFTER_ACTION: 472 | - word: data 473 | type: qualifier 474 | set: quadPatternData 475 | 476 | delete: 477 | - word: delete 478 | type: qualifier 479 | set: delete_AFTER_DELETE 480 | 481 | delete_AFTER_DELETE: 482 | - include: insertDeleteData_AFTER_ACTION 483 | - word: where 484 | type: modifier 485 | set: quadPatternData 486 | - switch: 487 | - quadPatternData: [modify_AFTER_INSERT_CLAUSE, insertClause_OPTIONAL, quadPatternData] 488 | 489 | modify: 490 | - word: with 491 | type: modifier 492 | set: [modify_AFTER_NAMED_NODE, namedNode] 493 | - goto: modify_AFTER_NAMED_NODE 494 | 495 | modify_AFTER_NAMED_NODE: 496 | - switch: 497 | - delete: [modify_AFTER_INSERT_CLAUSE, insertClause_OPTIONAL, deleteClause] 498 | - insert: [modify_AFTER_INSERT_CLAUSE, insertClause] 499 | - goto: modify_AFTER_INSERT_CLAUSE 500 | 501 | modify_AFTER_INSERT_CLAUSE: 502 | - goto: [modify_AFTER_USING_CLAUSE, usingClause] 503 | 504 | modify_AFTER_USING_CLAUSE: 505 | - word: where 506 | type: modifier 507 | set: groupGraphPattern 508 | 509 | deleteClause: 510 | - word: delete 511 | type: qualifier 512 | set: quadPatternData 513 | 514 | insertClause_OPTIONAL: 515 | - switch: 516 | - insertClause 517 | - bail 518 | 519 | insertClause: 520 | - word: insert 521 | type: qualifier 522 | set: quadPatternData 523 | 524 | usingClause: 525 | - word: using 526 | type: qualifier 527 | push: usingClause_AFTER_USING 528 | - bail 529 | 530 | usingClause_AFTER_USING: 531 | - word: named 532 | type: qualifier 533 | set: namedNode 534 | - switch: 535 | - namedNode 536 | 537 | graphOrDefault: 538 | - word: default 539 | scope: support.constant.graph.default.SYNTAX 540 | pop: true 541 | - word: graph 542 | type: qualifier 543 | set: namedNode 544 | - switch: 545 | - namedNode 546 | 547 | graphRef: 548 | - word: graph 549 | type: modifier 550 | set: namedNode 551 | 552 | graphRefAll: 553 | - switch: 554 | - graphRef 555 | - word: default 556 | scope: support.constant.graph.default.SYNTAX 557 | pop: true 558 | - word: named 559 | scope: support.constant.graph.named.SYNTAX 560 | pop: true 561 | - word: all 562 | scope: support.constant.graph.all.SYNTAX 563 | pop: true 564 | 565 | quadPatternData: 566 | - open.brace: section.quads 567 | set: [quadPatternData_AFTER_QUADS, quads] 568 | 569 | quadPatternData_AFTER_QUADS: 570 | - close.brace: section.quads 571 | pop: true 572 | 573 | quads: 574 | - goto: [quads_AFTER_TRIPLES_TEMPLATE, triplesTemplate] 575 | 576 | quads_AFTER_TRIPLES_TEMPLATE: 577 | - switch: 578 | - quadsNotTriples: [quads_AFTER_QUADS_NOT_TRIPLES, quadsNotTriples] 579 | - bail 580 | 581 | quads_AFTER_QUADS_NOT_TRIPLES: 582 | - match: '\.' 583 | scope: punctuation.terminator.quad.SYNTAX 584 | set: [quads_AFTER_TRIPLES_TEMPLATE, triplesTemplate] 585 | - goto: [quads_AFTER_TRIPLES_TEMPLATE, triplesTemplate] 586 | 587 | quadsNotTriples: 588 | - word: graph 589 | type: modifier 590 | set: [quadsNotTriples_AFTER_VAR_OR_NAMED_NODE, varOrNamedNode] 591 | 592 | quadsNotTriples_AFTER_VAR_OR_NAMED_NODE: 593 | - open.brace: section.quads 594 | set: [quadsNotTriples_AFTER_TRIPLES_TEMPLATE, triplesTemplate] 595 | 596 | quadsNotTriples_AFTER_TRIPLES_TEMPLATE: 597 | - close.brace: section.quads 598 | pop: true 599 | 600 | triplesTemplate: 601 | - switch: 602 | - triplesSameSubject: [triplesTemplate_AFTER_TRIPLES_SAME_SUBJECT, triplesSameSubject] 603 | - bail 604 | 605 | triplesTemplate_AFTER_TRIPLES_SAME_SUBJECT: 606 | - match: '\.' 607 | scope: punctuation.terminator.triple.SYNTAX 608 | set: triplesTemplate 609 | - bail 610 | 611 | groupGraphPattern: 612 | - meta_content_scope: meta.block.pattern.graph.group.SYNTAX 613 | - open.brace: section.group 614 | set: groupGraphPattern_AFTER_BEGIN 615 | 616 | groupGraphPattern_AFTER_BEGIN: 617 | - switch: 618 | - selectQuery: [groupGraphPattern_TERMINATE, subSelect] 619 | - goto: [groupGraphPattern_TERMINATE, groupGraphPatternSub] 620 | 621 | groupGraphPatternSub: 622 | - goto: [groupGraphPatternSub_AFTER_TRIPLES_BLOCK, triplesBlock] 623 | 624 | groupGraphPatternSub_AFTER_TRIPLES_BLOCK: 625 | - switch: 626 | - graphPatternNotTriples: 627 | - groupGraphPatternSub_AFTER_TRIPLES_BLOCK 628 | - triplesBlock 629 | - groupGraphPatternSub_AFTER_GRAPH_PATTERN_NOT_TRIPLES 630 | - graphPatternNotTriples 631 | - bail 632 | 633 | groupGraphPatternSub_AFTER_GRAPH_PATTERN_NOT_TRIPLES: 634 | - match: '\.' 635 | scope: punctuation.terminator.graph-pattern.SYNTAX 636 | pop: true 637 | - bail 638 | 639 | groupGraphPattern_TERMINATE: 640 | - close.brace: section.group 641 | pop: true 642 | - retry 643 | 644 | triplesBlock: 645 | - switch: 646 | - triplesSameSubjectPath: [triplesBlock_AFTER_TRIPLES_SAME_SUBJECT_PATH, triplesSameSubjectPath] 647 | - bail 648 | 649 | triplesBlock_AFTER_TRIPLES_SAME_SUBJECT_PATH: 650 | - match: '\.' 651 | scope: punctuation.terminator.triple.SYNTAX 652 | set: triplesBlock 653 | - bail 654 | 655 | graphPatternNotTriples: 656 | - switch: 657 | - groupGraphPattern: groupOrUnionGraphPattern 658 | - words: 659 | - optional 660 | - minus 661 | set: groupGraphPattern 662 | mask: meta.graph-pattern.WORD.SYNTAX 663 | - word: graph 664 | type: modifier 665 | set: graphGraphPattern_AFTER_GRAPH 666 | - word: service 667 | type: qualifier 668 | set: serviceGraphPattern_AFTER_SERVICE 669 | - word: filter 670 | type: modifier 671 | set: filter_AFTER_FILTER 672 | - word: bind 673 | type: modifier 674 | set: bind_AFTER_BIND 675 | - word: values 676 | type: qualifier 677 | set: dataBlock 678 | 679 | graphGraphPattern_AFTER_GRAPH: 680 | - switch: 681 | - var: [groupGraphPattern, var] 682 | - namedNode: [groupGraphPattern, namedNodeGraphPattern] 683 | 684 | namedNodeGraphPattern: 685 | - goto: [namedNode] 686 | mask: meta.term.role.graph.pattern.SYNTAX 687 | 688 | serviceGraphPattern_AFTER_SERVICE: 689 | - word: silent 690 | type: modifier 691 | set: serviceGraphPattern_AFTER_SILENT 692 | - goto: serviceGraphPattern_AFTER_SILENT 693 | 694 | serviceGraphPattern_AFTER_SILENT: 695 | - goto: [groupGraphPattern, varOrNamedNode] 696 | 697 | bind_AFTER_BIND: 698 | - open.paren: section.bind 699 | set: [bind_AFTER_EXPRESSION, expressionOrEmbTP] 700 | 701 | bind_AFTER_EXPRESSION: 702 | - word: as 703 | scope: storage.type.variable.as.select-clause.SYNTAX 704 | set: [bind_AFTER_VAR, var] 705 | 706 | bind_AFTER_VAR: 707 | - close.paren: section.bind 708 | pop: true 709 | 710 | dataBlock: 711 | - switch: 712 | - inlineDataOneVar 713 | - inlineDataFull 714 | 715 | inlineDataOneVar: 716 | - lookaheads: [var] 717 | - goto: [inlineDataOneVar_AFTER_VAR, var] 718 | 719 | inlineDataOneVar_AFTER_VAR: 720 | - open.brace: section.block.values-data.one-var 721 | set: [inlineDataOneVar_AFTER_DATA_BLOCK_VALUE, dataBlockValue] 722 | 723 | inlineDataOneVar_AFTER_DATA_BLOCK_VALUE: 724 | - close.brace: section.block.values-data.one-var 725 | pop: true 726 | 727 | inlineDataFull: 728 | - open.paren: section.inline-data-vars 729 | set: inlineDataFull_AFTER_BEGIN 730 | 731 | inlineDataFull_AFTER_BEGIN: 732 | - close.paren: section.inline-data-vars 733 | set: inlineDataFull_AFTER_VARS 734 | - switch.push: 735 | - var 736 | 737 | inlineDataFull_AFTER_VARS: 738 | - open.brace: section.block.values-data.full 739 | set: inlineDataFull_AFTER_BRACE 740 | 741 | inlineDataFull_AFTER_BRACE: 742 | - open.paren: section.data 743 | set: [inlineDataFull_AFTER_DATA_BLOCK_VALUE, dataBlockValue] 744 | - close.brace: section.block.values-data.full 745 | pop: true 746 | 747 | inlineDataFull_AFTER_DATA_BLOCK_VALUE: 748 | - close.paren: section.data 749 | set: inlineDataFull_AFTER_BRACE 750 | 751 | dataBlockValue: 752 | - word: undef 753 | scope: support.constant.undef.SYNTAX 754 | - switch.push: 755 | - namedNode 756 | - literal 757 | - bail 758 | 759 | groupOrUnionGraphPattern: 760 | - goto: [groupOrUnionGraphPattern_MORE, groupGraphPattern] 761 | 762 | groupOrUnionGraphPattern_MORE: 763 | - word: union 764 | type: qualifier 765 | set: groupOrUnionGraphPattern 766 | - bail 767 | 768 | filter_AFTER_FILTER: 769 | - switch: 770 | - brackettedExpression 771 | - functionCall 772 | - builtInCall 773 | 774 | constraint: 775 | - switch: 776 | - brackettedExpression 777 | - builtInCall 778 | - functionCall 779 | 780 | functionCall: 781 | - lookahead: |- 782 | (?x) 783 | (?: 784 | (?:<{{IRI_CONTENTS}}>) 785 | |(?:{{PN_PREFIX}}?:{{PN_LOCAL}}) 786 | )\s*\( 787 | - meta_content_scope: meta.function-call.SYNTAX 788 | - goto: [functionCall_TERMINATE, argList, namedNodeFunctionCall] 789 | 790 | namedNodeFunctionCall: 791 | - goto: [namedNode] 792 | mask: meta.term.role.function-call.SYNTAX 793 | 794 | functionCall_TERMINATE: 795 | - meta_content_scope: meta.function-call.SYNTAX 796 | - bail 797 | 798 | argList: 799 | - open.paren: definition.arguments 800 | set: [argList_AFTER_ARGUMENT, argList_AFTER_BEGIN] 801 | - bail 802 | 803 | argList_AFTER_BEGIN: 804 | - match: '(?=\))' 805 | pop: true 806 | - word: distinct 807 | scope: keyword.operator.word.modifier.distinct.function-call.SYNTAX 808 | set: expression 809 | - goto: expression 810 | 811 | argList_AFTER_ARGUMENT: 812 | - match: ',' 813 | scope: punctuation.separator.argument.SYNTAX 814 | push: expression 815 | - close.paren: definition.arguments 816 | pop: true 817 | 818 | expressionList: 819 | - open.paren: definition.expression 820 | set: expressionList_AFTER_BEGIN 821 | 822 | expressionList_AFTER_BEGIN: 823 | - close.paren: definition.expression 824 | pop: true 825 | - goto: [expressionList_AFTER_EXPRESSION, expression] 826 | 827 | expressionList_AFTER_EXPRESSION: 828 | - match: ',' 829 | scope: punctuation.separator.expression.SYNTAX 830 | push: expression 831 | - close.paren: definition.expression 832 | pop: true 833 | 834 | constructTemplate: 835 | - open.brace: section.triples 836 | set: constructTriples_OPTIONAL 837 | 838 | constructTemplate_AFTER_TRIPLES: 839 | - close.brace: section.triples 840 | pop: true 841 | 842 | constructTriples_OPTIONAL: 843 | - switch: 844 | - triplesSameSubject: [constructTriples_AFTER_TRIPLES_SAME_SUBJECT, triplesSameSubject] 845 | - bail 846 | 847 | constructTriples_AFTER_TRIPLES_SAME_SUBJECT: 848 | - match: '\.' 849 | scope: punctuation.terminator.triple.SYNTAX 850 | set: constructTriples_OPTIONAL 851 | - bail 852 | 853 | ################################### 854 | # < SPARQL* > 855 | ################################### 856 | embeddedTriplePattern: 857 | - match: '<<' 858 | scope: punctuation.definition.triple-x.begin.SYNTAX meta.triple.reified.SYNTAX 859 | mask: meta.triple.reified.SYNTAX 860 | set: [embeddedTriplePattern_TERMINATE, embeddedTriplePattern_THING, verb, embeddedTriplePattern_THING] 861 | 862 | embeddedTriplePatternNested: 863 | - goto: embeddedTriplePattern 864 | mask: meta.triple.reified-nested.SYNTAX 865 | 866 | embeddedTriplePattern_THING: 867 | - switch: 868 | - embeddedTriplePatternNested 869 | - varOrTerm 870 | 871 | embeddedTriplePattern_TERMINATE: 872 | - match: '>>' 873 | scope: punctuation.definition.triple-x.end.SYNTAX meta.triple.reified.SYNTAX 874 | pop: true 875 | 876 | varOrTermOrEmbTP: 877 | - switch: 878 | - embeddedTriplePattern 879 | - include: varOrTerm 880 | 881 | expressionOrEmbTP: 882 | - switch: 883 | - embeddedTriplePattern 884 | - include: expression 885 | 886 | ################################### 887 | # 888 | ################################### 889 | 890 | triplesSameSubject: 891 | - switch: 892 | - hollowAnonymousBlankNode: [propertyListNotEmpty, hollowAnonymousBlankNode] 893 | - anonymousBlankNode: anonymousBlankNode_LATENT_PL_PLNE 894 | - varOrTermOrEmbTP: [propertyListNotEmpty_REQUIRED, varOrTermOrEmbTP] 895 | - triplesNode: [propertyList, triplesNode] 896 | 897 | anonymousBlankNode_LATENT: 898 | - open.bracket: definition.blank-node-property-list 899 | set: anonymousBlankNode_LATENT_AFTER_BEGIN 900 | 901 | anonymousBlankNode_LATENT_AFTER_BEGIN: 902 | - close.bracket: definition.anonymous-blank-node.hack 903 | pop: true 904 | - goto: [blankNodePropertyList_TERMINATE, propertyListNotEmpty] 905 | 906 | anonymousBlankNodePath_LATENT: 907 | - open.bracket: definition.blank-node-property-list 908 | set: anonymousBlankNodePath_LATENT_AFTER_BEGIN 909 | 910 | anonymousBlankNodePath_LATENT_AFTER_BEGIN: 911 | - close.bracket: definition.anonymous-blank-node.hack 912 | pop: true 913 | - goto: [blankNodePropertyList_TERMINATE, propertyListPathNotEmpty] 914 | 915 | blankNodePropertyList_LATENT: 916 | - open.bracket: definition.blank-node-property-list 917 | set: blankNodePropertyList_LATENT_AFTER_BEGIN 918 | 919 | blankNodePropertyList_LATENT_AFTER_BEGIN: 920 | - close.bracket: definition.anonymous-blank-node.hack 921 | 922 | set: [blankNodePropertyList_TERMINATE, propertyListNotEmpty] 923 | 924 | anonymousBlankNode_LATENT_PL_PLNE: 925 | - open.bracket: definition.blank-node-property-list 926 | set: anonymousBlankNode_LATENT_PL_PLNE_AFTER_BEGIN 927 | 928 | anonymousBlankNode_LATENT_PL_PLNE_AFTER_BEGIN: 929 | - close.bracket: definition.anonymous-blank-node.hack 930 | set: propertyListNotEmpty 931 | - goto: [propertyList, blankNodePropertyList_TERMINATE, propertyListNotEmpty] 932 | 933 | triplesSameSubject_AFTER_OPEN_BRACKET: 934 | - close.bracket: definition.anonymous-blank-node 935 | set: propertyListNotEmpty 936 | - goto: [propertyList, triplesNode] 937 | 938 | propertyList: 939 | - include: propertyListNotEmpty 940 | - bail 941 | 942 | propertyListNotEmpty_REQUIRED: 943 | - include: propertyListNotEmpty 944 | 945 | propertyListNotEmpty: 946 | - switch: 947 | - verb: [propertyListNotEmpty_AFTER_OBJECT_LIST, objectList, verb] 948 | 949 | propertyListNotEmpty_AFTER_OBJECT_LIST: 950 | - match: ';' 951 | scope: punctuation.separator.pair.SYNTAX 952 | set: propertyListNotEmpty_AFTER_SEMICOLON 953 | - bail 954 | 955 | propertyListNotEmpty_AFTER_SEMICOLON: 956 | - switch: 957 | - verb: [propertyListNotEmpty_AFTER_OBJECT_LIST, objectList, verb] 958 | - propertyListNotEmpty_AFTER_OBJECT_LIST 959 | - bail 960 | 961 | verb: 962 | - switch: 963 | - var 964 | - namedNode 965 | - a 966 | 967 | object: 968 | - goto: graphNode 969 | 970 | triplesSameSubjectPath: 971 | - switch: 972 | - hollowAnonymousBlankNode: [propertyListPathNotEmpty, hollowAnonymousBlankNode] 973 | - anonymousBlankNode: anonymousBlankNode_LATENT_PLP_PLPNE 974 | - varOrTermOrEmbTP: [propertyListPathNotEmpty, varOrTermOrEmbTP] 975 | - triplesNode: [propertyListPath, triplesNodePath] 976 | 977 | anonymousBlankNode_LATENT_PLP_PLPNE: 978 | - open.bracket: definition.blank-node-property-list 979 | set: anonymousBlankNode_LATENT_PLP_PLPNE_AFTER_BEGIN 980 | 981 | anonymousBlankNode_LATENT_PLP_PLPNE_AFTER_BEGIN: 982 | - close.bracket: definition.anonymous-blank-node.hack 983 | set: propertyListPathNotEmpty 984 | - goto: [propertyListPath, blankNodePropertyList_TERMINATE, propertyListPathNotEmpty] 985 | 986 | propertyListPath: 987 | - switch: 988 | - verbPathOrSimple: propertyListPathNotEmpty 989 | - bail 990 | 991 | propertyListPathNotEmpty: 992 | - goto: [propertyListPathNotEmpty_AFTER_OBJECT_LIST_PATH, objectListPath, verbPathOrSimple] 993 | 994 | propertyListPathNotEmpty_AFTER_OBJECT_LIST_PATH: 995 | - match: ';' 996 | scope: punctuation.separator.pair.SYNTAX 997 | push: propertyListPathNotEmpty_AFTER_SEMICOLON 998 | - bail 999 | 1000 | propertyListPathNotEmpty_AFTER_SEMICOLON: 1001 | - switch: 1002 | - verbPathOrSimple: [objectList, verbPathOrSimple] 1003 | - bail 1004 | 1005 | verbPathOrSimple: 1006 | - switch: 1007 | - path 1008 | - var 1009 | 1010 | objectListPath: 1011 | - goto: [objectListPath_MORE, objectPath] 1012 | 1013 | objectListPath_MORE: 1014 | - match: ',' 1015 | scope: punctuation.separator.object.SYNTAX 1016 | set: objectListPath 1017 | - bail 1018 | 1019 | objectPath: 1020 | - goto: graphNodePath 1021 | 1022 | path: 1023 | - goto: pathAlternative 1024 | 1025 | pathAlternative: 1026 | - goto: [pathAlternative_MORE, pathSequence] 1027 | 1028 | pathAlternative_MORE: 1029 | - match: '\|' 1030 | scope: keyword.operator.path.alternative.SYNTAX 1031 | set: pathAlternative 1032 | - bail 1033 | 1034 | pathSequence: 1035 | - goto: [pathSequence_MORE, pathEltOrInverse] 1036 | 1037 | pathSequence_MORE: 1038 | - match: '\/' 1039 | scope: keyword.operator.path.separator.SYNTAX 1040 | set: pathSequence 1041 | - bail 1042 | 1043 | pathEltOrInverse: 1044 | - match: '\^' 1045 | scope: keyword.operator.path.inverse.SYNTAX meta.path.inverse.SYNTAX 1046 | set: pathElt 1047 | mask: meta.path.inverse.SYNTAX 1048 | - goto: pathElt 1049 | 1050 | pathElt: 1051 | - goto: [pathMod?, pathPrimary] 1052 | 1053 | pathMod: 1054 | - match: '\?(?={{KEYWORD_BOUNDARY}})' 1055 | scope: keyword.operator.path.quantifier.zero-or-one.SYNTAX 1056 | pop: true 1057 | - match: '\*(?={{KEYWORD_BOUNDARY}})' 1058 | scope: keyword.operator.path.quantifier.zero-or-more.SYNTAX 1059 | pop: true 1060 | - match: '\+(?={{KEYWORD_BOUNDARY}})' 1061 | scope: keyword.operator.path.quantifier.one-or-more.SYNTAX 1062 | pop: true 1063 | 1064 | pathPrimary: 1065 | - match: '!' 1066 | scope: keyword.operator.path.logical.not.SYNTAX meta.path.negated.SYNTAX 1067 | set: pathNegatedPropertySet 1068 | mask: meta.path.negated.SYNTAX 1069 | - open.paren: section.path-group.sub 1070 | set: [pathPrimary_GROUP_TERMINATE, path] 1071 | - include: predicateData 1072 | 1073 | pathPrimary_GROUP_TERMINATE: 1074 | - close.paren: section.path-group.sub 1075 | pop: true 1076 | 1077 | pathNegatedPropertySet: 1078 | - open.paren: section.path 1079 | set: [pathNegatedPropertySet_AFTER_GROUP_BEGIN] 1080 | - goto: pathOneInPropertySet 1081 | 1082 | pathNegatedPropertySet_AFTER_GROUP_BEGIN: 1083 | - close.paren: section.path 1084 | pop: true 1085 | - goto: [pathNegatedPropertySet_GROUP_TERMINATE, pathNegatedPropertySet_AFTER_SET, pathOneInPropertySet] 1086 | 1087 | pathNegatedPropertySet_AFTER_SET: 1088 | - match: '\|' 1089 | scope: keyword.operator.path.alternative.SYNTAX 1090 | set: pathOneInPropertySet 1091 | - bail 1092 | 1093 | pathNegatedPropertySet_GROUP_TERMINATE: 1094 | - close.paren: section.path 1095 | pop: true 1096 | 1097 | pathOneInPropertySet: 1098 | - match: '\^' 1099 | scope: keyword.operator.path.inverse.SYNTAX 1100 | set: pathOneInPropertySet_AFTER_INVERSE 1101 | - goto: pathOneInPropertySet_AFTER_INVERSE 1102 | 1103 | pathOneInPropertySet_AFTER_INVERSE: 1104 | - include: predicateData 1105 | 1106 | triplesNode: 1107 | - switch: 1108 | - collection 1109 | - blankNodePropertyList 1110 | 1111 | blankNodePropertyList: 1112 | - open.bracket: definition.blank-node-property-list 1113 | set: [blankNodePropertyList_TERMINATE, propertyListNotEmpty] 1114 | 1115 | triplesNodePath: 1116 | - switch: 1117 | - collectionPath 1118 | - blankNodePropertyListPath 1119 | 1120 | blankNodePropertyListPath: 1121 | - open.bracket: definition.blank-node-property-list 1122 | set: [blankNodePropertyList_TERMINATE, propertyListPathNotEmpty] 1123 | 1124 | collection_AFTER_BEGIN: 1125 | - goto: [collection_AFTER_GRAPH_NODE, graphNode] 1126 | 1127 | collection_AFTER_GRAPH_NODE: 1128 | - close.paren: section.collection 1129 | pop: true 1130 | - goto: [collection_AFTER_GRAPH_NODE, graphNode] 1131 | 1132 | collectionPath: 1133 | - open.paren: section.collection 1134 | set: [collectionPath_AFTER_GRAPH_NODE_PATH, graphNodePath] 1135 | 1136 | collectionPath_AFTER_GRAPH_NODE_PATH: 1137 | - close.paren: section.collection 1138 | pop: true 1139 | - goto: [collectionPath_AFTER_GRAPH_NODE_PATH, graphNodePath] 1140 | 1141 | graphNode: 1142 | - switch: 1143 | - hollowAnonymousBlankNode 1144 | - anonymousBlankNode: anonymousBlankNode_LATENT 1145 | - varOrTermOrEmbTP 1146 | - triplesNode 1147 | 1148 | graphNodePath: 1149 | - switch: 1150 | - hollowAnonymousBlankNode 1151 | - anonymousBlankNode: anonymousBlankNodePath_LATENT 1152 | - varOrTermOrEmbTP 1153 | - triplesNodePath 1154 | 1155 | varOrTerm: 1156 | - switch: 1157 | - var 1158 | - term: graphTerm 1159 | 1160 | varOrNamedNode: 1161 | - switch: 1162 | - var 1163 | - namedNode 1164 | 1165 | var: 1166 | - lookahead: '[?$]' 1167 | - match: '((\?){{varName}})' 1168 | captures: 1169 | 1: variable.other.readwrite.var.question-mark.SYNTAX 1170 | 2: punctuation.definition.variable.var.question-mark.SYNTAX 1171 | pop: true 1172 | - match: '((\$){{varName}})' 1173 | captures: 1174 | 1: variable.other.readwrite.var.dollar-sign.SYNTAX 1175 | 2: punctuation.definition.variable.var.dollar-sign.SYNTAX 1176 | pop: true 1177 | - retry 1178 | 1179 | graphTerm: 1180 | - word: undef 1181 | scope: support.constant.undef.SYNTAX 1182 | pop: true 1183 | - switch: 1184 | - namedNode 1185 | - literal 1186 | - blankNode 1187 | - nil 1188 | 1189 | expression: 1190 | - goto: conditionalOrExpression 1191 | mask: meta.expression.SYNTAX 1192 | 1193 | conditionalOrExpression: 1194 | - goto: [conditionalOrExpression_MORE, conditionalAndExpression] 1195 | 1196 | conditionalOrExpression_MORE: 1197 | - match: '\|\|' 1198 | scope: keyword.operator.conditional.or.SYNTAX 1199 | set: conditionalOrExpression 1200 | - bail 1201 | 1202 | conditionalAndExpression: 1203 | - goto: [conditionalAndExpression_MORE, valueLogical] 1204 | 1205 | conditionalAndExpression_MORE: 1206 | - match: '&&' 1207 | scope: keyword.operator.conditional.and.SYNTAX 1208 | set: conditionalAndExpression 1209 | - bail 1210 | 1211 | valueLogical: 1212 | - goto: relationalExpression 1213 | 1214 | relationalExpression: 1215 | - goto: [relationalExpression_AFTER_NUMERIC_EXPRESSION, numericExpression] 1216 | 1217 | relationalExpression_AFTER_NUMERIC_EXPRESSION: 1218 | - match: '=' 1219 | scope: keyword.operator.relational.equality.SYNTAX 1220 | set: numericExpression 1221 | - match: '!=' 1222 | scope: keyword.operator.relational.non-equality.SYNTAX 1223 | set: numericExpression 1224 | - match: '<=' 1225 | scope: keyword.operator.relational.less-than-or-equal-to.SYNTAX 1226 | set: numericExpression 1227 | - match: '>=' 1228 | scope: keyword.operator.relational.greater-than-or-equal-to.SYNTAX 1229 | set: numericExpression 1230 | - match: '<' 1231 | scope: keyword.operator.relational.less-than.SYNTAX 1232 | set: numericExpression 1233 | - match: '>' 1234 | scope: keyword.operator.relational.greater-than.SYNTAX 1235 | set: numericExpression 1236 | - word: in 1237 | scope: keyword.operator.word.modifier.relational.in.SYNTAX 1238 | set: expressionList 1239 | - word: not 1240 | scope: keyword.operator.word.modifier.relational.not.SYNTAX 1241 | set: relationalExpression_AFTER_NOT 1242 | - bail 1243 | 1244 | relationalExpression_AFTER_NOT: 1245 | - word: in 1246 | scope: keyword.operator.word.modifier.relational.in.SYNTAX 1247 | set: expressionList 1248 | 1249 | numericExpression: 1250 | - goto: additiveExpression 1251 | 1252 | additiveExpression: 1253 | - goto: [additiveExpression_MORE, multiplicativeExpression] 1254 | 1255 | additiveExpression_MORE: 1256 | - match: '{{numericLiteralPositive_LOOKAHEAD}}|{{numericLiteralNegative_LOOKAHEAD}}' 1257 | push: [additiveExpression_AFTER_SIGNED_NUMERIC_LITERAL, numericLiteral] 1258 | - match: '\+' 1259 | scope: keyword.operator.arithmetic.addition.SYNTAX 1260 | set: additiveExpression 1261 | - match: '\-' 1262 | scope: keyword.operator.arithmetic.subtraction.SYNTAX 1263 | set: additiveExpression 1264 | - bail 1265 | 1266 | additiveExpression_AFTER_SIGNED_NUMERIC_LITERAL: 1267 | - match: '\*' 1268 | scope: keyword.operator.arithmetic.multiplication.SYNTAX 1269 | push: unaryExpression 1270 | - match: '/' 1271 | scope: keyword.operator.arithmetic.division.SYNTAX 1272 | push: unaryExpression 1273 | - bail 1274 | 1275 | multiplicativeExpression: 1276 | - goto: [multiplicativeExpression_MORE, unaryExpression] 1277 | 1278 | multiplicativeExpression_MORE: 1279 | - match: '\*' 1280 | scope: keyword.operator.arithmetic.multiplication.SYNTAX 1281 | set: multiplicativeExpression 1282 | - match: '/' 1283 | scope: keyword.operator.arithmetic.division.SYNTAX 1284 | set: multiplicativeExpression 1285 | - bail 1286 | 1287 | unaryExpression: 1288 | - match: '!' 1289 | scope: keyword.operator.logical.not.SYNTAX 1290 | set: primaryExpression 1291 | - match: '\+' 1292 | scope: keyword.operator.arithmetic.sign.positive.SYNTAX 1293 | set: primaryExpression 1294 | - match: '-' 1295 | scope: keyword.operator.arithmetic.sign.negative.SYNTAX 1296 | set: primaryExpression 1297 | - goto: primaryExpression 1298 | 1299 | primaryExpression: 1300 | - switch: 1301 | - functionCall 1302 | - var 1303 | - brackettedExpression 1304 | - include: builtInCall 1305 | - include: literal 1306 | - goto: namedNode 1307 | mask: meta.term.role.expression.SYNTAX 1308 | 1309 | brackettedExpression: 1310 | - open.paren: definition.expression 1311 | set: [brackettedExpression_TERMINATE, expression] 1312 | 1313 | brackettedExpression_TERMINATE: 1314 | - meta_content_scope: meta.group.bracketted-expression.SYNTAX 1315 | - close.paren: definition.expression 1316 | pop: true 1317 | 1318 | builtInCall: 1319 | - words: 1320 | - str 1321 | - lang 1322 | - datatype 1323 | - iri 1324 | - uri 1325 | - rand 1326 | - abs 1327 | - ceil 1328 | - floor 1329 | - round 1330 | - strlen 1331 | - ucase 1332 | - lcase 1333 | - encode_for_uri 1334 | - year 1335 | - month 1336 | - day 1337 | - hours 1338 | - minutes 1339 | - seconds 1340 | - timezone 1341 | - tz 1342 | - md5 1343 | - sha1 1344 | - sha256 1345 | - sha384 1346 | - sha512 1347 | scope: support.function.built-in.WORD.SYNTAX 1348 | set: 1349 | - builtInCall_TERMINATE 1350 | - expression 1351 | - builtInCallArguments 1352 | - words.camel: 1353 | - langMatches 1354 | - contains 1355 | - strStarts 1356 | - strBefore 1357 | - strAfter 1358 | - strLang 1359 | - strDt 1360 | - sameTerm 1361 | scope: support.function.built-in.WORD.SYNTAX 1362 | set: 1363 | - builtInCall_TERMINATE 1364 | - expression 1365 | - builtInCall_AFTER_ARGUMENT 1366 | - expression 1367 | - builtInCallArguments 1368 | - word: bound 1369 | scope: support.function.built-in.WORD.SYNTAX 1370 | set: 1371 | - builtInCall_TERMINATE 1372 | - var 1373 | - builtInCallArguments 1374 | - word: bnode 1375 | scope: support.function.built-in.WORD.SYNTAX 1376 | set: 1377 | - builtInCall_TERMINATE 1378 | - optionalArgumentExpression 1379 | - builtInCallArguments 1380 | - words: 1381 | - rand 1382 | - now 1383 | - uuid 1384 | scope: support.function.built-in.WORD.SYNTAX 1385 | set: 1386 | - builtInCall_TERMINATE 1387 | - builtInCallArguments 1388 | - words: 1389 | - concat 1390 | - coalesce 1391 | scope: support.function.built-in.WORD.SYNTAX 1392 | set: expressionList 1393 | - words.camel: 1394 | - isIri 1395 | - isUri 1396 | - isBlank 1397 | - isLiteral 1398 | - isNumeric 1399 | scope: support.function.built-in.WORD.SYNTAX 1400 | set: 1401 | - builtInCall_TERMINATE 1402 | - expression 1403 | - builtInCallArguments 1404 | - words.camel: struuid 1405 | scope: support.function.built-in.WORD.SYNTAX 1406 | set: 1407 | - builtInCall_TERMINATE 1408 | - builtInCallArguments 1409 | - word: if 1410 | scope: support.function.built-in.WORD.SYNTAX 1411 | set: 1412 | - builtInCall_TERMINATE 1413 | - expression 1414 | - builtInCall_AFTER_ARGUMENT 1415 | - expression 1416 | - builtInCall_AFTER_ARGUMENT 1417 | - expression 1418 | - builtInCallArguments 1419 | - words: 1420 | - regex 1421 | - substr 1422 | scope: support.function.built-in.WORD.SYNTAX 1423 | set: 1424 | - builtInCall_TERMINATE 1425 | - builtInCall_OPTIONAL_ARGUMENT 1426 | - expression 1427 | - builtInCall_AFTER_ARGUMENT 1428 | - expression 1429 | - builtInCallArguments 1430 | - word: replace 1431 | scope: support.function.built-in.WORD.SYNTAX 1432 | set: 1433 | - builtInCall_TERMINATE 1434 | - builtInCall_OPTIONAL_ARGUMENT 1435 | - expression 1436 | - builtInCall_AFTER_ARGUMENT 1437 | - expression 1438 | - builtInCall_AFTER_ARGUMENT 1439 | - expression 1440 | - builtInCallArguments 1441 | - word: exists 1442 | scope: support.function.built-in.WORD.SYNTAX 1443 | set: groupGraphPattern 1444 | - word: not 1445 | scope: support.function.built-in.WORD.SYNTAX 1446 | set: notExistsFunc_AFTER_NOT 1447 | - include: aggregateFunction 1448 | 1449 | builtInCallArguments: 1450 | - open.paren: definition.arguments 1451 | pop: true 1452 | 1453 | builtInCall_OPTIONAL_ARGUMENT: 1454 | - match: ',' 1455 | scope: punctuation.separator.argument.SYNTAX 1456 | set: expression 1457 | - bail 1458 | 1459 | builtInCall_AFTER_ARGUMENT: 1460 | - match: ',' 1461 | scope: punctuation.separator.argument.SYNTAX 1462 | pop: true 1463 | 1464 | builtInCall_TERMINATE: 1465 | - meta_content_scope: meta.invocation.built-in.SYNTAX 1466 | - close.paren: definition.arguments 1467 | pop: true 1468 | 1469 | optionalArgumentExpression: 1470 | - close.paren: definition.arguments 1471 | pop: true 1472 | - goto: expression 1473 | 1474 | 1475 | notExistsFunc_AFTER_NOT: 1476 | - word: exists 1477 | scope: support.function.built-in.WORD.SYNTAX 1478 | set: groupGraphPattern 1479 | 1480 | aggregateFunction: 1481 | - words: 1482 | - sum 1483 | - min 1484 | - max 1485 | - avg 1486 | - sample 1487 | scope: support.function.built-in.aggregate.SYNTAX 1488 | set: 1489 | - aggregateFunction_TERMINATE 1490 | - expression 1491 | - aggregateFunctionArguments 1492 | - word: count 1493 | scope: support.function.built-in.aggregate.SYNTAX 1494 | set: 1495 | - aggregateFunction_TERMINATE 1496 | - countExpression 1497 | - aggregateFunctionArguments 1498 | - word: group_concat 1499 | scope: support.function.built-in.aggregate.SYNTAX 1500 | set: 1501 | - aggregateFunction_TERMINATE 1502 | - groupConcatOption 1503 | - expression 1504 | - aggregateFunctionArguments 1505 | 1506 | aggregateFunction_TERMINATE: 1507 | - meta_content_scope: meta.invocation.function-call.aggregate.SYNTAX 1508 | - goto: builtInCall_TERMINATE 1509 | 1510 | aggregateFunctionArguments: 1511 | - open.paren: definition.arguments 1512 | set: aggregateFunctionArguments_AFTER_BEGIN 1513 | 1514 | aggregateFunctionArguments_AFTER_BEGIN: 1515 | - word: distinct 1516 | scope: keyword.operator.word.modifier.distinct.function-call.SYNTAX 1517 | pop: true 1518 | - bail 1519 | 1520 | countExpression: 1521 | - match: '\*' 1522 | scope: keyword.operator.star.count.SYNTAX 1523 | pop: true 1524 | - include: expression 1525 | 1526 | groupConcatOption: 1527 | - match: ';' 1528 | scope: punctuation.separator.group-concat.SYNTAX 1529 | set: groupConcatOption_AFTER_SEMICOLON 1530 | - bail 1531 | 1532 | groupConcatOption_AFTER_SEMICOLON: 1533 | - word: separator 1534 | type: modifier 1535 | set: groupConcatOption_AFTER_SEPARATOR 1536 | 1537 | groupConcatOption_AFTER_SEPARATOR: 1538 | - match: '=' 1539 | scope: keyword.operator.assignment.group-concat.SYNTAX 1540 | set: stringLiteral 1541 | 1542 | blankNode: 1543 | - switch: 1544 | - labeledBlankNode 1545 | - hollowAnonymousBlankNode 1546 | 1547 | integer: 1548 | - match: '[0-9]+' 1549 | scope: constant.numeric.integer.ttl 1550 | pop: true 1551 | 1552 | nil: 1553 | - open.paren: section.collection 1554 | set: nil_AFTER_BEGIN 1555 | 1556 | nil_AFTER_BEGIN: 1557 | - close.paren: section.collection 1558 | pop: true 1559 | - bail 1560 | -------------------------------------------------------------------------------- /src/syntax/t-family.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | extends: terse.syntax-source 4 | 5 | contexts: 6 | prototype: 7 | - include: whitespace 8 | - include: comment 9 | 10 | directive: 11 | - switch: 12 | - baseDeclaration 13 | - prefixDeclaration 14 | - retry 15 | 16 | triple_TERMINATE: 17 | - match: '\.' 18 | scope: punctuation.terminator.triple.SYNTAX 19 | pop: true 20 | 21 | baseDeclaration: 22 | - lookahead.i: '@?base\b' 23 | - include: baseDeclarationSparql 24 | - match: '@' 25 | scope: punctuation.definition.storage.base.at.SYNTAX storage.type.base.at.SYNTAX 26 | set: [baseDeclarationAt_TERMINATE, baseDeclarationAt_AFTER_AT] 27 | 28 | baseDeclarationAt_AFTER_AT: 29 | - word: base 30 | scope: storage.type.base.at.SYNTAX 31 | set: iriRef 32 | mask: meta.term.role.base-declaration.SYNTAX 33 | - retry 34 | 35 | baseDeclarationAt_TERMINATE: 36 | - meta_include_prototype: false 37 | - match: '\n' 38 | scope: invalid.illegal.token.expected.baseDeclarationAt_TERMINATE.SYNTAX 39 | - match: '\.' 40 | scope: punctuation.terminator.base-declaration.SYNTAX 41 | pop: true 42 | - include: comment 43 | 44 | prefixDeclaration: 45 | - lookahead.i: '@?prefix\b' 46 | - include: prefixDeclarationSparql 47 | - match: '@' 48 | scope: punctuation.definition.storage.prefix.at.SYNTAX storage.type.prefix.at.SYNTAX 49 | set: prefixDeclarationAt_AFTER_AT 50 | 51 | prefixDeclarationAt_AFTER_AT: 52 | - word: prefix 53 | boundary: '(?:{{KEYWORD_BOUNDARY}}|:)' 54 | scope: storage.type.prefix.at.SYNTAX 55 | set: [prefixDeclarationAt_TERMINATE, prefixDeclarationAt_AFTER_KEYWORD_SPACE, prefixDeclaration_AFTER_KEYWORD] 56 | - retry 57 | 58 | prefixDeclarationAt_AFTER_KEYWORD_SPACE: 59 | - _registeredPrefixDeclarations: at 60 | - match: '(({{PN_PREFIX}}?)(:))' 61 | captures: 62 | 1: meta.prefix-declaration.at.namespace.SYNTAX 63 | 2: variable.other.readwrite.prefixed-name.namespace.prefix-declaration.SYNTAX 64 | 3: punctuation.separator.prefixed-name.namespace.prefix-declaration.SYNTAX 65 | set: iriRef 66 | mask: meta.term.role.prefix-declaration.SYNTAX 67 | - throw: true 68 | add.front: meta.prefix-declaration.at.namespace.SYNTAX 69 | 70 | prefixDeclarationAt_TERMINATE: 71 | - meta_include_prototype: false 72 | - match: '\n' 73 | scope: invalid.illegal.token.expected.prefixDeclarationAt_TERMINATE.SYNTAX 74 | - match: '\.' 75 | scope: punctuation.terminator.prefix-declaration.SYNTAX 76 | pop: true 77 | - include: comment 78 | 79 | triples: 80 | - switch: 81 | - tripleX: [predicateObjectList^, tripleX] 82 | - hollowAnonymousBlankNode: [predicateObjectList^, hollowAnonymousBlankNode] 83 | - anonymousBlankNode: [predicateObjectList?, blankNodePropertyList] 84 | - collection: [predicateObjectList^, collection] 85 | - namedNode: [predicateObjectList^, namedNode] 86 | - labeledBlankNode: [predicateObjectList^, labeledBlankNode] 87 | - retry 88 | 89 | predicateObjectList: 90 | - switch: 91 | - verb: [predicateObjectList_AFTER_OBJECT_LIST, objectList, verb] 92 | 93 | predicateObjectList_AFTER_OBJECT_LIST: 94 | - match: ';' 95 | scope: punctuation.separator.predicate-object-list.SYNTAX 96 | set: predicateObjectList? 97 | - bail 98 | 99 | object: 100 | - switch: 101 | - hollowAnonymousBlankNode 102 | - anonymousBlankNode: blankNodePropertyList 103 | - include: objectData 104 | 105 | collection_AFTER_BEGIN: 106 | - close.paren: section.collection 107 | pop: true 108 | - goto.push: object+ 109 | 110 | blankNodePropertyList: 111 | - open.bracket: definition.blank-node-property-list 112 | set: blankNodePropertyList_AFTER_BEGIN 113 | 114 | blankNodePropertyList_AFTER_BEGIN: 115 | - close.bracket: definition.anonymous-blank-node.hack 116 | pop: true 117 | - switch: 118 | - verb: [blankNodePropertyList_TERMINATE, predicateObjectList] 119 | -------------------------------------------------------------------------------- /src/syntax/terse.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | extends: human-readable.syntax-source 4 | 5 | variables: 6 | 7 | PN_PREFIX: >- 8 | (?x) 9 | (?: 10 | {{PN_CHARS_BASE}} 11 | (?: 12 | (?:{{PN_CHARS}}|\.)* 13 | {{PN_CHARS}} 14 | )? 15 | ) 16 | 17 | PN_LOCAL_ESC: '\\[-_~.!$&''()*+,;=/?#@%]' 18 | PLX: '(?:%{{HEX}}{2}|{{PN_LOCAL_ESC}})' 19 | 20 | PN_LOCAL_OPEN: '{{PN_CHARS_U}}|:|[0-9]' 21 | PN_LOCAL_GROUP_2: '{{PN_CHARS}}|:' 22 | PN_LOCAL_GROUP_1: '{{PN_LOCAL_GROUP_2}}|\.' 23 | 24 | PN_LOCAL: >- 25 | (?x) 26 | (?: 27 | (?: 28 | {{PN_LOCAL_OPEN}} 29 | |{{PLX}} 30 | ) 31 | (?: 32 | (?: 33 | {{PN_LOCAL_GROUP_1}} 34 | |{{PLX}} 35 | )* 36 | (?: 37 | {{PN_LOCAL_GROUP_2}} 38 | |{{PLX}} 39 | ) 40 | )? 41 | ) 42 | 43 | EXPONENT: '([eE])([+-]?)([0-9]+)' 44 | STRING_SHORT_SINGLE: '[^\x{27}\x{5C}\x{0A}\x{0D}]' 45 | STRING_SHORT_DOUBLE: '[^\x{22}\x{5C}\x{0A}\x{0D}]' 46 | ECHAR_SINGLE: '(?:\\[tbnrf''\\])' 47 | ECHAR_DOUBLE: '(?:\\[tbnrf"\\])' 48 | 49 | 50 | BLANK_NODE_LABEL: '(?:{{PN_CHARS_U}}|[0-9])(?:(?:{{PN_CHARS}}|\.)*{{PN_CHARS}})?' 51 | 52 | 53 | # lookaheads 54 | 55 | # openBrace_LOOKAHEAD: '(?=\{)' 56 | # openParen_LOOKAHEAD: '(?=\()' 57 | 58 | # prefixedNameLocal: '{{PN_LOCAL}}' 59 | # prefixedNameNamespace: '{{PN_PREFIX}}?:' 60 | # prefixedNameNamespace_LOOKAHEAD: '(?={{prefixedNameNamespace}})' 61 | 62 | # numericLiteral: '[0-9+-]|\.[0-9]' 63 | # numericLiteral_LOOKAHEAD: '(?={{numericLiteral}})' 64 | # booleanLiteral_LOOKAHEAD: '(?i)(?=(?:true|false){{KEYWORD_BOUNDARY}})' 65 | 66 | # a_LOOKAHEAD: '(?=a{{KEYWORD_BOUNDARY}})' 67 | 68 | # collection_LOOKAHEAD: '(?=\()' 69 | 70 | # literal_LOOKAHEAD: '(?={{stringLiteral_LOOKAHEAD}}|{{numericLiteral_LOOKAHEAD}}|{{booleanLiteral_LOOKAHEAD}})' 71 | 72 | # namedNode_LOOKAHEAD: '(?:{{iriRef_LOOKAHEAD}}|{{prefixedNameNamespace_LOOKAHEAD}})' 73 | 74 | # node_LOOKAHEAD: '(?:{{namedNode_LOOKAHEAD}}|{{blankNode_LOOKAHEAD}})' 75 | 76 | # object_LOOKAHEAD: '{{node_LOOKAHEAD}}|{{literal_LOOKAHEAD}}|{{collection_LOOKAHEAD}}' 77 | 78 | tripleTerminator_LOOKAHEAD: '(?=[.\])}#])' 79 | objectTerminator_LOOKAHEAD: '(?=[;,^@]|{{tripleTerminator_LOOKAHEAD}})' 80 | 81 | # hollowAnonymousBlankNode_LOOKAHEAD: '(?=\[[\s\n]*\])' 82 | 83 | 84 | contexts: 85 | baseDeclarationSparql: 86 | - meta_scope: meta.base-declaration.keyword.SYNTAX 87 | - word: base 88 | scope: storage.type.base.sparql.SYNTAX 89 | set: iriRef 90 | mask: meta.term.role.base-declaration.SYNTAX 91 | 92 | prefixDeclarationSparql: 93 | - word: prefix 94 | boundary: '(?:{{KEYWORD_BOUNDARY}}|:)' 95 | scope: storage.type.prefix.sparql.SYNTAX 96 | set: [prefixDeclarationSparql_AFTER_KEYWORD_SPACE, prefixDeclaration_AFTER_KEYWORD] 97 | 98 | prefixDeclaration_AFTER_KEYWORD: 99 | - alone 100 | - match: '\s+|$' 101 | scope: meta.whitespace.SYNTAX 102 | pop: true 103 | - include: prototype 104 | - retry 105 | 106 | prefixDeclarationSparql_AFTER_KEYWORD_SPACE: 107 | - _registeredPrefixDeclarations: sparql 108 | - match: '(({{PN_PREFIX}}?)(:))' 109 | captures: 110 | 1: meta.prefix-declaration.sparql.namespace.SYNTAX 111 | 2: variable.other.readwrite.prefixed-name.namespace.prefix-declaration.SYNTAX 112 | 3: punctuation.separator.prefixed-name.namespace.prefix-declaration.SYNTAX 113 | set: iriRef 114 | mask: meta.term.role.prefix-declaration.SYNTAX 115 | - throw: true 116 | add.front: meta.prefix-declaration.sparql.namespace.SYNTAX 117 | 118 | predicateData: 119 | - switch: 120 | - a 121 | - namedNode 122 | mask: meta.term.role.predicate.SYNTAX 123 | 124 | a: 125 | - match: 'a(?={{KEYWORD_BOUNDARY}})' 126 | scope: support.constant.predicate.a.SYNTAX 127 | pop: true 128 | 129 | objectData: 130 | - switch: 131 | - collection 132 | - labeledBlankNode 133 | - tripleX 134 | - namedNode 135 | mask: meta.term.role.object.SYNTAX 136 | - goto: literal 137 | mask: meta.term.role.object.SYNTAX 138 | 139 | literal: 140 | - switch: 141 | - stringLiteral: rdfLiteral 142 | - words: 143 | - 'true' 144 | - 'false' 145 | scope: constant.language.boolean.WORD.SYNTAX 146 | pop: true 147 | - include: numericLiteral 148 | 149 | blankNodePropertyList: 150 | - open.bracket: definition.blank-node-property-list 151 | set: [blankNodePropertyList_TERMINATE, predicateObjectList] 152 | 153 | blankNodePropertyList_TERMINATE: 154 | - close.bracket: definition.blank-node-property-list 155 | pop: true 156 | 157 | objectList: 158 | - goto: [objectList_AFTER_OBJECT, object] 159 | 160 | objectList_AFTER_OBJECT: 161 | - match: ',' 162 | scope: punctuation.separator.object.rq 163 | push: object 164 | - match: '{{objectTerminator_LOOKAHEAD}}' 165 | pop: true 166 | - retry 167 | # - include: else_pop 168 | 169 | collection: 170 | - open.paren: section.collection 171 | set: collection_AFTER_BEGIN 172 | 173 | collection_TERMINATE: 174 | - close.paren: section.collection 175 | pop: true 176 | 177 | numericLiteral: 178 | - include: double 179 | - include: decimal 180 | - include: integer 181 | 182 | double: 183 | - match: '((?:(\+)|(-))?([0-9]+)(\.)([0-9]*){{EXPONENT}})' 184 | captures: 185 | 1: constant.numeric.decimal.SYNTAX 186 | 2: keyword.operator.arithmetic.sign.positive.SYNTAX 187 | 3: keyword.operator.arithmetic.sign.negative.SYNTAX 188 | 4: meta.numeric.decimal.characteristic.SYNTAX 189 | 5: punctuation.decimal.SYNTAX 190 | 6: meta.numeric.decimal.mantissa.SYNTAX 191 | 7: meta.numeric.exponent.e.SYNTAX 192 | 8: meta.numeric.exponent.sign.SYNTAX 193 | 9: meta.numeric.exponent.digit.SYNTAX 194 | pop: true 195 | - match: '((?:(\+)|(-))?(\.)?([0-9]+){{EXPONENT}})' 196 | captures: 197 | 1: constant.numeric.decimal.SYNTAX 198 | 2: keyword.operator.arithmetic.sign.positive.SYNTAX 199 | 3: keyword.operator.arithmetic.sign.negative.SYNTAX 200 | 4: punctuation.decimal.SYNTAX 201 | 5: meta.numeric.decimal.mantissa.SYNTAX 202 | 6: meta.numeric.exponent.e.SYNTAX 203 | 7: meta.numeric.exponent.sign.SYNTAX 204 | 8: meta.numeric.exponent.digit.SYNTAX 205 | pop: true 206 | 207 | decimal: 208 | - match: '((?:(\+)|(-))?([0-9]*)(\.)([0-9]+))' 209 | captures: 210 | 1: constant.numeric.decimal.SYNTAX 211 | 2: keyword.operator.arithmetic.sign.positive.SYNTAX 212 | 3: keyword.operator.arithmetic.sign.negative.SYNTAX 213 | 4: meta.numeric.decimal.characteristic.SYNTAX 214 | 5: punctuation.decimal.SYNTAX 215 | 6: meta.numeric.decimal.mantissa.SYNTAX 216 | pop: true 217 | 218 | integer: 219 | - match: '((?:(\+)|(-))?([0-9]+))' 220 | captures: 221 | 1: constant.numeric.integer.SYNTAX 222 | 2: keyword.operator.arithmetic.sign.positive.SYNTAX 223 | 3: keyword.operator.arithmetic.sign.negative.SYNTAX 224 | 4: meta.numeric.decimal.integer.SYNTAX 225 | pop: true 226 | 227 | stringLiteral: 228 | - match: '"""' 229 | scope: punctuation.definition.string.begin.literal.double.long.SYNTAX 230 | set: stringLiteralLongDouble 231 | - open.dirk: literal.double.short 232 | set: stringLiteralShortDouble 233 | - match: '''''''' 234 | scope: punctuation.definition.string.begin.literal.single.long.SYNTAX 235 | set: stringLiteralLongSingle 236 | - open.irk: literal.single.short 237 | set: stringLiteralShortSingle 238 | 239 | stringLiteralLongDouble: 240 | - meta_include_prototype: false 241 | - include: stringLiteralLongDouble_AFTER_INNER_QUOTE 242 | - match: '"""' 243 | scope: punctuation.definition.string.end.literal.double.long.SYNTAX 244 | pop: true 245 | - match: '""?' 246 | scope: string.quoted.double.literal.long.SYNTAX 247 | 248 | stringLiteralLongDouble_AFTER_INNER_QUOTE: 249 | - match: '[^"\\]' 250 | scope: string.quoted.double.literal.long.SYNTAX 251 | set: stringLiteralLongDouble 252 | - match: '{{ECHAR_DOUBLE}}' 253 | scope: string.quoted.double.literal.long.SYNTAX constant.character.escape.literal.escape.long.SYNTAX 254 | set: stringLiteralLongDouble 255 | - match: '\\''' 256 | scope: string.quoted.double.literal.long.SYNTAX constant.character.escape.literal.escape.pointless.long.SYNTAX 257 | set: stringLiteralLongDouble 258 | - match: '{{UCHAR}}' 259 | scope: string.quoted.double.literal.long.SYNTAX constant.character.escape.literal.unicode.long.SYNTAX 260 | set: stringLiteralLongDouble 261 | - match: '\\.' 262 | scope: string.quoted.double.literal.long.SYNTAX invalid.illegal.escape.SYNTAX 263 | pop: true 264 | 265 | stringLiteralShortDouble: 266 | - meta_include_prototype: false 267 | - meta_scope: string.quoted.double.literal.short.SYNTAX 268 | - match: '{{STRING_SHORT_DOUBLE}}+' 269 | - close.dirk: literal.double.short 270 | pop: true 271 | - match: '{{ECHAR_DOUBLE}}' 272 | scope: constant.character.escape.literal.escape.short.SYNTAX 273 | - match: '\\''' 274 | scope: constant.character.escape.literal.escape.pointless.short.SYNTAX 275 | - match: '{{UCHAR}}' 276 | scope: constant.character.escape.literal.unicode.short.SYNTAX 277 | - match: '\\.' 278 | scope: invalid.illegal.escape.SYNTAX 279 | pop: true 280 | - match: '\n' 281 | scope: invalid.illegal.newline.literal.double.short.SYNTAX 282 | pop: true 283 | 284 | stringLiteralLongSingle: 285 | - meta_include_prototype: false 286 | - include: stringLiteralLongSingle_AFTER_INNER_QUOTE 287 | - match: '''''''' 288 | scope: punctuation.definition.string.end.literal.single.long.SYNTAX 289 | pop: true 290 | - match: '''''?' 291 | scope: string.quoted.single.literal.long.SYNTAX 292 | 293 | stringLiteralLongSingle_AFTER_INNER_QUOTE: 294 | - match: '[^''\\]' 295 | scope: string.quoted.single.literal.long.SYNTAX 296 | set: stringLiteralLongSingle 297 | - match: '{{ECHAR_SINGLE}}' 298 | scope: string.quoted.single.literal.long.SYNTAX constant.character.escape.literal.escape.single.SYNTAX 299 | set: stringLiteralLongSingle 300 | - match: '\\"' 301 | scope: string.quoted.single.literal.long.SYNTAX constant.character.escape.literal.escape.pointless.single.SYNTAX 302 | set: stringLiteralLongSingle 303 | - match: '{{UCHAR}}' 304 | scope: string.quoted.single.literal.long.SYNTAX constant.character.escape.literal.unicode.single.SYNTAX 305 | set: stringLiteralLongSingle 306 | - match: '\\.' 307 | scope: string.quoted.double.literal.long.SYNTAX invalid.illegal.escape.SYNTAX 308 | pop: true 309 | 310 | stringLiteralShortSingle: 311 | - meta_include_prototype: false 312 | - meta_scope: string.quoted.single.literal.short.SYNTAX 313 | - match: '{{STRING_SHORT_SINGLE}}+' 314 | - match: '''' 315 | scope: punctuation.definition.string.end.literal.single.short.SYNTAX 316 | pop: true 317 | - match: '{{ECHAR_SINGLE}}' 318 | scope: constant.character.escape.literal.escape.short.SYNTAX 319 | - match: '\\"' 320 | scope: constant.character.escape.literal.escape.pointless.short.SYNTAX 321 | - match: '{{UCHAR}}' 322 | scope: constant.character.escape.literal.unicode.short.SYNTAX 323 | - match: '\\.' 324 | scope: invalid.illegal.escape.SYNTAX 325 | pop: true 326 | - match: '\n' 327 | scope: invalid.illegal.newline.literal.single.short.SYNTAX 328 | pop: true 329 | 330 | verb: 331 | - switch: 332 | - a 333 | - namedNode 334 | mask: meta.term.role.predicate.SYNTAX 335 | 336 | datatype: 337 | - meta_include_prototype: false 338 | - switch: 339 | - namedNode 340 | mask: meta.term.role.datatype.SYNTAX 341 | 342 | namedNode: 343 | - switch: 344 | - iriRef 345 | - prefixedName 346 | 347 | tripleX: 348 | - match: '<<' 349 | scope: punctuation.definition.triple-x.begin.SYNTAX meta.triple.reified.SYNTAX 350 | mask: meta.triple.reified.SYNTAX 351 | set: [tripleX_TERMINATE, tripleX_AFTER_BEGIN] 352 | 353 | tripleXNested: 354 | - goto: tripleX 355 | mask: meta.triple.reified-nested.SYNTAX 356 | 357 | tripleX_AFTER_BEGIN: 358 | - switch: 359 | - tripleX: [predicateObjectListX^, tripleXNested] 360 | - labeledBlankNode: [predicateObjectListX^, labeledBlankNode] 361 | - namedNode: [predicateObjectListX^, namedNode] 362 | - hollowAnonymousBlankNode: [predicateObjectListX^, hollowAnonymousBlankNode] 363 | - throw 364 | 365 | predicateObjectListX: 366 | - switch: 367 | - verb: [objectX, verb] 368 | 369 | objectX: 370 | - switch: 371 | - tripleXNested 372 | - labeledBlankNode 373 | - namedNode 374 | - hollowAnonymousBlankNode 375 | mask: meta.term.role.object.SYNTAX 376 | - goto: literal 377 | mask: meta.term.role.object.SYNTAX 378 | 379 | tripleX_TERMINATE: 380 | - match: '>>' 381 | scope: punctuation.definition.triple-x.end.SYNTAX 382 | pop: true 383 | 384 | prefixedName: 385 | - goto: [prefixedNameLocal, prefixedNameNamespace] 386 | 387 | prefixedNameNamespace: 388 | - match: '({{PN_PREFIX}}?)(:)' 389 | captures: 390 | 1: variable.other.readwrite.prefixed-name.namespace.SYNTAX 391 | 2: punctuation.separator.prefixed-name.namespace.SYNTAX 392 | pop: true 393 | 394 | prefixedNameLocal: 395 | - meta_include_prototype: false 396 | - match: '{{PN_LOCAL_OPEN}}' 397 | scope: variable.other.member.prefixed-name.local.SYNTAX 398 | - match: '{{PLX}}' 399 | scope: variable.other.member.prefixed-name.local.SYNTAX constant.character.escape.prefixed-name.local.SYNTAX 400 | - goto: prefixedNameLocal_AFTER_OPEN 401 | 402 | prefixedNameLocal_AFTER_OPEN: 403 | - meta_include_prototype: false 404 | - match: '{{PN_LOCAL_GROUP_1}}(?!{{KEYWORD_BOUNDARY}})' 405 | scope: variable.other.member.prefixed-name.local.SYNTAX 406 | - match: '{{PLX}}(?!{{KEYWORD_BOUNDARY}})' 407 | scope: variable.other.member.prefixed-name.local.SYNTAX constant.character.escape.prefixed-name.local.SYNTAX 408 | - goto: prefixedNameLocal_AFTER_GROUP_1 409 | 410 | prefixedNameLocal_AFTER_GROUP_1: 411 | - meta_include_prototype: false 412 | - match: '{{PN_LOCAL_GROUP_2}}' 413 | scope: variable.other.member.prefixed-name.local.SYNTAX 414 | - match: '{{PLX}}' 415 | scope: variable.other.member.prefixed-name.local.SYNTAX constant.character.escape.prefixed-name.local.SYNTAX 416 | - bail 417 | 418 | hollowAnonymousBlankNode: 419 | - lookahead: '\[[\s\n]*\]' 420 | - open.bracket: definition.anonymous-blank-node 421 | set: hollowAnonymousBlankNode_AFTER_BEGIN 422 | 423 | hollowAnonymousBlankNode_AFTER_BEGIN: 424 | - close.bracket: definition.anonymous-blank-node 425 | pop: true 426 | 427 | -------------------------------------------------------------------------------- /src/syntax/trig.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: TriG 4 | file_extensions: 5 | - trig 6 | scope: source.trig 7 | extends: t-family.syntax-source 8 | 9 | lookaheads.i: 10 | graph: 'graph{{KEYWORD_BOUNDARY}}' 11 | 12 | 13 | contexts: 14 | 15 | main: 16 | - switch.push: 17 | - directive 18 | - block 19 | - retry 20 | 21 | block: 22 | - word: graph 23 | scope: keyword.control.graph.trig 24 | set: block_AFTER_GRAPH 25 | - switch: 26 | - wrappedGraph 27 | - hollowAnonymousBlankNode: triplesOrGraph 28 | - triples2 29 | - triplesOrGraph 30 | 31 | block_AFTER_GRAPH: 32 | - goto: [wrappedGraph, graphTerm] 33 | 34 | graphTerm: 35 | - goto: labelOrSubject 36 | mask: meta.term.role.graph.SYNTAX 37 | 38 | triplesOrGraph: 39 | - lookaheads: [labelOrSubject] 40 | - goto: [triplesOrGraph_AFTER_LABEL_OR_SUBJECT, graphOrSubjectTerm] 41 | 42 | graphOrSubjectTerm: 43 | - goto: labelOrSubject 44 | mask: meta.term.role.graph-or-subject.SYNTAX 45 | 46 | triplesOrGraph_AFTER_LABEL_OR_SUBJECT: 47 | - switch: 48 | - wrappedGraph 49 | - verb: [triplesOrGraph_AFTER_PREDICATE_OBJECT_LIST, predicateObjectList] 50 | - retry 51 | 52 | triplesOrGraph_AFTER_PREDICATE_OBJECT_LIST: 53 | - goto: triple_TERMINATE 54 | 55 | triples2: 56 | - lookahead: '[\[\(]' 57 | - switch: 58 | - anonymousBlankNode: [triple_TERMINATE, predicateObjectList?, blankNodePropertyList] 59 | - collection: [triple_TERMINATE, predicateObjectList^, collection] 60 | - retry 61 | 62 | wrappedGraph: 63 | - open.brace: section.wrapped-graph 64 | set: [wrappedGraph_TERMINATE, triplesBlock?] 65 | 66 | wrappedGraph_TERMINATE: 67 | - close.brace: section.wrapped-graph 68 | pop: true 69 | 70 | triplesBlock: 71 | - switch: 72 | - triples: [triplesBlock_AFTER_TRIPLES, triples] 73 | 74 | triplesBlock_AFTER_TRIPLES: 75 | - match: '\.' 76 | scope: punctuation.terminator.triple.trig 77 | set: triplesBlock? 78 | - bail 79 | 80 | labelOrSubject: 81 | - switch: 82 | - namedNode 83 | - blankNode 84 | - retry 85 | 86 | blankNode: 87 | - switch: 88 | - labeledBlankNode 89 | - hollowAnonymousBlankNode 90 | - retry 91 | -------------------------------------------------------------------------------- /src/syntax/turtle.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: Turtle 4 | file_extensions: 5 | - ttl 6 | scope: source.ttl 7 | extends: t-family.syntax-source 8 | 9 | contexts: 10 | main: # turtleDoc -> statement 11 | - switch.push: 12 | - directive 13 | - triples: [triple_TERMINATE, triples] 14 | - retry 15 | -------------------------------------------------------------------------------- /src/syntax/verbose.syntax-source: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | extends: human-readable.syntax-source 4 | 5 | contexts: 6 | prototype: 7 | - include: whitespace 8 | - include: comment 9 | 10 | subject: 11 | - switch: 12 | - iriRef 13 | - labeledBlankNode 14 | mask: meta.term.role.subject.SYNTAX 15 | - retry 16 | 17 | predicate: 18 | - switch: 19 | - iriRef 20 | mask: meta.term.role.predicate.SYNTAX 21 | 22 | object: 23 | - switch: 24 | - iriRef 25 | - labeledBlankNode 26 | - stringLiteral: rdfLiteral 27 | mask: meta.term.role.object.SYNTAX 28 | - retry 29 | 30 | stringLiteral: 31 | - open.dirk: literal.double.long 32 | set: stringLiteral_AFTER_QUOTE 33 | 34 | stringLiteral_AFTER_QUOTE: 35 | - match: '[^"\\\r\n]+' 36 | scope: string.quoted.double.literal.long.SYNTAX 37 | - close.dirk: literal.double.long 38 | pop: true 39 | - match: '{{ECHAR}}' 40 | scope: string.quoted.double.literal.long.SYNTAX constant.character.escape.literal.escape.long.SYNTAX 41 | - match: '{{UCHAR}}' 42 | scope: string.quoted.double.literal.long.SYNTAX constant.character.escape.literal.unicode.long.SYNTAX 43 | 44 | datatype: 45 | - meta_include_prototype: false 46 | - switch: 47 | - iriRef 48 | mask: meta.term.role.datatype.SYNTAX 49 | --------------------------------------------------------------------------------