[clojure] Add a word boundary to ensure exact matches for (comment ...).

This commit is contained in:
Abdussalam Abdurrahman 2018-09-12 18:32:24 -07:00
parent 6f6f1b43f0
commit c77f11b1b0
2 changed files with 26 additions and 2 deletions

View file

@ -792,6 +792,30 @@ testTokenization('clojure', [
{startIndex: 0, type: 'comment.clj'}, {startIndex: 0, type: 'comment.clj'},
], ],
}, },
{
line: '(comments foo bar)',
tokens: [
{startIndex: 0, type: 'delimiter.parenthesis.clj'},
{startIndex: 1, type: 'identifier.clj'},
{startIndex: 9, type: 'white.clj'},
{startIndex: 10, type: 'identifier.clj'},
{startIndex: 13, type: 'white.clj'},
{startIndex: 14, type: 'identifier.clj'},
{startIndex: 17, type: 'delimiter.parenthesis.clj'},
]
},
{
line: '(comment6 foo bar)',
tokens: [
{startIndex: 0, type: 'delimiter.parenthesis.clj'},
{startIndex: 1, type: 'identifier.clj'},
{startIndex: 9, type: 'white.clj'},
{startIndex: 10, type: 'identifier.clj'},
{startIndex: 13, type: 'white.clj'},
{startIndex: 14, type: 'identifier.clj'},
{startIndex: 17, type: 'delimiter.parenthesis.clj'},
]
},
{ {
line: '(comment foo', line: '(comment foo',
tokens: [ tokens: [

View file

@ -762,13 +762,13 @@ export const language = <ILanguage>{
whitespace: [ whitespace: [
[/\s+/, 'white'], [/\s+/, 'white'],
[/;.*$/, 'comment'], [/;.*$/, 'comment'],
[/\(comment/, 'comment', '@comment'], [/\(comment\b/, 'comment', '@comment'],
], ],
comment: [ comment: [
[/\(/, 'comment', '@push'], [/\(/, 'comment', '@push'],
[/\)/, 'comment', '@pop'], [/\)/, 'comment', '@pop'],
[/[^)]/, 'comment'], [/[^()]/, 'comment'],
], ],
string: [ string: [