| 1 |
{ |
| 2 |
"comment": "\n\t\tThe foldings do not currently work the way I want them to. This\n\t\tmay be a limitation of the way they are applied rather than the\n\t\tregexps in use. Nonetheless, the foldings will end on the last\n\t\tidentically indented blank line following an s-expression. Not\n\t\tideal perhaps, but it works. Also, the #illegal pattern never\n\t\tmatches an unpaired ( as being illegal. Why?! -- Rob Rix\n\t\t\n\t\tOk, hopefully this grammar works better on quoted stuff now. It\n\t\tmay break for fancy macros, but should generally work pretty\n\t\tsmoothly. -- Jacob Rus\n\t\t\n\t\tI have attempted to get this under control but because of the way folding\n\t\tand indentation interact in Textmate, I am not sure if it is possible. In the\n\t\tmeantime, I have implemented Python-style folding anchored at newlines.\n\t\tAdditionally, I have made some minor improvements to the numeric constant\n\t\thighlighting. Next up is square bracket expressions, I guess, but that\n\t\tshould be trivial. -- ozy`\n\t", |
| 3 |
"fileTypes": ["scm", "ss", "sch", "rkt"], |
| 4 |
"keyEquivalent": "^~S", |
| 5 |
"name": "scheme", |
| 6 |
"patterns": [ |
| 7 |
{ |
| 8 |
"include": "#comment" |
| 9 |
}, |
| 10 |
{ |
| 11 |
"include": "#block-comment" |
| 12 |
}, |
| 13 |
{ |
| 14 |
"include": "#sexp" |
| 15 |
}, |
| 16 |
{ |
| 17 |
"include": "#string" |
| 18 |
}, |
| 19 |
{ |
| 20 |
"include": "#language-functions" |
| 21 |
}, |
| 22 |
{ |
| 23 |
"include": "#quote" |
| 24 |
}, |
| 25 |
{ |
| 26 |
"include": "#illegal" |
| 27 |
} |
| 28 |
], |
| 29 |
"repository": { |
| 30 |
"comment": { |
| 31 |
"begin": "(^[ \\t]+)?(?=;)", |
| 32 |
"beginCaptures": { |
| 33 |
"1": { |
| 34 |
"name": "punctuation.whitespace.comment.leading.scheme" |
| 35 |
} |
| 36 |
}, |
| 37 |
"end": "(?!\\G)", |
| 38 |
"patterns": [ |
| 39 |
{ |
| 40 |
"begin": ";", |
| 41 |
"beginCaptures": { |
| 42 |
"0": { |
| 43 |
"name": "punctuation.definition.comment.scheme" |
| 44 |
} |
| 45 |
}, |
| 46 |
"end": "\\n", |
| 47 |
"name": "comment.line.semicolon.scheme" |
| 48 |
} |
| 49 |
] |
| 50 |
}, |
| 51 |
"block-comment": { |
| 52 |
"begin": "\\#\\|", |
| 53 |
"contentName": "comment", |
| 54 |
"end": "\\|\\#", |
| 55 |
"name": "comment", |
| 56 |
"patterns": [ |
| 57 |
{ |
| 58 |
"include": "#block-comment", |
| 59 |
"name": "comment" |
| 60 |
} |
| 61 |
] |
| 62 |
}, |
| 63 |
"constants": { |
| 64 |
"patterns": [ |
| 65 |
{ |
| 66 |
"match": "#[t|f]", |
| 67 |
"name": "constant.language.boolean.scheme" |
| 68 |
}, |
| 69 |
{ |
| 70 |
"match": "(?<=[\\(\\s])((#e|#i)?[0-9]+(\\.[0-9]+)?|(#x)[0-9a-fA-F]+|(#o)[0-7]+|(#b)[01]+)(?=[\\s;()'\",\\[\\]])", |
| 71 |
"name": "constant.numeric.scheme" |
| 72 |
} |
| 73 |
] |
| 74 |
}, |
| 75 |
"illegal": { |
| 76 |
"match": "[()\\[\\]]", |
| 77 |
"name": "invalid.illegal.parenthesis.scheme" |
| 78 |
}, |
| 79 |
"language-functions": { |
| 80 |
"patterns": [ |
| 81 |
{ |
| 82 |
"match": "(?x)\n\t\t\t\t\t\t(?<=(\\s|\\(|\\[)) # preceded by space or ( \n\t\t\t\t\t\t( do|or|and|else|quasiquote|begin|if|case|set!|\n\t\t\t\t\t\t cond|let|unquote|define|let\\*|unquote-splicing|delay|\n\t\t\t\t\t\t letrec)\n\t\t\t\t\t\t(?=(\\s|\\())", |
| 83 |
"name": "keyword.control.scheme" |
| 84 |
}, |
| 85 |
{ |
| 86 |
"comment": "\n\t\t\t\t\t\tThese functions run a test, and return a boolean\n\t\t\t\t\t\tanswer.\n\t\t\t\t\t", |
| 87 |
"match": "(?x)\n\t\t\t\t\t\t(?<=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( char-alphabetic|char-lower-case|char-numeric|\n\t\t\t\t\t\t char-ready|char-upper-case|char-whitespace|\n\t\t\t\t\t\t (?:char|string)(?:-ci)?(?:=|<=?|>=?)|\n\t\t\t\t\t\t atom|boolean|bound-identifier=|char|complex|\n\t\t\t\t\t\t identifier|integer|symbol|free-identifier=|inexact|\n\t\t\t\t\t\t eof-object|exact|list|(?:input|output)-port|pair|\n\t\t\t\t\t\t real|rational|zero|vector|negative|odd|null|string|\n\t\t\t\t\t\t eq|equal|eqv|even|number|positive|procedure\n\t\t\t\t\t\t)\n\t\t\t\t\t\t(\\?)\t\t# name ends with ? sign\n\t\t\t\t\t\t(?=(\\s|\\()) # followed by space or (\n\t\t\t\t\t", |
| 88 |
"name": "support.function.boolean-test.scheme" |
| 89 |
}, |
| 90 |
{ |
| 91 |
"comment": "\n\t\t\t\t\t\tThese functions change one type into another.\n\t\t\t\t\t", |
| 92 |
"match": "(?x)\n\t\t\t\t\t\t(?<=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( char->integer|exact->inexact|inexact->exact|\n\t\t\t\t\t\t integer->char|symbol->string|list->vector|\n\t\t\t\t\t\t list->string|identifier->symbol|vector->list|\n\t\t\t\t\t\t string->list|string->number|string->symbol|\n\t\t\t\t\t\t number->string\n\t\t\t\t\t\t)\n\t\t\t\t\t\t(?=(\\s|\\()) # followed by space or (\t\t\t\t\t\n\t\t\t\t\t", |
| 93 |
"name": "support.function.convert-type.scheme" |
| 94 |
}, |
| 95 |
{ |
| 96 |
"comment": "\n\t\t\t\t\t\tThese functions are potentially dangerous because\n\t\t\t\t\t\tthey have side-effects which could affect other\n\t\t\t\t\t\tparts of the program.\n\t\t\t\t\t", |
| 97 |
"match": "(?x)\n\t\t\t\t\t\t(?<=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( set-(?:car|cdr)|\t\t\t\t # set car/cdr\n\t\t\t\t\t\t (?:vector|string)-(?:fill|set) # fill/set string/vector\n\t\t\t\t\t\t)\n\t\t\t\t\t\t(!)\t\t\t# name ends with ! sign\n\t\t\t\t\t\t(?=(\\s|\\()) # followed by space or (\n\t\t\t\t\t", |
| 98 |
"name": "support.function.with-side-effects.scheme" |
| 99 |
}, |
| 100 |
{ |
| 101 |
"comment": "\n\t\t\t\t\t\t+, -, *, /, =, >, etc. \n\t\t\t\t\t", |
| 102 |
"match": "(?x)\n\t\t\t\t\t\t(?<=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( >=?|<=?|=|[*/+-])\n\t\t\t\t\t\t(?=(\\s|\\()) # followed by space or (\n\t\t\t\t\t\t", |
| 103 |
"name": "keyword.operator.arithmetic.scheme" |
| 104 |
}, |
| 105 |
{ |
| 106 |
"match": "(?x)\n\t\t\t\t\t\t(?<=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( append|apply|approximate|\n\t\t\t\t\t\t call-with-current-continuation|call/cc|catch|\n\t\t\t\t\t\t construct-identifier|define-syntax|display|foo|\n\t\t\t\t\t\t for-each|force|format|cd|gen-counter|gen-loser|\n\t\t\t\t\t\t generate-identifier|last-pair|length|let-syntax|\n\t\t\t\t\t\t letrec-syntax|list|list-ref|list-tail|load|log|\n\t\t\t\t\t\t macro|magnitude|map|map-streams|max|member|memq|\n\t\t\t\t\t\t memv|min|newline|nil|not|peek-char|rationalize|\n\t\t\t\t\t\t read|read-char|return|reverse|sequence|substring|\n\t\t\t\t\t\t syntax|syntax-rules|transcript-off|transcript-on|\n\t\t\t\t\t\t truncate|unwrap-syntax|values-list|write|write-char|\n\t\t\t\t\t\t \n\t\t\t\t\t\t # cons, car, cdr, etc\n\t\t\t\t\t\t cons|c(a|d){1,4}r| \n \n\t\t\t\t\t\t # unary math operators\n\t\t\t\t\t\t abs|acos|angle|asin|assoc|assq|assv|atan|ceiling|\n\t\t\t\t\t\t cos|floor|round|sin|sqrt|tan|\n\t\t\t\t\t\t (?:real|imag)-part|numerator|denominator\n \n\t\t\t\t\t\t # other math operators\n\t\t\t\t\t\t modulo|exp|expt|remainder|quotient|lcm|\n \n\t\t\t\t\t\t # ports / files\n\t\t\t\t\t\t call-with-(?:input|output)-file|\n\t\t\t\t\t\t (?:close|current)-(?:input|output)-port|\n\t\t\t\t\t\t with-(?:input|output)-from-file|\n\t\t\t\t\t\t open-(?:input|output)-file|\n\t\t\t\t\t\t \n\t\t\t\t\t\t # char-«foo»\n\t\t\t\t\t\t char-(?:downcase|upcase|ready)|\n\t\t\t\t\t\t \n\t\t\t\t\t\t # make-«foo»\n\t\t\t\t\t\t make-(?:polar|promise|rectangular|string|vector)\n\t\t\t\t\t\t \n\t\t\t\t\t\t # string-«foo», vector-«foo»\n\t\t\t\t\t\t string(?:-(?:append|copy|length|ref))?|\n\t\t\t\t\t\t vector(?:-length|-ref)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t(?=(\\s|\\()) # followed by space or (\n\t\t\t\t\t", |
| 107 |
"name": "support.function.general.scheme" |
| 108 |
} |
| 109 |
] |
| 110 |
}, |
| 111 |
"quote": { |
| 112 |
"comment": "\n\t\t\t\tWe need to be able to quote any kind of item, which creates\n\t\t\t\ta tiny bit of complexity in our grammar. It is hopefully\n\t\t\t\tnot overwhelming complexity.\n\t\t\t\t\n\t\t\t\tNote: the first two matches are special cases. quoted\n\t\t\t\tsymbols, and quoted empty lists are considered constant.other\n\t\t\t\t\n\t\t\t", |
| 113 |
"patterns": [ |
| 114 |
{ |
| 115 |
"captures": { |
| 116 |
"1": { |
| 117 |
"name": "punctuation.section.quoted.symbol.scheme" |
| 118 |
} |
| 119 |
}, |
| 120 |
"match": "(?x)\n\t\t\t\t\t\t(')\\s*\n\t\t\t\t\t\t([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)\n\t\t\t\t\t", |
| 121 |
"name": "constant.other.symbol.scheme" |
| 122 |
}, |
| 123 |
{ |
| 124 |
"captures": { |
| 125 |
"1": { |
| 126 |
"name": "punctuation.section.quoted.empty-list.scheme" |
| 127 |
}, |
| 128 |
"2": { |
| 129 |
"name": "meta.expression.scheme" |
| 130 |
}, |
| 131 |
"3": { |
| 132 |
"name": "punctuation.section.expression.begin.scheme" |
| 133 |
}, |
| 134 |
"4": { |
| 135 |
"name": "punctuation.section.expression.end.scheme" |
| 136 |
} |
| 137 |
}, |
| 138 |
"match": "(?x)\n\t\t\t\t\t\t(')\\s*\n\t\t\t\t\t\t((\\()\\s*(\\)))\n\t\t\t\t\t", |
| 139 |
"name": "constant.other.empty-list.schem" |
| 140 |
}, |
| 141 |
{ |
| 142 |
"begin": "(')\\s*", |
| 143 |
"beginCaptures": { |
| 144 |
"1": { |
| 145 |
"name": "punctuation.section.quoted.scheme" |
| 146 |
} |
| 147 |
}, |
| 148 |
"comment": "quoted double-quoted string or s-expression", |
| 149 |
"end": "(?=[\\s()])|(?<=\\n)", |
| 150 |
"name": "string.other.quoted-object.scheme", |
| 151 |
"patterns": [ |
| 152 |
{ |
| 153 |
"include": "#quoted" |
| 154 |
} |
| 155 |
] |
| 156 |
} |
| 157 |
] |
| 158 |
}, |
| 159 |
"quote-sexp": { |
| 160 |
"begin": "(?<=\\()\\s*(quote)\\s+", |
| 161 |
"beginCaptures": { |
| 162 |
"1": { |
| 163 |
"name": "keyword.control.quote.scheme" |
| 164 |
} |
| 165 |
}, |
| 166 |
"comment": "\n\t\t\t\tSomething quoted with (quote «thing»). In this case «thing»\n\t\t\t\twill not be evaluated, so we are considering it a string.\n\t\t\t", |
| 167 |
"contentName": "string.other.quote.scheme", |
| 168 |
"end": "(?=[\\s)])|(?<=\\n)", |
| 169 |
"patterns": [ |
| 170 |
{ |
| 171 |
"include": "#quoted" |
| 172 |
} |
| 173 |
] |
| 174 |
}, |
| 175 |
"quoted": { |
| 176 |
"patterns": [ |
| 177 |
{ |
| 178 |
"include": "#string" |
| 179 |
}, |
| 180 |
{ |
| 181 |
"begin": "(\\()", |
| 182 |
"beginCaptures": { |
| 183 |
"1": { |
| 184 |
"name": "punctuation.section.expression.begin.scheme" |
| 185 |
} |
| 186 |
}, |
| 187 |
"end": "(\\))", |
| 188 |
"endCaptures": { |
| 189 |
"1": { |
| 190 |
"name": "punctuation.section.expression.end.scheme" |
| 191 |
} |
| 192 |
}, |
| 193 |
"name": "meta.expression.scheme", |
| 194 |
"patterns": [ |
| 195 |
{ |
| 196 |
"include": "#quoted" |
| 197 |
} |
| 198 |
] |
| 199 |
}, |
| 200 |
{ |
| 201 |
"include": "#quote" |
| 202 |
}, |
| 203 |
{ |
| 204 |
"include": "#illegal" |
| 205 |
} |
| 206 |
] |
| 207 |
}, |
| 208 |
"sexp": { |
| 209 |
"begin": "(\\()", |
| 210 |
"beginCaptures": { |
| 211 |
"1": { |
| 212 |
"name": "punctuation.section.expression.begin.scheme" |
| 213 |
} |
| 214 |
}, |
| 215 |
"end": "(\\))(\\n)?", |
| 216 |
"endCaptures": { |
| 217 |
"1": { |
| 218 |
"name": "punctuation.section.expression.end.scheme" |
| 219 |
}, |
| 220 |
"2": { |
| 221 |
"name": "meta.after-expression.scheme" |
| 222 |
} |
| 223 |
}, |
| 224 |
"name": "meta.expression.scheme", |
| 225 |
"patterns": [ |
| 226 |
{ |
| 227 |
"include": "#comment" |
| 228 |
}, |
| 229 |
{ |
| 230 |
"begin": "(?x)\n\t\t\t\t\t\t(?<=\\() # preceded by (\n\t\t\t\t\t\t(define)\\s+ # define\n\t\t\t\t\t\t(\\() # list of parameters\n\t\t\t\t\t\t ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)\n\t\t\t\t\t\t ((\\s+\n\t\t\t\t\t\t ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])\n\t\t\t\t\t\t )*\n\t\t\t\t\t\t )\\s*\n\t\t\t\t\t\t(\\))\n\t\t\t\t\t", |
| 231 |
"captures": { |
| 232 |
"1": { |
| 233 |
"name": "keyword.control.scheme" |
| 234 |
}, |
| 235 |
"2": { |
| 236 |
"name": "punctuation.definition.function.scheme" |
| 237 |
}, |
| 238 |
"3": { |
| 239 |
"name": "entity.name.function.scheme" |
| 240 |
}, |
| 241 |
"4": { |
| 242 |
"name": "variable.parameter.function.scheme" |
| 243 |
}, |
| 244 |
"7": { |
| 245 |
"name": "punctuation.definition.function.scheme" |
| 246 |
} |
| 247 |
}, |
| 248 |
"end": "(?=\\))", |
| 249 |
"name": "meta.declaration.procedure.scheme", |
| 250 |
"patterns": [ |
| 251 |
{ |
| 252 |
"include": "#comment" |
| 253 |
}, |
| 254 |
{ |
| 255 |
"include": "#sexp" |
| 256 |
}, |
| 257 |
{ |
| 258 |
"include": "#illegal" |
| 259 |
} |
| 260 |
] |
| 261 |
}, |
| 262 |
{ |
| 263 |
"begin": "(?x)\n\t\t\t\t\t\t(?<=\\() # preceded by (\n\t\t\t\t\t\t(lambda)\\s+\n\t\t\t\t\t\t(\\() # opening paren\n\t\t\t\t\t\t((?:\n\t\t\t\t\t\t ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])\n\t\t\t\t\t\t \\s+\n\t\t\t\t\t\t)*(?:\n\t\t\t\t\t\t ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])\n\t\t\t\t\t\t)?)\n\t\t\t\t\t\t(\\)) # closing paren\n\t\t\t\t\t", |
| 264 |
"captures": { |
| 265 |
"1": { |
| 266 |
"name": "keyword.control.scheme" |
| 267 |
}, |
| 268 |
"2": { |
| 269 |
"name": "punctuation.definition.variable.scheme" |
| 270 |
}, |
| 271 |
"3": { |
| 272 |
"name": "variable.parameter.scheme" |
| 273 |
}, |
| 274 |
"6": { |
| 275 |
"name": "punctuation.definition.variable.scheme" |
| 276 |
} |
| 277 |
}, |
| 278 |
"comment": "\n\t\t\t\t\t\tNot sure this one is quite correct. That \\s* is\n\t\t\t\t\t\tparticularly troubling\n\t\t\t\t\t", |
| 279 |
"end": "(?=\\))", |
| 280 |
"name": "meta.declaration.procedure.scheme", |
| 281 |
"patterns": [ |
| 282 |
{ |
| 283 |
"include": "#comment" |
| 284 |
}, |
| 285 |
{ |
| 286 |
"include": "#sexp" |
| 287 |
}, |
| 288 |
{ |
| 289 |
"include": "#illegal" |
| 290 |
} |
| 291 |
] |
| 292 |
}, |
| 293 |
{ |
| 294 |
"begin": "(?<=\\()(define)\\s([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)\\s*.*?", |
| 295 |
"captures": { |
| 296 |
"1": { |
| 297 |
"name": "keyword.control.scheme" |
| 298 |
}, |
| 299 |
"2": { |
| 300 |
"name": "variable.other.scheme" |
| 301 |
} |
| 302 |
}, |
| 303 |
"end": "(?=\\))", |
| 304 |
"name": "meta.declaration.variable.scheme", |
| 305 |
"patterns": [ |
| 306 |
{ |
| 307 |
"include": "#comment" |
| 308 |
}, |
| 309 |
{ |
| 310 |
"include": "#sexp" |
| 311 |
}, |
| 312 |
{ |
| 313 |
"include": "#illegal" |
| 314 |
} |
| 315 |
] |
| 316 |
}, |
| 317 |
{ |
| 318 |
"include": "#quote-sexp" |
| 319 |
}, |
| 320 |
{ |
| 321 |
"include": "#quote" |
| 322 |
}, |
| 323 |
{ |
| 324 |
"include": "#language-functions" |
| 325 |
}, |
| 326 |
{ |
| 327 |
"include": "#string" |
| 328 |
}, |
| 329 |
{ |
| 330 |
"include": "#constants" |
| 331 |
}, |
| 332 |
{ |
| 333 |
"match": "(?<=[\\(\\s])(#\\\\)(space|newline|tab)(?=[\\s\\)])", |
| 334 |
"name": "constant.character.named.scheme" |
| 335 |
}, |
| 336 |
{ |
| 337 |
"match": "(?<=[\\(\\s])(#\\\\)x[0-9A-F]{2,4}(?=[\\s\\)])", |
| 338 |
"name": "constant.character.hex-literal.scheme" |
| 339 |
}, |
| 340 |
{ |
| 341 |
"match": "(?<=[\\(\\s])(#\\\\).(?=[\\s\\)])", |
| 342 |
"name": "constant.character.escape.scheme" |
| 343 |
}, |
| 344 |
{ |
| 345 |
"comment": "\n\t\t\t\t\t\tthe . in (a . b) which conses together two elements\n\t\t\t\t\t\ta and b. (a b c) == (a . (b . (c . nil)))\n\t\t\t\t\t", |
| 346 |
"match": "(?<=[ ()])\\.(?=[ ()])", |
| 347 |
"name": "punctuation.separator.cons.scheme" |
| 348 |
}, |
| 349 |
{ |
| 350 |
"include": "#sexp" |
| 351 |
}, |
| 352 |
{ |
| 353 |
"include": "#illegal" |
| 354 |
} |
| 355 |
] |
| 356 |
}, |
| 357 |
"string": { |
| 358 |
"begin": "(\")", |
| 359 |
"beginCaptures": { |
| 360 |
"1": { |
| 361 |
"name": "punctuation.definition.string.begin.scheme" |
| 362 |
} |
| 363 |
}, |
| 364 |
"end": "(\")", |
| 365 |
"endCaptures": { |
| 366 |
"1": { |
| 367 |
"name": "punctuation.definition.string.end.scheme" |
| 368 |
} |
| 369 |
}, |
| 370 |
"name": "string.quoted.double.scheme", |
| 371 |
"patterns": [ |
| 372 |
{ |
| 373 |
"match": "\\\\.", |
| 374 |
"name": "constant.character.escape.scheme" |
| 375 |
} |
| 376 |
] |
| 377 |
} |
| 378 |
}, |
| 379 |
"scopeName": "source.scheme", |
| 380 |
"uuid": "3EC2CFD0-909C-4692-AC29-1A60ADBC161E" |
| 381 |
} |
| 382 |
|