Skip to content

Commit a60f92b

Browse files
committed
designate doc comments
1 parent 2beedf2 commit a60f92b

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

corpus/source_files.txt

+19
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ Line comments
5555
(source_file
5656
(line_comment))
5757

58+
============================================
59+
Doc comments
60+
============================================
61+
62+
/// Foo
63+
///
64+
/// # Description
65+
///
66+
/// * Bar
67+
68+
----
69+
70+
(source_file
71+
(doc_comment)
72+
(doc_comment)
73+
(doc_comment)
74+
(doc_comment)
75+
(doc_comment))
76+
5877
=====================================
5978
Greek letters in identifiers
6079
=====================================

grammar.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const primitive_types = numeric_types.concat(['bool', 'str', 'char'])
3838
module.exports = grammar({
3939
name: 'rust',
4040

41-
extras: $ => [/\s/, $.line_comment, $.block_comment],
41+
extras: $ => [/\s/, $.line_comment, $.block_comment, $.doc_comment],
4242

4343
externals: $ => [
4444
$._string_content,
@@ -1410,13 +1410,12 @@ module.exports = grammar({
14101410

14111411
boolean_literal: $ => choice('true', 'false'),
14121412

1413-
comment: $ => choice(
1414-
$.line_comment,
1415-
$.block_comment
1416-
),
1413+
doc_comment: $ => token(seq(
1414+
'///', /.*/
1415+
)),
14171416

14181417
line_comment: $ => token(seq(
1419-
'//', /.*/
1418+
new RegExp('\/\/[^\/]'), /.*/
14201419
)),
14211420

14221421
_path: $ => choice(

0 commit comments

Comments
 (0)