Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { scopeName = 'source.scheme';
- comment = '
- The foldings do not currently work the way I want them to. This
- may be a limitation of the way they are applied rather than the
- regexps in use. Nonetheless, the foldings will end on the last
- identically indented blank line following an s-expression. Not
- ideal perhaps, but it works. Also, the #illegal pattern never
- matches an unpaired ( as being illegal. Why?! -- Rob Rix
- This grammar still needs a bit of work, but I have tried to separate
- out disparate parts a bit. -- Jacob Rus
- ';
- fileTypes = ( 'scm', 'sch' );
- foldingStartMarker = '(?x)^ [ \t]* \(
- (?<par>
- ( [^()\n]++ | \( \g<par> \)? )*+
- )
- $';
- foldingStopMarker = '(?x)^ [ \t]*
- (?<par>
- ( [^()\n]++ | \( \g<par> \) )*+
- )
- ( \) [ \t]*+ ) ++
- $';
- patterns = (
- { include = '#comment'; },
- { include = '#sexp'; },
- { include = '#string'; },
- { include = '#language-functions'; },
- { include = '#quote'; },
- { include = '#illegal'; },
- );
- repository =
- { comment =
- { name = 'comment.line.semicolon.scheme';
- match = '(;).*$\n?';
- captures = { 1 = { name = 'punctuation.definition.comment.semicolon.scheme'; }; };
- };
- illegal =
- { name = 'invalid.illegal.parenthesis.scheme';
- match = '[()]';
- };
- string = {
- name = 'string.quoted.double.scheme';
- begin = '(")';
- end = '(")';
- beginCaptures = { 1 = { name = 'punctuation.definition.string.begin.scheme'; }; };
- endCaptures = { 1 = { name = 'punctuation.definition.string.end.scheme'; }; };
- patterns = (
- { name = 'constant.character.escape.scheme';
- match = '\\.';
- }
- );
- };
- 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';
- comment = '
- These functions run a test, and return a boolean
- answer.
- ';
- match = '(?x)
- (?<=(\s|\()) # preceded by space or (
- ( char-alphabetic|char-lower-case|char-numeric|
- char-ready|char-upper-case|char-whitespace|
- (?:char|string)(?:-ci)?(?:=|<=?|>=?)|
- atom|boolean|bound-identifier=|char|complex|
- identifier|integer|symbol|free-identifier=|inexact|
- eof-object|exact|list|(?:input|output)-port|pair|
- real|rational|zero|vector|negative|odd|null|string|
- eq|equal|eqv|even|number|positive|procedure
- )
- (\?) # name ends with ? sign
- (?=(\s|\()) # followed by space or (
- ';
- },
- { name = 'support.function.convert-type.scheme';
- comment = '
- These functions change one type into another.
- ';
- match = '(?x)
- (?<=(\s|\()) # preceded by space or (
- ( char->integer|exact->inexact|inexact->exact|
- integer->char|symbol->string|list->vector|
- list->string|identifier->symbol|vector->list|
- string->list|string->number|string->symbol|
- number->string
- )
- (?=(\s|\()) # followed by space or (
- ';
- },
- { name = 'support.function.with-side-effects.scheme';
- comment = '
- These functions are potentially dangerous because
- they have side-effects which could affect other
- parts of the program.
- ';
- match = '(?x)
- (?<=(\s|\()) # preceded by space or (
- ( set-(?:car|cdr)| # set car/cdr
- (?:vector|string)-(?:fill|set) # fill/set string/vector
- )
- (!) # name ends with ! sign
- (?=(\s|\()) # followed by space or (
- ';
- },
- { name = 'support.function.arithmetic-operators.scheme';
- comment = '
- +, -, *, /, =, >, etc.
- ';
- match = '(?x)
- (?<=(\s|\()) # preceded by space or (
- ( >=?|<=?|=|[*/+-])
- (?=(\s|\()) # followed by space or (
- ';
- },
- { name = 'support.function.general.scheme';
- match = '(?x)
- (?<=(\s|\()) # preceded by space or (
- ( append|apply|approximate|
- call-with-current-continuation|call/cc|catch|
- construct-identifier|define-syntax|display|foo|
- for-each|force|cd|gen-counter|gen-loser|
- generate-identifier|last-pair|length|let-syntax|
- letrec-syntax|list|list-ref|list-tail|load|log|
- macro|magnitude|map|map-streams|max|member|memq|
- memv|min|newline|nil|not|peek-char|rationalize|
- read|read-char|return|reverse|sequence|substring|
- syntax|syntax-rules|transcript-off|transcript-on|
- truncate|unwrap-syntax|values-list|write|write-char|
- # cons, car, cdr, etc
- cons|c(a|d){1,4}r|
- # unary math operators
- abs|acos|angle|asin|assoc|assq|assv|atan|ceiling|
- cos|floor|round|sin|sqrt|tan|
- (?:real|imag)-part|numerator|denominator
- # other math operators
- modulo|exp|expt|remainder|quotient|lcm|
- # ports / files
- call-with-(?:input|output)-file|
- (?:close|current)-(?:input|output)-port|
- with-(?:input|output)-from-file|
- open-(?:input|output)-file|
- # char-«foo»
- char-(?:downcase|upcase|ready)|
- # make-«foo»
- make-(?:polar|promise|rectangular|string|vector)
- # string-«foo», vector-«foo»
- string(?:-(?:append|copy|length|ref))?|
- vector(?:-length|-ref)
- )
- (?=(\s|\()) # followed by space or (
- ';
- },
- );
- };
- constants = {
- patterns = (
- { name = 'constant.language.boolean.scheme';
- match = '#[t|f]';
- },
- { name = 'constant.other.symbol.scheme';
- match = "(')[[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*";
- captures = { 1 = { name = 'punctuation.definition.symbol.scheme'; }; };
- },
- { 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]+';
- },
- );
- };
- quote = {
- comment = '
- We need to be able to quote any kind of item, which creates
- a tiny bit of complexity in our grammar. It is hopefully
- not overwhelming complexity
- ';
- patterns = (
- { contentName = 'string.other.quoted-object.scheme';
- comment = 'quoted double-quoted string';
- begin = '('')\s*(?=")';
- end = '(?<=")';
- beginCaptures = {
- 1 = { name = 'punctuation.section.quoted-code.scheme'; };
- };
- patterns = (
- { include = '#quoted'; },
- );
- },
- { contentName = 'string.other.quoted-object.scheme';
- comment = 'quoted s-expression';
- begin = '('')\s*(?=\()';
- end = '(?<=\))';
- beginCaptures = {
- 1 = { name = 'punctuation.section.quoted-code.scheme'; };
- };
- patterns = (
- { include = '#quoted'; },
- );
- },
- { contentName = 'string.other.quoted-object.scheme';
- comment = 'quoted anything else';
- begin = '('')\s*(?=[^\s])';
- end = '(?<=\s)';
- beginCaptures = {
- 1 = { name = 'punctuation.section.quoted-code.scheme'; };
- };
- patterns = (
- { include = '#quoted'; },
- );
- },
- { begin = '(?<=\([ ]?)(quote)\b\s*';
- end = '(?=\)|[ ])';
- beginCaptures = {
- 1 = { name = 'keyword.control.quote.scheme'; };
- };
- patterns = (
- { name = 'string.other.quoted-code.scheme';
- comment = 'quoted s-expression';
- begin = '(?=\()';
- end = '(?<=\))';
- patterns = (
- { include = '#quoted'; },
- );
- },
- { name = 'string.other.quoted-code.scheme';
- comment = 'quoted string';
- begin = '(?=")';
- end = '(?<=")';
- patterns = (
- { include = '#quoted'; },
- );
- },
- { name = 'string.other.quoted-code.scheme';
- comment = 'quoted anything else';
- begin = '(?=[^\s])';
- end = '(?<=\s)';
- patterns = (
- { include = '#quoted'; },
- );
- },
- );
- }
- );
- };
- quoted = {
- patterns = (
- { include = '#string'; },
- { name = 'meta.expression.scheme';
- begin = '(\()';
- end = '(\))(\n)?';
- beginCaptures = { 1 = { name = 'punctuation.section.expression.begin.scheme'; }; };
- endCaptures =
- { 1 = { name = 'punctuation.section.expression.end.scheme'; };
- 2 = { name = 'meta.after-expression.scheme'; };
- };
- patterns = (
- { include = '#quoted'; },
- );
- },
- { include = '#quote'; },
- { include = '#illegal'; },
- );
- };
- sexp =
- { name = 'meta.expression.scheme';
- begin = '(\()';
- end = '(\))(\n)?';
- beginCaptures = { 1 = { name = 'punctuation.section.expression.begin.scheme'; }; };
- endCaptures =
- { 1 = { name = 'punctuation.section.expression.end.scheme'; };
- 2 = { name = 'meta.after-expression.scheme'; };
- };
- patterns = (
- { include = '#comment'; },
- { name = 'meta.declaration.procedure.scheme';
- begin = '(?x)
- (?<=\() # preceded by (
- (define)\s+ # define
- \( # list of parameters
- ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)
- ((\s+
- ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])
- )*
- )\s*
- \)
- ';
- end = '(?=\))';
- captures =
- { 1 = { name = 'keyword.other.scheme'; };
- 2 = { name = 'entity.name.function.scheme'; };
- 3 = { name = 'variable.parameter.function.scheme'; };
- };
- patterns = (
- { include = '#comment'; },
- { include = '#sexp'; },
- { include = '#illegal'; },
- );
- },
- { name = 'meta.declaration.procedure.scheme';
- comment = '
- Not sure this one is quite correct. That \s* is
- particularly troubling
- ';
- begin = '(?x)
- (?<=\() # preceded by (
- (lambda)\s+
- (\() # opening paren
- ((?:
- ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._])
- \s*
- )*)
- (\)) # closing paren
- ';
- end = '(?=\))';
- captures =
- { 1 = { name = 'keyword.other.scheme'; };
- 2 = { name = 'variable.parameter.scheme'; };
- };
- patterns = (
- { include = '#comment'; },
- { include = '#sexp'; },
- { include = '#illegal'; },
- );
- },
- { name = 'meta.declaration.variable.scheme';
- begin = '(?<=\()(define)\s([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*)\s*.*?';
- end = '(?=\))';
- captures =
- { 1 = { name = 'keyword.other.scheme'; };
- 2 = { name = 'variable.language.scheme'; };
- };
- patterns = (
- { include = '#comment'; },
- { include = '#sexp'; },
- { include = '#illegal'; },
- );
- },
- { include = '#language-functions'; },
- { include = '#string'; },
- { include = '#constants'; },
- { name = 'constant.character.escape.scheme';
- match = '(?<=[\(\s])(#\\).';
- },
- { include = '#sexp'; },
- { include = '#illegal'; },
- );
- };
- };
- }
Add Comment
Please, Sign In to add comment