diff --git a/lib/jslex.js b/lib/jslex.js index c268513..a3bdc13 100644 --- a/lib/jslex.js +++ b/lib/jslex.js @@ -135,6 +135,15 @@ Narcissus.lexer = (function() { for (;;) { var ch = input[this.cursor++]; var next = input[this.cursor]; + // handle \r, \r\n and (always preferable) \n + if (ch === '\r') { + // if the next character is \n, we don't care about this at all + if (next === '\n') continue; + + // otherwise, we want to consider this as a newline + ch = '\n'; + } + if (ch === '\n' && !this.scanNewlines) { this.lineno++; } else if (ch === '/' && next === '*') {