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 7373 stream . match ( ".." )
7474 return "punctuation"
7575 }
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 ] )
7879 state . tokenize . push ( tokenize )
7980 return tokenize ( stream , state )
8081 }
115116 }
116117 }
117118
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 ( ) )
131127 return "string"
132- } else {
133- escaped = ch == "\\"
134128 }
135- }
136- if ( singleLine ) {
129+ escaped = false
130+ } else if ( stream . match ( openQuote ) ) {
137131 state . tokenize . pop ( )
132+ return "string"
133+ } else {
134+ stream . next ( )
135+ escaped = ch == "\\"
138136 }
139- return "string"
140137 }
138+ if ( singleLine ) {
139+ state . tokenize . pop ( )
140+ }
141+ return "string"
141142 }
142143
143144 function tokenComment ( stream , state ) {
Original file line number Diff line number Diff line change 4040 "[string multi]" ,
4141 "[string line]" ,
4242 "[string \"test\"]" ,
43- "[string \"\"\"]" ) ;
43+ "[string \"\"\"]" ,
44+ "[variable print][punctuation (][string \"\"][punctuation )]" ) ;
4445
4546 // Comments.
4647 MT ( "comments" ,
You can’t perform that action at this time.
0 commit comments