forked from lkesteloot/turbopascal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommentStripper.js
34 lines (29 loc) · 902 Bytes
/
CommentStripper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// A token filter that strips out comment tokens.
if (typeof define !== 'function') { var define = require('amdefine')(module) };
define(["./Token"], function (Token) {
var CommentStripper = function (lexer) {
this.lexer = lexer;
};
// Returns the next token.
CommentStripper.prototype.next = function () {
while (true) {
var token = this.lexer.next();
if (token.tokenType != Token.COMMENT) {
return token;
}
}
};
// Peeks at the next token.
CommentStripper.prototype.peek = function () {
while (true) {
var token = this.lexer.peek();
if (token.tokenType != Token.COMMENT) {
return token;
} else {
// Skip the comment.
this.lexer.next();
}
}
};
return CommentStripper;
});