small refactor.

This commit is contained in:
Christopher Jeffrey 2013-01-03 01:06:58 -06:00
parent aef3a954da
commit 079cbe8b6a

View File

@ -89,11 +89,11 @@ Lexer.lex = function(src, options) {
};
Lexer.prototype.lex = function(src) {
this.src = src
src = src
.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ');
return this.token(this.src, true);
return this.token(src, true);
};
Lexer.prototype.token = function(src, top) {
@ -562,9 +562,6 @@ Parser.prototype.parse = function(src) {
out += this.tok();
}
this.tokens = [];
this.token = null;
return out;
};
@ -572,12 +569,14 @@ Parser.prototype.next = function() {
return this.token = this.tokens.pop();
};
Parser.prototype.parseText = function() {
var body = this.token.text
, top;
Parser.prototype.peek = function() {
return this.tokens[this.tokens.length-1] || 0;
};
while ((top = this.tokens[this.tokens.length-1])
&& top.type === 'text') {
Parser.prototype.parseText = function() {
var body = this.token.text;
while (this.peek().type === 'text') {
body += '\n' + this.next().text;
}