From e4f6ccace9207c36a15b1f9df0093e9b5b48468a Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sun, 30 Aug 2020 15:08:38 +0200 Subject: [PATCH] Scheme: Added support for R7RS syntax (#2525) --- components/prism-scheme.js | 33 +- components/prism-scheme.min.js | 2 +- tests/languages/racket/function_feature.test | 8 - tests/languages/scheme/boolean_feature.test | 8 +- tests/languages/scheme/builtin_feature.test | 434 ++++++++++++++++-- tests/languages/scheme/comment_feature.test | 17 +- tests/languages/scheme/function_feature.test | 8 +- .../languages/scheme/identifier_feature.test | 7 + tests/languages/scheme/keyword_feature.test | 102 ++-- .../scheme/lambda_parameter_feature.test | 12 + 10 files changed, 523 insertions(+), 108 deletions(-) create mode 100644 tests/languages/scheme/identifier_feature.test diff --git a/components/prism-scheme.js b/components/prism-scheme.js index 9c7b60c0fc..176add2fcf 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -1,5 +1,10 @@ Prism.languages.scheme = { - 'comment': /;.*/, + // this supports "normal" single-line comments: + // ; comment + // and (potentially nested) multiline comments: + // #| comment #| nested |# still comment |# + // (only 1 level of nesting is supported) + 'comment': /;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, 'string': { pattern: /"(?:[^"\\]|\\.)*"/, greedy: true @@ -9,14 +14,14 @@ Prism.languages.scheme = { greedy: true }, 'character': { - pattern: /#\\(?:[ux][a-fA-F\d]+|[-a-zA-Z]+|\S)/, + pattern: /#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|\S)/, greedy: true, alias: 'string' }, 'lambda-parameter': [ // https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_6.html#SEC30 { - pattern: /(\(lambda\s+)[^()'\s]+/, + pattern: /(\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/, lookbehind: true }, { @@ -25,11 +30,16 @@ Prism.languages.scheme = { } ], 'keyword': { - pattern: /(\()(?:define(?:-library|-macro|-syntax|-values)?|defmacro|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s]|$)/, + pattern: /(\()(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|export|except|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\s]|$)/, lookbehind: true }, 'builtin': { - pattern: /(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\s]|$)/, + // all functions of the base library of R7RS plus some of built-ins of R5Rs + pattern: /(\()(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\s]|$)/, + lookbehind: true + }, + 'operator': { + pattern: /(\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/, lookbehind: true }, 'number': { @@ -52,16 +62,17 @@ Prism.languages.scheme = { lookbehind: true }, 'boolean': { - pattern: /(^|[\s()])#[ft](?=[()\s]|$)/, - lookbehind: true - }, - 'operator': { - pattern: /(\()(?:[-+*%\/]|[<>]=?|=>?)(?=[()\s]|$)/, + pattern: /(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/, lookbehind: true }, 'function': { - pattern: /(\()[^()'\s]+(?=[()\s]|$)/, + pattern: /(\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/, lookbehind: true }, + 'identifier': { + pattern: /(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/, + lookbehind: true, + greedy: true + }, 'punctuation': /[()']/ }; diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index 7176052c9d..db51b867a2 100644 --- a/components/prism-scheme.min.js +++ b/components/prism-scheme.min.js @@ -1 +1 @@ -Prism.languages.scheme={comment:/;.*/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()#'\s]+/,greedy:!0},character:{pattern:/#\\(?:[ux][a-fA-F\d]+|[-a-zA-Z]+|\S)/,greedy:!0,alias:"string"},"lambda-parameter":[{pattern:/(\(lambda\s+)[^()'\s]+/,lookbehind:!0},{pattern:/(\(lambda\s+\()[^()']+/,lookbehind:!0}],keyword:{pattern:/(\()(?:define(?:-library|-macro|-syntax|-values)?|defmacro|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s]|$)/,lookbehind:!0},builtin:{pattern:/(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\s]|$)/,lookbehind:!0},number:{pattern:/(^|[\s()])(?:(?:#d(?:#[ei])?|#[ei](?:#d)?)?[+-]?(?:(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)(?:[+-](?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)?|(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)|(?:#[box](?:#[ei])?|#[ei](?:#[box])?)[+-]?(?:[\da-fA-F]+(?:\/[\da-fA-F]+)?(?:[+-][\da-fA-F]+(?:\/[\da-fA-F]+)?i)?|[\da-fA-F]+(?:\/[\da-fA-F]+)?i))(?=[()\s]|$)/,lookbehind:!0},boolean:{pattern:/(^|[\s()])#[ft](?=[()\s]|$)/,lookbehind:!0},operator:{pattern:/(\()(?:[-+*%\/]|[<>]=?|=>?)(?=[()\s]|$)/,lookbehind:!0},function:{pattern:/(\()[^()'\s]+(?=[()\s]|$)/,lookbehind:!0},punctuation:/[()']/}; \ No newline at end of file +Prism.languages.scheme={comment:/;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()#'\s]+/,greedy:!0},character:{pattern:/#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|\S)/,greedy:!0,alias:"string"},"lambda-parameter":[{pattern:/(\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/,lookbehind:!0},{pattern:/(\(lambda\s+\()[^()']+/,lookbehind:!0}],keyword:{pattern:/(\()(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|export|except|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\s]|$)/,lookbehind:!0},builtin:{pattern:/(\()(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\s]|$)/,lookbehind:!0},operator:{pattern:/(\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/,lookbehind:!0},number:{pattern:/(^|[\s()])(?:(?:#d(?:#[ei])?|#[ei](?:#d)?)?[+-]?(?:(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)(?:[+-](?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)?|(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)|(?:#[box](?:#[ei])?|#[ei](?:#[box])?)[+-]?(?:[\da-fA-F]+(?:\/[\da-fA-F]+)?(?:[+-][\da-fA-F]+(?:\/[\da-fA-F]+)?i)?|[\da-fA-F]+(?:\/[\da-fA-F]+)?i))(?=[()\s]|$)/,lookbehind:!0},boolean:{pattern:/(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/,lookbehind:!0},function:{pattern:/(\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/,lookbehind:!0},identifier:{pattern:/(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/,lookbehind:!0,greedy:!0},punctuation:/[()']/}; \ No newline at end of file diff --git a/tests/languages/racket/function_feature.test b/tests/languages/racket/function_feature.test index 4911b747fb..9dd606246a 100644 --- a/tests/languages/racket/function_feature.test +++ b/tests/languages/racket/function_feature.test @@ -1,20 +1,16 @@ (fl= 1 2) (flmin 2 3) -(exact? 2) (inexact->exact 3) (!fact) (** 10) -(exact? (** (defined foo) [fl= 1 2] [flmin 2 3] -[exact? 2] [inexact->exact 3] [!fact] [** 10] -[exact? [** [defined foo] @@ -23,21 +19,17 @@ [ ["punctuation", "("], ["function", "fl="], ["number", "1"], ["number", "2"], ["punctuation", ")"], ["punctuation", "("], ["function", "flmin"], ["number", "2"], ["number", "3"], ["punctuation", ")"], - ["punctuation", "("], ["function", "exact?"], ["number", "2"], ["punctuation", ")"], ["punctuation", "("], ["function", "inexact->exact"], ["number", "3"], ["punctuation", ")"], ["punctuation", "("], ["function", "!fact"], ["punctuation", ")"], ["punctuation", "("], ["function", "**"], ["number", "10"], ["punctuation", ")"], - ["punctuation", "("], ["function", "exact?"], ["punctuation", "("], ["function", "**"], ["punctuation", "("], ["function", "defined"], " foo", ["punctuation", ")"], ["punctuation", "["], ["function", "fl="], ["number", "1"], ["number", "2"], ["punctuation", "]"], ["punctuation", "["], ["function", "flmin"], ["number", "2"], ["number", "3"], ["punctuation", "]"], - ["punctuation", "["], ["function", "exact?"], ["number", "2"], ["punctuation", "]"], ["punctuation", "["], ["function", "inexact->exact"], ["number", "3"], ["punctuation", "]"], ["punctuation", "["], ["function", "!fact"], ["punctuation", "]"], ["punctuation", "["], ["function", "**"], ["number", "10"], ["punctuation", "]"], - ["punctuation", "["], ["function", "exact?"], ["punctuation", "["], ["function", "**"], ["punctuation", "["], ["function", "defined"], " foo", ["punctuation", "]"] ] diff --git a/tests/languages/scheme/boolean_feature.test b/tests/languages/scheme/boolean_feature.test index af218655a4..53753fc7a1 100644 --- a/tests/languages/scheme/boolean_feature.test +++ b/tests/languages/scheme/boolean_feature.test @@ -1,17 +1,15 @@ #t #f - -; not a boolean #true +#false ---------------------------------------------------- [ ["boolean", "#t"], ["boolean", "#f"], - - ["comment", "; not a boolean"], - "\r\n#true" + ["boolean", "#true"], + ["boolean", "#false"] ] ---------------------------------------------------- diff --git a/tests/languages/scheme/builtin_feature.test b/tests/languages/scheme/builtin_feature.test index ab03c8e209..1a3706f4b4 100644 --- a/tests/languages/scheme/builtin_feature.test +++ b/tests/languages/scheme/builtin_feature.test @@ -1,51 +1,397 @@ -(cons) -(car) -(cdr) -(null?) -(pair?) -(boolean?) -(eof-object?) -(char?) -(procedure?) -(number?) -(port?) -(string?) -(vector?) -(symbol?) -(bytevector?) -(list) -(call-with-current-continuation) -(call/cc) -(append) -(abs) -(apply) -(eval) +(abs +(and +(append +(apply +(assoc +(assq +(assv +(binary-port? +(boolean=? +(boolean? +(bytevector +(bytevector-append +(bytevector-copy +(bytevector-copy! +(bytevector-length +(bytevector-u8-ref +(bytevector-u8-set! +(bytevector? +(caar +(cadr +(call-with-current-continuation +(call-with-port +(call-with-values +(call/cc +(car +(cdar +(cddr +(cdr +(ceiling +(char->integer +(char-ready? +(char<=? +(char=? +(char>? +(char? +(close-input-port +(close-output-port +(close-port +(complex? +(cons +(current-error-port +(current-input-port +(current-output-port +(denominator +(dynamic-wind +(eof-object +(eof-object? +(eq? +(equal? +(eqv? +(error +(error-object-irritants +(error-object-message +(error-object? +(eval +(even? +(exact +(exact-integer-sqrt +(exact-integer? +(exact? +(expt +(features +(file-error? +(floor +(floor-quotient +(floor-remainder +(floor/ +(flush-output-port +(for-each +(gcd +(get-output-bytevector +(get-output-string +(inexact +(inexact? +(input-port-open? +(input-port? +(integer->char +(integer? +(lcm +(length +(list +(list->string +(list->vector +(list-copy +(list-ref +(list-set! +(list-tail +(list? +(make-bytevector +(make-list +(make-parameter +(make-string +(make-vector +(map +(max +(member +(memq +(memv +(min +(modulo +(negative? +(newline +(not +(null? +(number->string +(number? +(numerator +(odd? +(open-input-bytevector +(open-input-string +(open-output-bytevector +(open-output-string +(or +(output-port-open? +(output-port? +(pair? +(peek-char +(peek-u8 +(port? +(positive? +(procedure? +(quotient +(raise +(raise-continuable +(rational? +(rationalize +(read-bytevector +(read-bytevector! +(read-char +(read-error? +(read-line +(read-string +(read-u8 +(real? +(remainder +(reverse +(round +(set-car! +(set-cdr! +(square +(string +(string->list +(string->number +(string->symbol +(string->utf8 +(string->vector +(string-append +(string-copy +(string-copy! +(string-fill! +(string-for-each +(string-length +(string-map +(string-ref +(string-set! +(string<=? +(string=? +(string>? +(string? +(substring +(symbol->string +(symbol=? +(symbol? +(syntax-error +(textual-port? +(truncate +(truncate-quotient +(truncate-remainder +(truncate/ +(u8-ready? +(utf8->string +(values +(vector +(vector->list +(vector->string +(vector-append +(vector-copy +(vector-copy! +(vector-fill! +(vector-for-each +(vector-length +(vector-map +(vector-ref +(vector-set! +(vector? +(with-exception-handler +(write-bytevector +(write-char +(write-string +(write-u8 +(zero? ---------------------------------------------------- [ - ["punctuation", "("], ["builtin", "cons"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "car"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "cdr"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "null?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "pair?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "boolean?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "eof-object?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "char?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "procedure?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "number?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "port?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "string?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "vector?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "symbol?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "bytevector?"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "list"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "call-with-current-continuation"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "call/cc"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "append"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "abs"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "apply"], ["punctuation", ")"], - ["punctuation", "("], ["builtin", "eval"], ["punctuation", ")"] + ["punctuation", "("], ["builtin", "abs"], + ["punctuation", "("], ["builtin", "and"], + ["punctuation", "("], ["builtin", "append"], + ["punctuation", "("], ["builtin", "apply"], + ["punctuation", "("], ["builtin", "assoc"], + ["punctuation", "("], ["builtin", "assq"], + ["punctuation", "("], ["builtin", "assv"], + ["punctuation", "("], ["builtin", "binary-port?"], + ["punctuation", "("], ["builtin", "boolean=?"], + ["punctuation", "("], ["builtin", "boolean?"], + ["punctuation", "("], ["builtin", "bytevector"], + ["punctuation", "("], ["builtin", "bytevector-append"], + ["punctuation", "("], ["builtin", "bytevector-copy"], + ["punctuation", "("], ["builtin", "bytevector-copy!"], + ["punctuation", "("], ["builtin", "bytevector-length"], + ["punctuation", "("], ["builtin", "bytevector-u8-ref"], + ["punctuation", "("], ["builtin", "bytevector-u8-set!"], + ["punctuation", "("], ["builtin", "bytevector?"], + ["punctuation", "("], ["builtin", "caar"], + ["punctuation", "("], ["builtin", "cadr"], + ["punctuation", "("], ["builtin", "call-with-current-continuation"], + ["punctuation", "("], ["builtin", "call-with-port"], + ["punctuation", "("], ["builtin", "call-with-values"], + ["punctuation", "("], ["builtin", "call/cc"], + ["punctuation", "("], ["builtin", "car"], + ["punctuation", "("], ["builtin", "cdar"], + ["punctuation", "("], ["builtin", "cddr"], + ["punctuation", "("], ["builtin", "cdr"], + ["punctuation", "("], ["builtin", "ceiling"], + ["punctuation", "("], ["builtin", "char->integer"], + ["punctuation", "("], ["builtin", "char-ready?"], + ["punctuation", "("], ["builtin", "char<=?"], + ["punctuation", "("], ["builtin", "char=?"], + ["punctuation", "("], ["builtin", "char>?"], + ["punctuation", "("], ["builtin", "char?"], + ["punctuation", "("], ["builtin", "close-input-port"], + ["punctuation", "("], ["builtin", "close-output-port"], + ["punctuation", "("], ["builtin", "close-port"], + ["punctuation", "("], ["builtin", "complex?"], + ["punctuation", "("], ["builtin", "cons"], + ["punctuation", "("], ["builtin", "current-error-port"], + ["punctuation", "("], ["builtin", "current-input-port"], + ["punctuation", "("], ["builtin", "current-output-port"], + ["punctuation", "("], ["builtin", "denominator"], + ["punctuation", "("], ["builtin", "dynamic-wind"], + ["punctuation", "("], ["builtin", "eof-object"], + ["punctuation", "("], ["builtin", "eof-object?"], + ["punctuation", "("], ["builtin", "eq?"], + ["punctuation", "("], ["builtin", "equal?"], + ["punctuation", "("], ["builtin", "eqv?"], + ["punctuation", "("], ["builtin", "error"], + ["punctuation", "("], ["builtin", "error-object-irritants"], + ["punctuation", "("], ["builtin", "error-object-message"], + ["punctuation", "("], ["builtin", "error-object?"], + ["punctuation", "("], ["builtin", "eval"], + ["punctuation", "("], ["builtin", "even?"], + ["punctuation", "("], ["builtin", "exact"], + ["punctuation", "("], ["builtin", "exact-integer-sqrt"], + ["punctuation", "("], ["builtin", "exact-integer?"], + ["punctuation", "("], ["builtin", "exact?"], + ["punctuation", "("], ["builtin", "expt"], + ["punctuation", "("], ["builtin", "features"], + ["punctuation", "("], ["builtin", "file-error?"], + ["punctuation", "("], ["builtin", "floor"], + ["punctuation", "("], ["builtin", "floor-quotient"], + ["punctuation", "("], ["builtin", "floor-remainder"], + ["punctuation", "("], ["builtin", "floor/"], + ["punctuation", "("], ["builtin", "flush-output-port"], + ["punctuation", "("], ["builtin", "for-each"], + ["punctuation", "("], ["builtin", "gcd"], + ["punctuation", "("], ["builtin", "get-output-bytevector"], + ["punctuation", "("], ["builtin", "get-output-string"], + ["punctuation", "("], ["builtin", "inexact"], + ["punctuation", "("], ["builtin", "inexact?"], + ["punctuation", "("], ["builtin", "input-port-open?"], + ["punctuation", "("], ["builtin", "input-port?"], + ["punctuation", "("], ["builtin", "integer->char"], + ["punctuation", "("], ["builtin", "integer?"], + ["punctuation", "("], ["builtin", "lcm"], + ["punctuation", "("], ["builtin", "length"], + ["punctuation", "("], ["builtin", "list"], + ["punctuation", "("], ["builtin", "list->string"], + ["punctuation", "("], ["builtin", "list->vector"], + ["punctuation", "("], ["builtin", "list-copy"], + ["punctuation", "("], ["builtin", "list-ref"], + ["punctuation", "("], ["builtin", "list-set!"], + ["punctuation", "("], ["builtin", "list-tail"], + ["punctuation", "("], ["builtin", "list?"], + ["punctuation", "("], ["builtin", "make-bytevector"], + ["punctuation", "("], ["builtin", "make-list"], + ["punctuation", "("], ["builtin", "make-parameter"], + ["punctuation", "("], ["builtin", "make-string"], + ["punctuation", "("], ["builtin", "make-vector"], + ["punctuation", "("], ["builtin", "map"], + ["punctuation", "("], ["builtin", "max"], + ["punctuation", "("], ["builtin", "member"], + ["punctuation", "("], ["builtin", "memq"], + ["punctuation", "("], ["builtin", "memv"], + ["punctuation", "("], ["builtin", "min"], + ["punctuation", "("], ["builtin", "modulo"], + ["punctuation", "("], ["builtin", "negative?"], + ["punctuation", "("], ["builtin", "newline"], + ["punctuation", "("], ["builtin", "not"], + ["punctuation", "("], ["builtin", "null?"], + ["punctuation", "("], ["builtin", "number->string"], + ["punctuation", "("], ["builtin", "number?"], + ["punctuation", "("], ["builtin", "numerator"], + ["punctuation", "("], ["builtin", "odd?"], + ["punctuation", "("], ["builtin", "open-input-bytevector"], + ["punctuation", "("], ["builtin", "open-input-string"], + ["punctuation", "("], ["builtin", "open-output-bytevector"], + ["punctuation", "("], ["builtin", "open-output-string"], + ["punctuation", "("], ["builtin", "or"], + ["punctuation", "("], ["builtin", "output-port-open?"], + ["punctuation", "("], ["builtin", "output-port?"], + ["punctuation", "("], ["builtin", "pair?"], + ["punctuation", "("], ["builtin", "peek-char"], + ["punctuation", "("], ["builtin", "peek-u8"], + ["punctuation", "("], ["builtin", "port?"], + ["punctuation", "("], ["builtin", "positive?"], + ["punctuation", "("], ["builtin", "procedure?"], + ["punctuation", "("], ["builtin", "quotient"], + ["punctuation", "("], ["builtin", "raise"], + ["punctuation", "("], ["builtin", "raise-continuable"], + ["punctuation", "("], ["builtin", "rational?"], + ["punctuation", "("], ["builtin", "rationalize"], + ["punctuation", "("], ["builtin", "read-bytevector"], + ["punctuation", "("], ["builtin", "read-bytevector!"], + ["punctuation", "("], ["builtin", "read-char"], + ["punctuation", "("], ["builtin", "read-error?"], + ["punctuation", "("], ["builtin", "read-line"], + ["punctuation", "("], ["builtin", "read-string"], + ["punctuation", "("], ["builtin", "read-u8"], + ["punctuation", "("], ["builtin", "real?"], + ["punctuation", "("], ["builtin", "remainder"], + ["punctuation", "("], ["builtin", "reverse"], + ["punctuation", "("], ["builtin", "round"], + ["punctuation", "("], ["builtin", "set-car!"], + ["punctuation", "("], ["builtin", "set-cdr!"], + ["punctuation", "("], ["builtin", "square"], + ["punctuation", "("], ["builtin", "string"], + ["punctuation", "("], ["builtin", "string->list"], + ["punctuation", "("], ["builtin", "string->number"], + ["punctuation", "("], ["builtin", "string->symbol"], + ["punctuation", "("], ["builtin", "string->utf8"], + ["punctuation", "("], ["builtin", "string->vector"], + ["punctuation", "("], ["builtin", "string-append"], + ["punctuation", "("], ["builtin", "string-copy"], + ["punctuation", "("], ["builtin", "string-copy!"], + ["punctuation", "("], ["builtin", "string-fill!"], + ["punctuation", "("], ["builtin", "string-for-each"], + ["punctuation", "("], ["builtin", "string-length"], + ["punctuation", "("], ["builtin", "string-map"], + ["punctuation", "("], ["builtin", "string-ref"], + ["punctuation", "("], ["builtin", "string-set!"], + ["punctuation", "("], ["builtin", "string<=?"], + ["punctuation", "("], ["builtin", "string=?"], + ["punctuation", "("], ["builtin", "string>?"], + ["punctuation", "("], ["builtin", "string?"], + ["punctuation", "("], ["builtin", "substring"], + ["punctuation", "("], ["builtin", "symbol->string"], + ["punctuation", "("], ["builtin", "symbol=?"], + ["punctuation", "("], ["builtin", "symbol?"], + ["punctuation", "("], ["builtin", "syntax-error"], + ["punctuation", "("], ["builtin", "textual-port?"], + ["punctuation", "("], ["builtin", "truncate"], + ["punctuation", "("], ["builtin", "truncate-quotient"], + ["punctuation", "("], ["builtin", "truncate-remainder"], + ["punctuation", "("], ["builtin", "truncate/"], + ["punctuation", "("], ["builtin", "u8-ready?"], + ["punctuation", "("], ["builtin", "utf8->string"], + ["punctuation", "("], ["builtin", "values"], + ["punctuation", "("], ["builtin", "vector"], + ["punctuation", "("], ["builtin", "vector->list"], + ["punctuation", "("], ["builtin", "vector->string"], + ["punctuation", "("], ["builtin", "vector-append"], + ["punctuation", "("], ["builtin", "vector-copy"], + ["punctuation", "("], ["builtin", "vector-copy!"], + ["punctuation", "("], ["builtin", "vector-fill!"], + ["punctuation", "("], ["builtin", "vector-for-each"], + ["punctuation", "("], ["builtin", "vector-length"], + ["punctuation", "("], ["builtin", "vector-map"], + ["punctuation", "("], ["builtin", "vector-ref"], + ["punctuation", "("], ["builtin", "vector-set!"], + ["punctuation", "("], ["builtin", "vector?"], + ["punctuation", "("], ["builtin", "with-exception-handler"], + ["punctuation", "("], ["builtin", "write-bytevector"], + ["punctuation", "("], ["builtin", "write-char"], + ["punctuation", "("], ["builtin", "write-string"], + ["punctuation", "("], ["builtin", "write-u8"], + ["punctuation", "("], ["builtin", "zero?"] ] ---------------------------------------------------- diff --git a/tests/languages/scheme/comment_feature.test b/tests/languages/scheme/comment_feature.test index 85faefe78b..af9bef0320 100644 --- a/tests/languages/scheme/comment_feature.test +++ b/tests/languages/scheme/comment_feature.test @@ -1,13 +1,26 @@ ; ; foobar +#;(foo bar) +#; (foo) + +#| + comment + #| nested comment |# +|# + ---------------------------------------------------- [ ["comment", ";"], - ["comment", "; foobar"] + ["comment", "; foobar"], + + ["comment", "#;(foo bar)"], + ["comment", "#; (foo)"], + + ["comment", "#|\r\n comment\r\n #| nested comment |#\r\n|#"] ] ---------------------------------------------------- -Checks for comments. \ No newline at end of file +Checks for comments. diff --git a/tests/languages/scheme/function_feature.test b/tests/languages/scheme/function_feature.test index 699ca063f4..bbd3259920 100644 --- a/tests/languages/scheme/function_feature.test +++ b/tests/languages/scheme/function_feature.test @@ -1,25 +1,23 @@ (fl= 1 2) (flmin 2 3) -(exact? 2) (inexact->exact 3) (!fact) (** 10) -(exact? (** (defined foo) +(|some name| foo) ---------------------------------------------------- [ ["punctuation", "("], ["function", "fl="], ["number", "1"], ["number", "2"], ["punctuation", ")"], ["punctuation", "("], ["function", "flmin"], ["number", "2"], ["number", "3"], ["punctuation", ")"], - ["punctuation", "("], ["function", "exact?"], ["number", "2"], ["punctuation", ")"], ["punctuation", "("], ["function", "inexact->exact"], ["number", "3"], ["punctuation", ")"], ["punctuation", "("], ["function", "!fact"], ["punctuation", ")"], ["punctuation", "("], ["function", "**"], ["number", "10"], ["punctuation", ")"], - ["punctuation", "("], ["function", "exact?"], ["punctuation", "("], ["function", "**"], - ["punctuation", "("], ["function", "defined"], " foo", ["punctuation", ")"] + ["punctuation", "("], ["function", "defined"], " foo", ["punctuation", ")"], + ["punctuation", "("], ["function", "|some name|"], " foo", ["punctuation", ")"] ] ---------------------------------------------------- diff --git a/tests/languages/scheme/identifier_feature.test b/tests/languages/scheme/identifier_feature.test new file mode 100644 index 0000000000..0ac5d36a62 --- /dev/null +++ b/tests/languages/scheme/identifier_feature.test @@ -0,0 +1,7 @@ +|\x9;\x9;| + +---------------------------------------------------- + +[ + ["identifier", "|\\x9;\\x9;|"] +] \ No newline at end of file diff --git a/tests/languages/scheme/keyword_feature.test b/tests/languages/scheme/keyword_feature.test index 53085d543d..2d6e82f5cf 100644 --- a/tests/languages/scheme/keyword_feature.test +++ b/tests/languages/scheme/keyword_feature.test @@ -1,65 +1,103 @@ -(define) +(begin) +(case) +(case-lambda) +(cond) +(cond-expand) (define-library) (define-macro) +(define-record-type) (define-syntax) (define-values) +(define) (defmacro) -(case-lambda) +(delay-force) +(delay) +(do) +(else) +(export) +(except) +(guard) +(if) +(import) +(include) +(include-ci) +(include-library-declarations) (lambda) -(let) -(let*) -(letrec) +(let-syntax) (let-values) +(let) (let*-values) +(let*) +(letrec-syntax) (letrec-values) -(else) -(if) -(cond) -(begin) -(delay) -(delay-force) +(letrec) +(letrec*) +(only) (parameterize) -(guard) -(set!) +(prefix) (quasi-quote) +(quasiquote) (quote) -(syntax-rules) +(rename) +(set!) (syntax-case) -(letrec-syntax) -(let-syntax) +(syntax-rules) +(unless) +(unquote) +(unquote-splicing) +(when) ---------------------------------------------------- [ - ["punctuation", "("], ["keyword", "define"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "begin"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "case"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "case-lambda"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "cond"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "cond-expand"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "define-library"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "define-macro"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "define-record-type"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "define-syntax"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "define-values"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "define"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "defmacro"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "case-lambda"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "delay-force"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "delay"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "do"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "else"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "export"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "except"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "guard"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "if"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "import"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "include"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "include-ci"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "include-library-declarations"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "lambda"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "let"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "let*"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "letrec"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "let-syntax"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "let-values"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "let"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "let*-values"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "let*"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "letrec-syntax"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "letrec-values"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "else"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "if"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "cond"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "begin"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "delay"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "delay-force"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "letrec"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "letrec*"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "only"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "parameterize"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "guard"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "set!"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "prefix"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "quasi-quote"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "quasiquote"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "quote"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "syntax-rules"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "rename"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "set!"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "syntax-case"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "letrec-syntax"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "let-syntax"], ["punctuation", ")"] + ["punctuation", "("], ["keyword", "syntax-rules"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "unless"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "unquote"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "unquote-splicing"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "when"], ["punctuation", ")"] ] ---------------------------------------------------- diff --git a/tests/languages/scheme/lambda_parameter_feature.test b/tests/languages/scheme/lambda_parameter_feature.test index a076879750..bbc7a22ffa 100644 --- a/tests/languages/scheme/lambda_parameter_feature.test +++ b/tests/languages/scheme/lambda_parameter_feature.test @@ -1,5 +1,9 @@ (lambda x x) + +(lambda |some name| |some name|) + (lambda (x) x) + (lambda (foo bar) (concat foo bar)) ---------------------------------------------------- @@ -10,6 +14,13 @@ ["lambda-parameter", "x"], " x", ["punctuation", ")"], + + ["punctuation", "("], + ["keyword", "lambda"], + ["lambda-parameter", "|some name|"], + ["identifier", "|some name|"], + ["punctuation", ")"], + ["punctuation", "("], ["keyword", "lambda"], ["punctuation", "("], @@ -17,6 +28,7 @@ ["punctuation", ")"], " x", ["punctuation", ")"], + ["punctuation", "("], ["keyword", "lambda"], ["punctuation", "("],