return new_lines;
}
- bool comment () {
+ bool comment (bool file_comment = false) {
if (current > end - 2
|| current[0] != '/'
|| (current[1] != '/' && current[1] != '*')) {
return false;
}
+
if (current[1] == '/') {
// single-line comment
+
+ SourceReference source_reference = null;
+ if (file_comment) {
+ source_reference = new SourceReference (source_file, line, column, line, column);
+ }
+
current += 2;
// skip until end of line or end of file
column = 1;
current_indent_level = 0;
}
+
+ if (source_reference != null) {
+ push_comment (((string) begin).ndup ((long) (current - begin)), source_reference, file_comment);
+ }
+
} else {
// delimited comment
SourceReference source_reference = null;
+ if (file_comment && current[2] == '*') {
+ return false;
+ }
- if (current[2] == '*') {
+ if (current[2] == '*' || file_comment) {
source_reference = new SourceReference (source_file, line, column, line, column);
}
current += 2;
char* begin = current;
- int begin_line = line;
+
while (current < end - 1
&& (current[0] != '*' || current[1] != '/')) {
if (current[0] == '\n') {
if (source_reference != null) {
string comment = ((string) begin).ndup ((long) (current - begin));
- push_comment (comment, source_reference, begin_line == 1 && comment[0] != '*');
+ push_comment (comment, source_reference, file_comment);
}
current += 2;
}
}
+ public void parse_file_comments () {
+ while (whitespace () || comment (true)) {
+ }
+
+ }
+
void push_comment (string comment_item, SourceReference source_reference, bool file_comment) {
if (comment_item[0] == '*') {
_comment = new Comment (comment_item, source_reference);