main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
946 bytes
|
Rev | Line | |
---|
[d565449] | 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.