{ "name": "Scheme", "scopeName": "source.scheme", "patterns": [ { "include": "#comment" }, { "include": "#sexp" }, { "include": "#string" }, { "include": "#language-functions" }, { "include": "#quote" }, { "include": "#illegal" } ], "repository": { "comment": { "begin": "(^[ \\t]+)?(?=;)", "end": "(?!\\G)", "patterns": [ { "name": "comment.line.semicolon.scheme", "begin": ";", "end": "\\n", "beginCaptures": { "0": { "name": "punctuation.definition.comment.scheme" } } } ], "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.scheme" } } }, "constants": { "patterns": [ { "name": "constant.language.boolean.scheme", "match": "#[t|f]" }, { "name": "constant.numeric.scheme", "match": "(?\u003c=[\\(\\s])((#e|#i)?[0-9]+(\\.[0-9]+)?|(#x)[0-9a-fA-F]+|(#o)[0-7]+|(#b)[01]+)(?=[\\s;()'\",\\[\\]])" } ] }, "illegal": { "name": "invalid.illegal.parenthesis.scheme", "match": "[()]" }, "language-functions": { "patterns": [ { "name": "keyword.control.scheme", "match": "(?x)\n\t\t\t\t\t\t(?\u003c=(\\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|\\())" }, { "name": "support.function.boolean-test.scheme", "match": "(?x)\n\t\t\t\t\t\t(?\u003c=(\\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)?(?:=|\u003c=?|\u003e=?)|\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" }, { "name": "support.function.convert-type.scheme", "match": "(?x)\n\t\t\t\t\t\t(?\u003c=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( char-\u003einteger|exact-\u003einexact|inexact-\u003eexact|\n\t\t\t\t\t\t integer-\u003echar|symbol-\u003estring|list-\u003evector|\n\t\t\t\t\t\t list-\u003estring|identifier-\u003esymbol|vector-\u003elist|\n\t\t\t\t\t\t string-\u003elist|string-\u003enumber|string-\u003esymbol|\n\t\t\t\t\t\t number-\u003estring\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" }, { "name": "support.function.with-side-effects.scheme", "match": "(?x)\n\t\t\t\t\t\t(?\u003c=(\\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" }, { "name": "keyword.operator.arithmetic.scheme", "match": "(?x)\n\t\t\t\t\t\t(?\u003c=(\\s|\\()) # preceded by space or (\n\t\t\t\t\t\t( \u003e=?|\u003c=?|=|[*/+-])\n\t\t\t\t\t\t(?=(\\s|\\()) # followed by space or (\n\t\t\t\t\t\t" }, { "name": "support.function.general.scheme", "match": "(?x)\n\t\t\t\t\t\t(?\u003c=(\\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|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" } ] }, "quote": { "patterns": [ { "name": "constant.other.symbol.scheme", "match": "(?x)\n\t\t\t\t\t\t(')\\s*\n\t\t\t\t\t\t([[:alnum:]][[:alnum:]!$%\u0026*+-./:\u003c=\u003e?@^_~]*)\n\t\t\t\t\t", "captures": { "1": { "name": "punctuation.section.quoted.symbol.scheme" } } }, { "name": "constant.other.empty-list.schem", "match": "(?x)\n\t\t\t\t\t\t(')\\s*\n\t\t\t\t\t\t((\\()\\s*(\\)))\n\t\t\t\t\t", "captures": { "1": { "name": "punctuation.section.quoted.empty-list.scheme" }, "2": { "name": "meta.expression.scheme" }, "3": { "name": "punctuation.section.expression.begin.scheme" }, "4": { "name": "punctuation.section.expression.end.scheme" } } }, { "name": "string.other.quoted-object.scheme", "begin": "(')\\s*", "end": "(?=[\\s()])|(?\u003c=\\n)", "patterns": [ { "include": "#quoted" } ], "beginCaptures": { "1": { "name": "punctuation.section.quoted.scheme" } } } ] }, "quote-sexp": { "contentName": "string.other.quote.scheme", "begin": "(?\u003c=\\()\\s*(quote)\\b\\s*", "end": "(?=[\\s)])|(?\u003c=\\n)", "patterns": [ { "include": "#quoted" } ], "beginCaptures": { "1": { "name": "keyword.control.quote.scheme" } } }, "quoted": { "patterns": [ { "include": "#string" }, { "name": "meta.expression.scheme", "begin": "(\\()", "end": "(\\))", "patterns": [ { "include": "#quoted" } ], "beginCaptures": { "1": { "name": "punctuation.section.expression.begin.scheme" } }, "endCaptures": { "1": { "name": "punctuation.section.expression.end.scheme" } } }, { "include": "#quote" }, { "include": "#illegal" } ] }, "sexp": { "name": "meta.expression.scheme", "begin": "(\\()", "end": "(\\))(\\n)?", "patterns": [ { "include": "#comment" }, { "name": "meta.declaration.procedure.scheme", "begin": "(?x)\n\t\t\t\t\t\t(?\u003c=\\() # 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:]!$%\u0026*+-./:\u003c=\u003e?@^_~]*)\n\t\t\t\t\t\t ((\\s+\n\t\t\t\t\t\t ([[:alnum:]][[:alnum:]!$%\u0026*+-./:\u003c=\u003e?@^_~]*|[._])\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", "end": "(?=\\))", "patterns": [ { "include": "#comment" }, { "include": "#sexp" }, { "include": "#illegal" } ], "captures": { "1": { "name": "keyword.control.scheme" }, "2": { "name": "punctuation.definition.function.scheme" }, "3": { "name": "entity.name.function.scheme" }, "4": { "name": "variable.parameter.function.scheme" }, "7": { "name": "punctuation.definition.function.scheme" } } }, { "name": "meta.declaration.procedure.scheme", "begin": "(?x)\n\t\t\t\t\t\t(?\u003c=\\() # 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:]!$%\u0026*+-./:\u003c=\u003e?@^_~]*|[._])\n\t\t\t\t\t\t \\s+\n\t\t\t\t\t\t)*(?:\n\t\t\t\t\t\t ([[:alnum:]][[:alnum:]!$%\u0026*+-./:\u003c=\u003e?@^_~]*|[._])\n\t\t\t\t\t\t)?)\n\t\t\t\t\t\t(\\)) # closing paren\n\t\t\t\t\t", "end": "(?=\\))", "patterns": [ { "include": "#comment" }, { "include": "#sexp" }, { "include": "#illegal" } ], "captures": { "1": { "name": "keyword.control.scheme" }, "2": { "name": "punctuation.definition.variable.scheme" }, "3": { "name": "variable.parameter.scheme" }, "6": { "name": "punctuation.definition.variable.scheme" } } }, { "name": "meta.declaration.variable.scheme", "begin": "(?\u003c=\\()(define)\\s([[:alnum:]][[:alnum:]!$%\u0026*+-./:\u003c=\u003e?@^_~]*)\\s*.*?", "end": "(?=\\))", "patterns": [ { "include": "#comment" }, { "include": "#sexp" }, { "include": "#illegal" } ], "captures": { "1": { "name": "keyword.control.scheme" }, "2": { "name": "variable.other.scheme" } } }, { "include": "#quote-sexp" }, { "include": "#quote" }, { "include": "#language-functions" }, { "include": "#string" }, { "include": "#constants" }, { "name": "constant.character.named.scheme", "match": "(?\u003c=[\\(\\s])(#\\\\)(space|newline|tab)(?=[\\s\\)])" }, { "name": "constant.character.hex-literal.scheme", "match": "(?\u003c=[\\(\\s])(#\\\\)x[0-9A-F]{2,4}(?=[\\s\\)])" }, { "name": "constant.character.escape.scheme", "match": "(?\u003c=[\\(\\s])(#\\\\).(?=[\\s\\)])" }, { "name": "punctuation.separator.cons.scheme", "match": "(?\u003c=[ ()])\\.(?=[ ()])" }, { "include": "#sexp" }, { "include": "#illegal" } ], "beginCaptures": { "1": { "name": "punctuation.section.expression.begin.scheme" } }, "endCaptures": { "1": { "name": "punctuation.section.expression.end.scheme" }, "2": { "name": "meta.after-expression.scheme" } } }, "string": { "name": "string.quoted.double.scheme", "begin": "(\")", "end": "(\")", "patterns": [ { "name": "constant.character.escape.scheme", "match": "\\\\." } ], "beginCaptures": { "1": { "name": "punctuation.definition.string.begin.scheme" } }, "endCaptures": { "1": { "name": "punctuation.definition.string.end.scheme" } } } } }