Skip to content

Commit b715ba3

Browse files
committed
designate doc comments
1 parent c7c50d4 commit b715ba3

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,
@@ -1425,13 +1425,12 @@ module.exports = grammar({
14251425

14261426
boolean_literal: $ => choice('true', 'false'),
14271427

1428-
comment: $ => choice(
1429-
$.line_comment,
1430-
$.block_comment
1431-
),
1428+
doc_comment: $ => token(seq(
1429+
'///', /.*/
1430+
)),
14321431

14331432
line_comment: $ => token(seq(
1434-
'//', /.*/
1433+
new RegExp('\/\/[^\/]'), /.*/
14351434
)),
14361435

14371436
_path: $ => choice(

0 commit comments

Comments
 (0)