Permalink
Browse files

drop regexes

  • Loading branch information...
chjj committed Mar 7, 2012
1 parent 552e2d0 commit 114861c1941d5fa06c0e64079dc6dddb21f9965a
Showing with 17 additions and 4 deletions.
  1. +17 −4 lib/lexer.js
View
@@ -4,10 +4,6 @@
*/
var lexer = function(str, options) {
- str = str
- .replace(/\r\n|\r/g, '\n')
- .replace(/"/g, '\\"');
-
var i = 0
, l = str.length
, ch
@@ -60,6 +56,9 @@ var lexer = function(str, options) {
}
switch(ch) {
+ case '\r':
+ if (str[i+1] === '\n') break;
+ ;
case '\n':
line++;
offset = 0;
@@ -173,6 +172,20 @@ var lexer = function(str, options) {
break;
}
break;
+ case '"':
+ switch (state()) {
+ case 'interpolate':
+ case 'evaluate':
+ buff += '"';
+ break;
+ case 'if':
+ case 'not':
+ case 'iterate':
+ default:
+ buff += '\\"';
+ break;
+ }
+ break;
default:
buff += ch;
break;

0 comments on commit 114861c

Please sign in to comment.