Report error on unclosed multiline comment.

Fixes #22
This commit is contained in:
Daniel Rosenwasser 2014-07-14 17:39:20 -07:00
parent 455364cf5a
commit c777d5c68a
6 changed files with 35 additions and 25 deletions

View File

@ -662,11 +662,14 @@ module ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
pos += 2;
while (pos < len) {
var safeLength = len - 1; // For lookahead.
var commentClosed = false;
while (pos < safeLength) {
var ch = text.charCodeAt(pos);
if (ch === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) {
pos += 2;
commentClosed = true;
break;
}
@ -676,6 +679,11 @@ module ts {
pos++;
}
if (!commentClosed) {
pos++;
onError(Diagnostics.Asterisk_Slash_expected);
}
if (onComment) {
onComment(tokenPos, pos);
}

View File

@ -0,0 +1,7 @@
==== tests/cases/conformance/parser/ecmascript5/parserKeywordsAsIdentifierName2.ts (2 errors) ====
// 'public' should be marked unusable, should complain on trailing /*
a.public /*
!!! '*/' expected.
~
!!! Cannot find name 'a'.

View File

@ -1,5 +0,0 @@
//// [parserKeywordsAsIdentifierName2.ts]
// 'public' shoudl be marked unusable because it has a trailing /*
//a.public /*
//// [parserKeywordsAsIdentifierName2.js]

View File

@ -0,0 +1,17 @@
==== tests/cases/conformance/scanner/ecmascript5/scannerS7.4_A2_T2.ts (1 errors) ====
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Correct interpretation of multi line comments
*
* @path ch07/7.4/S7.4_A2_T2.js
* @description Try use /*CHECK#1/. This is not closed multi line comment
* @negative
*/
/*CHECK#1/
!!! '*/' expected.

View File

@ -1,17 +0,0 @@
//// [scannerS7.4_A2_T2.ts]
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Correct interpretation of multi line comments
*
* @path ch07/7.4/S7.4_A2_T2.js
* @description Try use /*CHECK#1/. This is not closed multi line comment
* @negative
*/
/*CHECK#1/
//// [scannerS7.4_A2_T2.js]

View File

@ -1,2 +1,2 @@
// 'public' shoudl be marked unusable because it has a trailing /*
//a.public /*
// 'public' should be marked unusable, should complain on trailing /*
a.public /*