Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ng by using the lexer input function dirrectly
  • Loading branch information
ichiriac committed Mar 12, 2017
1 parent 1c717a8 commit ecd6a46
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,18 +447,16 @@ Parser.prototype.parseText = function () {
if (this.token !== this.lexer._t.T_STRING) {
return null;
}
var line = this.lexer.backup.line;
var offset = this.lexer.backup.offset;
while (this.token !== this.lexer._t.EOF) {
this.token = this.lexer.lex(); // eat && continue
if (this.lexer.line !== line) {
this.lexer.unlex();
var ch = this.lexer.input();
while (ch !== null) {
if (ch === '\r' || ch === '\n' || ch === '\r\n') {
break;
}
ch = this.lexer.input();
}
var result = this.lexer._input.substring(offset, this.lexer.offset).trim();
var input = this.lexer.text.trim();
this.token = this.lexer.lex(); // eat && continue
return result;
return input;
};

/**
Expand Down
24 changes: 24 additions & 0 deletions test/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ describe('Test annotations', function () {
);
});

it('test deprecated', function () {
var ast = doc.parse([
'/**',
' * @deprecated 1.2.3-alpha',
' * @deprecated That\'s the way',
' */'
].join('\r\n'));
ast.body.length.should.be.exactly(2);

ast.body[0].kind.should.be.exactly('deprecated');
(ast.body[0].description === null).should.be.exactly(true);
ast.body[0].version.major.should.be.exactly(1);
ast.body[0].version.minor.should.be.exactly(2);
ast.body[0].version.patch.should.be.exactly(3);
ast.body[0].version.label.should.be.exactly('alpha');

ast.body[1].kind.should.be.exactly('deprecated');
ast.body[1].description.should.be.exactly('That\'s the way');
ast.body[1].version.major.should.be.exactly(0);
ast.body[1].version.minor.should.be.exactly(0);
ast.body[1].version.patch.should.be.exactly(0);
(ast.body[1].version.label === null).should.be.exactly(true);
});

it('should parse', function () {
var ast = doc.parse([
'/**',
Expand Down

0 comments on commit ecd6a46

Please sign in to comment.