File tree Expand file tree Collapse file tree 3 files changed +48
-14
lines changed Expand file tree Collapse file tree 3 files changed +48
-14
lines changed Original file line number Diff line number Diff line change
1
+ ================================================================================
2
+ Single line comments
3
+ ================================================================================
4
+
5
+ // comment 1
6
+ // comment 2
7
+
8
+ --------------------------------------------------------------------------------
9
+
10
+ (compilation_unit
11
+ (comment)
12
+ (comment))
13
+
14
+ ================================================================================
15
+ Block comments
16
+ ================================================================================
17
+ /**/
18
+ /** comment 1
19
+ * /* comment 2
20
+ * /* / * * /comment 3 */
21
+ // comment 4
22
+ * @param
23
+ * */
24
+ */
25
+
26
+ --------------------------------------------------------------------------------
27
+
28
+ (compilation_unit
29
+ (block_comment)
30
+ (block_comment
31
+ (block_comment
32
+ (block_comment)
33
+ (comment))))
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ class C {
76
76
(identifier)
77
77
(operator_identifier)
78
78
(integer_literal)))))
79
- (comment )
79
+ (block_comment )
80
80
(call_expression
81
81
(field_expression
82
82
(identifier)
@@ -813,7 +813,7 @@ class C {
813
813
(identifier)
814
814
(identifier))
815
815
(comment)
816
- (comment )
816
+ (block_comment )
817
817
(identifier)))))))
818
818
819
819
================================================================================
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ module.exports = grammar({
27
27
28
28
extras : $ => [
29
29
/ \s / ,
30
- $ . comment
30
+ $ . comment ,
31
+ $ . block_comment ,
31
32
] ,
32
33
33
34
supertypes : $ => [
@@ -1294,7 +1295,7 @@ module.exports = grammar({
1294
1295
wildcard : $ => '_' ,
1295
1296
1296
1297
/**
1297
- * Regex patterns created to avoid matching // comments.
1298
+ * Regex patterns created to avoid matching // comments and /* comment starts .
1298
1299
* This could technically match illeagal tokens such as val ?// = 1
1299
1300
*/
1300
1301
operator_identifier : $ => token ( choice (
@@ -1309,8 +1310,8 @@ module.exports = grammar({
1309
1310
seq (
1310
1311
// opchar
1311
1312
/ [ \- ! # % & * + \/ \\ : < = > ? @ \u005e \u007c ~ \p{ Sm} \p{ So} ] / ,
1312
- // opchar minus slash
1313
- / [ \- ! # % & * + \\ : < = > ? @ \u005e \u007c ~ \p{ Sm} \p{ So} ] / ,
1313
+ // opchar minus slash and asterisk
1314
+ / [ \- ! # % & + \\ : < = > ? @ \u005e \u007c ~ \p{ Sm} \p{ So} ] / ,
1314
1315
// opchar*
1315
1316
repeat ( / [ \- ! # % & * + \/ \\ : < = > ? @ \u005e \u007c ~ \p{ Sm} \p{ So} ] / ) ,
1316
1317
) ,
@@ -1520,14 +1521,14 @@ module.exports = grammar({
1520
1521
repeat1 ( $ . guard ) ,
1521
1522
) ,
1522
1523
1523
- comment : $ => token ( choice (
1524
- seq ( '//' , / . * / ) ,
1525
- seq (
1526
- '/*' ,
1527
- / [ ^ * ] * \* + ( [ ^ / * ] [ ^ * ] * \* + ) * / ,
1528
- '/'
1529
- )
1530
- ) )
1524
+ comment : $ => token ( seq ( '//' , / . * / ) ) ,
1525
+
1526
+ block_comment : $ => seq (
1527
+ token ( '/*' ) ,
1528
+ repeat ( token ( / . / ) ) ,
1529
+ token ( '*/' )
1530
+ ) ,
1531
+
1531
1532
}
1532
1533
} )
1533
1534
You can’t perform that action at this time.
0 commit comments