File tree Expand file tree Collapse file tree 2 files changed +23
-21
lines changed Expand file tree Collapse file tree 2 files changed +23
-21
lines changed Original file line number Diff line number Diff line change 73
73
stream . match ( ".." )
74
74
return "punctuation"
75
75
}
76
- if ( ch = stream . match ( / ( " { 3 } | " | ' ) / ) ) {
77
- var tokenize = tokenString ( ch [ 0 ] )
76
+ var stringMatch
77
+ if ( stringMatch = stream . match ( / ( " " " | " | ' ) / ) ) {
78
+ var tokenize = tokenString . bind ( null , stringMatch [ 0 ] )
78
79
state . tokenize . push ( tokenize )
79
80
return tokenize ( stream , state )
80
81
}
115
116
}
116
117
}
117
118
118
- function tokenString ( quote ) {
119
- var singleLine = quote . length == 1
120
- return function ( stream , state ) {
121
- var ch , escaped = false
122
- while ( ch = stream . next ( ) ) {
123
- if ( escaped ) {
124
- if ( ch == "(" ) {
125
- state . tokenize . push ( tokenUntilClosingParen ( ) )
126
- return "string"
127
- }
128
- escaped = false
129
- } else if ( stream . match ( quote ) ) {
130
- state . tokenize . pop ( )
119
+ function tokenString ( openQuote , stream , state ) {
120
+ var singleLine = openQuote . length == 1
121
+ var ch , escaped = false
122
+ while ( ch = stream . peek ( ) ) {
123
+ if ( escaped ) {
124
+ stream . next ( )
125
+ if ( ch == "(" ) {
126
+ state . tokenize . push ( tokenUntilClosingParen ( ) )
131
127
return "string"
132
- } else {
133
- escaped = ch == "\\"
134
128
}
135
- }
136
- if ( singleLine ) {
129
+ escaped = false
130
+ } else if ( stream . match ( openQuote ) ) {
137
131
state . tokenize . pop ( )
132
+ return "string"
133
+ } else {
134
+ stream . next ( )
135
+ escaped = ch == "\\"
138
136
}
139
- return "string"
140
137
}
138
+ if ( singleLine ) {
139
+ state . tokenize . pop ( )
140
+ }
141
+ return "string"
141
142
}
142
143
143
144
function tokenComment ( stream , state ) {
Original file line number Diff line number Diff line change 40
40
"[string multi]" ,
41
41
"[string line]" ,
42
42
"[string \"test\"]" ,
43
- "[string \"\"\"]" ) ;
43
+ "[string \"\"\"]" ,
44
+ "[variable print][punctuation (][string \"\"][punctuation )]" ) ;
44
45
45
46
// Comments.
46
47
MT ( "comments" ,
You can’t perform that action at this time.
0 commit comments