Browse files

use regexp for strings :)

  • Loading branch information...
1 parent e5a713c commit 7cc9e35cb52eeae7f311283a753cd52ad33bbec7 @thejh thejh committed Jan 16, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 clarinet.js
View
13 clarinet.js
@@ -122,6 +122,8 @@ if(typeof FastList === 'function') {
parser[buffers[i]] = "";
}
}
+
+ var stringTokenPattern = /[\\"\n]/g
function CParser (opt) {
if (!(this instanceof CParser)) return new CParser (opt);
@@ -413,7 +415,16 @@ if(typeof FastList === 'function') {
parser.line ++;
parser.column = 0;
} else parser.column ++;
- c = chunk.charAt(i++);
+
+ stringTokenPattern.lastIndex = i
+ var reResult = stringTokenPattern.exec(chunk)
+ if (reResult == null) {
+ i = chunk.length+1
+ break
+ }
+ if (reResult.index > i) consecutive_slashes = 0;
+ i = reResult.index+1;
+ c = chunk.charAt(reResult.index);
}
var e = gaps.shift()
, s = starti

0 comments on commit 7cc9e35

Please sign in to comment.