|
5 | 5 | // and (potentially nested) multiline comments:
|
6 | 6 | // #| comment #| nested |# still comment |#
|
7 | 7 | // (only 1 level of nesting is supported)
|
8 |
| - 'comment': /;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, |
| 8 | + 'comment': /;.*|#;\s*(?:\((?:[^()]|\([^()]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\])|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, |
9 | 9 | 'string': {
|
10 | 10 | pattern: /"(?:[^"\\]|\\.)*"/,
|
11 | 11 | greedy: true
|
12 | 12 | },
|
13 | 13 | 'symbol': {
|
14 |
| - pattern: /'[^()#'\s]+/, |
| 14 | + pattern: /'[^()\[\]#'\s]+/, |
15 | 15 | greedy: true
|
16 | 16 | },
|
17 | 17 | 'character': {
|
|
22 | 22 | 'lambda-parameter': [
|
23 | 23 | // https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_6.html#SEC30
|
24 | 24 | {
|
25 |
| - pattern: /((?:^|[^'`#])\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/, |
| 25 | + pattern: /((?:^|[^'`#])[(\[]lambda\s+)(?:[^|()\[\]'\s]+|\|(?:[^\\|]|\\.)*\|)/, |
26 | 26 | lookbehind: true
|
27 | 27 | },
|
28 | 28 | {
|
29 |
| - pattern: /((?:^|[^'`#])\(lambda\s+\()[^()']+/, |
| 29 | + pattern: /((?:^|[^'`#])[(\[]lambda\s+[(\[])[^()\[\]']+/, |
30 | 30 | lookbehind: true
|
31 | 31 | }
|
32 | 32 | ],
|
33 | 33 | 'keyword': {
|
34 |
| - 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]|$)/, |
| 34 | + 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]|$)/, |
35 | 35 | lookbehind: true
|
36 | 36 | },
|
37 | 37 | 'builtin': {
|
38 | 38 | // all functions of the base library of R7RS plus some of built-ins of R5Rs
|
39 |
| - 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]|$)/, |
| 39 | + 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]|$)/, |
40 | 40 | lookbehind: true
|
41 | 41 | },
|
42 | 42 | 'operator': {
|
43 |
| - pattern: /((?:^|[^'`#])\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/, |
| 43 | + pattern: /((?:^|[^'`#])[(\[])(?:[-+*%/]|[<>]=?|=>?)(?=[()\[\]\s]|$)/, |
44 | 44 | lookbehind: true
|
45 | 45 | },
|
46 | 46 | 'number': {
|
|
82 | 82 | '<complex box>': /<real box>(?:@<real box>|<imaginary box>)?|<imaginary box>/.source,
|
83 | 83 | '<num box>': /#[box](?:#[ei])?|(?:#[ei])?#[box]<complex box>/.source,
|
84 | 84 |
|
85 |
| - '<number>': /(^|[\s()])(?:<num dec>|<num box>)(?=[()\s]|$)/.source, |
| 85 | + '<number>': /(^|[()\[\]\s])(?:<num dec>|<num box>)(?=[()\[\]\s]|$)/.source, |
86 | 86 | }), 'i'),
|
87 | 87 | lookbehind: true
|
88 | 88 | },
|
89 | 89 | 'boolean': {
|
90 |
| - pattern: /(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/, |
| 90 | + pattern: /(^|[()\[\]\s])#(?:[ft]|false|true)(?=[()\[\]\s]|$)/, |
91 | 91 | lookbehind: true
|
92 | 92 | },
|
93 | 93 | 'function': {
|
94 |
| - pattern: /((?:^|[^'`#])\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/, |
| 94 | + pattern: /((?:^|[^'`#])[(\[])(?:[^|()\[\]'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\[\]\s]|$)/, |
95 | 95 | lookbehind: true
|
96 | 96 | },
|
97 | 97 | 'identifier': {
|
98 |
| - pattern: /(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/, |
| 98 | + pattern: /(^|[()\[\]\s])\|(?:[^\\|]|\\.)*\|(?=[()\[\]\s]|$)/, |
99 | 99 | lookbehind: true,
|
100 | 100 | greedy: true
|
101 | 101 | },
|
102 |
| - 'punctuation': /[()']/ |
| 102 | + 'punctuation': /[()\[\]']/ |
103 | 103 | };
|
104 | 104 |
|
105 | 105 | /**
|
|
0 commit comments