Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

use regexp for strings :)

  • Loading branch information...
commit 7cc9e35cb52eeae7f311283a753cd52ad33bbec7 1 parent e5a713c
Jann Horn thejh authored

Showing 1 changed file with 12 additions and 1 deletion. Show diff stats Hide diff stats

  1. +12 1 clarinet.js
13 clarinet.js
@@ -122,6 +122,8 @@ if(typeof FastList === 'function') {
122 122 parser[buffers[i]] = "";
123 123 }
124 124 }
  125 +
  126 + var stringTokenPattern = /[\\"\n]/g
125 127
126 128 function CParser (opt) {
127 129 if (!(this instanceof CParser)) return new CParser (opt);
@@ -413,7 +415,16 @@ if(typeof FastList === 'function') {
413 415 parser.line ++;
414 416 parser.column = 0;
415 417 } else parser.column ++;
416   - c = chunk.charAt(i++);
  418 +
  419 + stringTokenPattern.lastIndex = i
  420 + var reResult = stringTokenPattern.exec(chunk)
  421 + if (reResult == null) {
  422 + i = chunk.length+1
  423 + break
  424 + }
  425 + if (reResult.index > i) consecutive_slashes = 0;
  426 + i = reResult.index+1;
  427 + c = chunk.charAt(reResult.index);
417 428 }
418 429 var e = gaps.shift()
419 430 , s = starti

0 comments on commit 7cc9e35

Please sign in to comment.
Something went wrong with that request. Please try again.