small refactor.
This commit is contained in:
parent
aef3a954da
commit
079cbe8b6a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user