name: Scheme fileTypes:

scopeName: source.scheme repository:

illegal: 
  name: invalid.illegal.parenthesis.scheme
  match: "[()]"
quote-sexp: 
  begin: (?<=\()\s*(quote)\b\s*
  contentName: string.other.quote.scheme
  beginCaptures: 
    "1": 
      name: keyword.control.quote.scheme
  end: (?=[\s)])|(?<=\n)
  patterns: 
  - include: "#quoted"
  comment: "\n\
    \t\t\t\tSomething quoted with (quote \xC2\xABthing\xC2\xBB).  In this case \xC2\xABthing\xC2\xBB\n\
    \t\t\t\twill not be evaluated, so we are considering it a string.\n\
    \t\t\t"
quote: 
  patterns: 
  - name: constant.other.symbol.scheme
    captures: 
      "1": 
        name: punctuation.section.quoted.symbol.scheme
    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"
  - name: constant.other.empty-list.schem
    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
    match: "(?x)\n\
      \t\t\t\t\t\t(')\\s*\n\
      \t\t\t\t\t\t((\\()\\s*(\\)))\n\
      \t\t\t\t\t"
  - name: string.other.quoted-object.scheme
    begin: (')\s*
    beginCaptures: 
      "1": 
        name: punctuation.section.quoted.scheme
    end: (?=[\s()])|(?<=\n)
    patterns: 
    - include: "#quoted"
    comment: quoted double-quoted string or s-expression
  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"
language-functions: 
  patterns: 
  - name: keyword.control.scheme
    match: |-
      (?x)
                                                      (?<=(\s|\()) # preceded by space or ( 
                                                      ( do|or|and|else|quasiquote|begin|if|case|set!|
                                                        cond|let|unquote|define|let\*|unquote-splicing|delay|
                                                        letrec)
                                                      (?=(\s|\())
  - name: support.function.boolean-test.scheme
    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"
    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"
  - name: support.function.convert-type.scheme
    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"
    comment: "\n\
      \t\t\t\t\t\tThese functions change one type into another.\n\
      \t\t\t\t\t"
  - name: support.function.with-side-effects.scheme
    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"
    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"
  - name: support.function.arithmetic-operators.scheme
    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"
    comment: "\n\
      \t\t\t\t\t\t+, -, *, /, =, >, etc. \n\
      \t\t\t\t\t"
  - name: support.function.general.scheme
    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|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-\xC2\xABfoo\xC2\xBB\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-\xC2\xABfoo\xC2\xBB\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-\xC2\xABfoo\xC2\xBB, vector-\xC2\xABfoo\xC2\xBB\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"
quoted: 
  patterns: 
  - include: "#string"
  - name: meta.expression.scheme
    endCaptures: 
      "1": 
        name: punctuation.section.expression.end.scheme
    begin: (\()
    beginCaptures: 
      "1": 
        name: punctuation.section.expression.begin.scheme
    end: (\))
    patterns: 
    - include: "#quoted"
  - include: "#quote"
  - include: "#illegal"
constants: 
  patterns: 
  - name: constant.language.boolean.scheme
    match: "#[t|f]"
  - name: constant.numeric.scheme
    match: (?<=[\(\s])(#e|#i)?[0-9][0-9.]*
  - name: constant.numeric.scheme
    match: (?<=[\(\s])(#x)[0-9a-fA-F]+
  - name: constant.numeric.scheme
    match: (?<=[\(\s])(#o)[0-7]+
  - name: constant.numeric.scheme
    match: (?<=[\(\s])(#b)[01]+
comment: 
  name: comment.line.semicolon.scheme
  captures: 
    "1": 
      name: punctuation.definition.comment.semicolon.scheme
  match: (;).*$\n?
string: 
  name: string.quoted.double.scheme
  endCaptures: 
    "1": 
      name: punctuation.definition.string.end.scheme
  begin: (")
  beginCaptures: 
    "1": 
      name: punctuation.definition.string.begin.scheme
  end: (")
  patterns: 
  - name: constant.character.escape.scheme
    match: \\.
sexp: 
  name: meta.expression.scheme
  endCaptures: 
    "1": 
      name: punctuation.section.expression.end.scheme
    "2": 
      name: meta.after-expression.scheme
  begin: (\()
  beginCaptures: 
    "1": 
      name: punctuation.section.expression.begin.scheme
  end: (\))(\n)?
  patterns: 
  - include: "#comment"
  - name: meta.declaration.procedure.scheme
    captures: 
      "1": 
        name: keyword.control.scheme
      "2": 
        name: entity.name.function.scheme
      "3": 
        name: variable.parameter.function.scheme
    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"
    end: (?=\))
    patterns: 
    - include: "#comment"
    - include: "#sexp"
    - include: "#illegal"
  - name: meta.declaration.procedure.scheme
    captures: 
      "1": 
        name: keyword.control.scheme
      "2": 
        name: variable.parameter.scheme
    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(\\)) # closing paren\n\
      \t\t\t\t\t"
    end: (?=\))
    patterns: 
    - include: "#comment"
    - include: "#sexp"
    - include: "#illegal"
    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"
  - name: meta.declaration.variable.scheme
    captures: 
      "1": 
        name: keyword.control.scheme
      "2": 
        name: variable.other.scheme
    begin: (?<=\()(define)\s([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)\s*.*?
    end: (?=\))
    patterns: 
    - include: "#comment"
    - include: "#sexp"
    - include: "#illegal"
  - include: "#quote-sexp"
  - include: "#quote"
  - include: "#language-functions"
  - include: "#string"
  - include: "#constants"
  - name: constant.character.named.scheme
    match: (?<=[\(\s])(#\\)(space|newline|tab)(?=[\s\)])
  - name: constant.character.hex-literal.scheme
    match: (?<=[\(\s])(#\\)x[0-9A-F]{2,4}(?=[\s\)])
  - name: constant.character.escape.scheme
    match: (?<=[\(\s])(#\\).(?=[\s\)])
  - name: punctuation.separator.cons.scheme
    match: (?<=[ ()])\.(?=[ ()])
    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"
  - include: "#sexp"
  - include: "#illegal"

uuid: 3EC2CFD0-909C-4692-AC29-1A60ADBC161E foldingStartMarker: |-

(?x)^ [ \t]* \(
        (?<par>
          ( [^()\n]++ | \( \g<par> \)? )*+
        )
      $

patterns:

foldingStopMarker: |-

(?x)^ [ \t]*
        (?<par>
          ( [^()\n]++ | \( \g<par> \) )*+
        )
        ( \) [ \t]*+ ) ++
      $

keyEquivalent: ^~S 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"