forked from glayzzle/php-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.js
More file actions
52 lines (51 loc) · 1.25 KB
/
comment.js
File metadata and controls
52 lines (51 loc) · 1.25 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
/**
* Comments with // or # or / * ... * /
*/
read_comment: function() {
const text = this.text();
let result = this.ast.prepare(
text.substring(0, 2) === "/*" ? "commentblock" : "commentline",
null,
this
);
const offset = this.lexer.yylloc.first_offset;
// handle location on comment
const prev = this.prev;
this.prev = [
this.lexer.yylloc.last_line,
this.lexer.yylloc.last_column,
this.lexer.offset
];
this.lex();
result = result(text);
result.offset = offset;
this.prev = prev;
return result;
},
/**
* Comments with / ** ... * /
*/
read_doc_comment: function() {
let result = this.ast.prepare("commentblock", null, this);
const offset = this.lexer.yylloc.first_offset;
const text = this.text();
const prev = this.prev;
this.prev = [
this.lexer.yylloc.last_line,
this.lexer.yylloc.last_column,
this.lexer.offset
];
this.lex();
result = result(text);
result.offset = offset;
this.prev = prev;
return result;
}
};