Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
946 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
| 2 |
|
---|
| 3 | var COMMENT = TYPE.Comment;
|
---|
| 4 | var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
---|
| 5 | var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
---|
| 6 |
|
---|
| 7 | // '/*' .* '*/'
|
---|
| 8 | module.exports = {
|
---|
| 9 | name: 'Comment',
|
---|
| 10 | structure: {
|
---|
| 11 | value: String
|
---|
| 12 | },
|
---|
| 13 | parse: function() {
|
---|
| 14 | var start = this.scanner.tokenStart;
|
---|
| 15 | var end = this.scanner.tokenEnd;
|
---|
| 16 |
|
---|
| 17 | this.eat(COMMENT);
|
---|
| 18 |
|
---|
| 19 | if ((end - start + 2) >= 2 &&
|
---|
| 20 | this.scanner.source.charCodeAt(end - 2) === ASTERISK &&
|
---|
| 21 | this.scanner.source.charCodeAt(end - 1) === SOLIDUS) {
|
---|
| 22 | end -= 2;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | return {
|
---|
| 26 | type: 'Comment',
|
---|
| 27 | loc: this.getLocation(start, this.scanner.tokenStart),
|
---|
| 28 | value: this.scanner.source.substring(start + 2, end)
|
---|
| 29 | };
|
---|
| 30 | },
|
---|
| 31 | generate: function(node) {
|
---|
| 32 | this.chunk('/*');
|
---|
| 33 | this.chunk(node.value);
|
---|
| 34 | this.chunk('*/');
|
---|
| 35 | }
|
---|
| 36 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.