Skip to content

Commit

Permalink
fix infinite loop when parsing a block
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Jan 19, 2017
1 parent a66edcd commit 4a05f0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Parser.prototype.parseAnnotation = function () {
name: type,
options: []
};
while (line === this.lexer.line) {
while (line === this.lexer.line && this.token !== this.lexer._t.T_EOF) {
item = this.parseTopStatement();
if (item !== null) {
result.options.push(item);
Expand Down
8 changes: 8 additions & 0 deletions test/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ var DocBlockParser = require('../src/index');

describe('Test annotations', function () {
var doc = new DocBlockParser();
it('should parse', function () {
var ast = doc.parse([
'@foobar'
]);
ast.body[0].kind.should.be.exactly('block');
ast.body[0].name.should.be.exactly('foobar');
ast.body[0].options.length.should.be.exactly(0);
});
it('should parse', function () {
var ast = doc.parse([
'/**',
Expand Down

0 comments on commit 4a05f0b

Please sign in to comment.