Skip to content

Commit ddd4766

Browse files
committed
feat: unnest more module_identifier_path’s
1 parent c9fb4d3 commit ddd4766

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

grammar.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = grammar({
2424
$.primary_expression,
2525
$._type,
2626
$.module_expression,
27+
$.module_primary_expression,
2728
],
2829

2930
precedences: $ => [
@@ -91,7 +92,8 @@ module.exports = grammar({
9192
[$.parameter, $._parenthesized_pattern],
9293
[$._switch_value_pattern, $._parenthesized_pattern],
9394
[$.variant_declaration],
94-
[$.unit, $._function_type_parameter_list]
95+
[$.unit, $._function_type_parameter_list],
96+
[$.module_primary_expression, $.module_identifier_path],
9597
],
9698

9799
rules: {
@@ -1235,18 +1237,22 @@ module.exports = grammar({
12351237
),
12361238

12371239
type_identifier_path: $ => seq(
1238-
$.module_identifier_path,
1240+
$.module_primary_expression,
12391241
'.',
12401242
$.type_identifier
12411243
),
12421244

12431245
module_expression: $ => choice(
1244-
$.module_identifier,
1245-
$.module_identifier_path,
1246+
$.module_primary_expression,
12461247
$.type_identifier_path,
12471248
$.module_type_of,
1248-
$.functor_use,
12491249
$.module_type_constraint,
1250+
),
1251+
1252+
module_primary_expression: $ => choice(
1253+
$.module_identifier,
1254+
$.module_identifier_path,
1255+
$.functor_use,
12501256
$.module_unpack,
12511257
),
12521258

test/corpus/expressions.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,7 @@ switch foo {
493493
(switch_match
494494
(polyvar_type_pattern
495495
(type_identifier_path
496-
(module_identifier_path
497-
(module_identifier))
496+
(module_identifier)
498497
(type_identifier)))
499498
(as_aliasing (value_identifier))
500499
(expression_statement (number))))))
@@ -1434,6 +1433,6 @@ let f = ({name, _} as foo: T.t) => {}
14341433
(value_identifier)
14351434
(type_annotation
14361435
(type_identifier_path
1437-
(module_identifier_path (module_identifier))
1436+
(module_identifier)
14381437
(type_identifier))))))
14391438
body: (block))))

test/corpus/modules.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ module MyFunctor = (X: {type t}, Y: {type t}): {type tx; type ty} => {
240240
return_module_type: (module_type_annotation
241241
(block (type_declaration (type_identifier)) (type_declaration (type_identifier))))
242242
body: (block
243-
(type_declaration (type_identifier) (type_identifier_path (module_identifier_path (module_identifier)) (type_identifier)))
244-
(type_declaration (type_identifier) (type_identifier_path (module_identifier_path (module_identifier)) (type_identifier)))))))
243+
(type_declaration
244+
(type_identifier)
245+
(type_identifier_path (module_identifier) (type_identifier)))
246+
(type_declaration
247+
(type_identifier)
248+
(type_identifier_path (module_identifier) (type_identifier)))))))
245249

246250
===========================================
247251
Functor signature
@@ -405,7 +409,7 @@ external add: (
405409
(function_type
406410
(function_type_parameters
407411
(parameter
408-
(type_identifier_path (module_identifier_path (module_identifier)) (type_identifier)))
412+
(type_identifier_path (module_identifier) (type_identifier)))
409413
(parameter
410414
(decorator (decorator_identifier) (decorator_arguments (template_string)))
411415
(type_identifier))
@@ -434,11 +438,11 @@ external add: (
434438
(polyvar_declaration
435439
(polyvar_identifier)
436440
(polyvar_parameters
437-
(type_identifier_path (module_identifier_path (module_identifier)) (type_identifier))))
441+
(type_identifier_path (module_identifier) (type_identifier))))
438442
(polyvar_declaration
439443
(polyvar_identifier)
440444
(polyvar_parameters
441-
(type_identifier_path (module_identifier_path (module_identifier)) (type_identifier)))))))))
445+
(type_identifier_path (module_identifier) (type_identifier)))))))))
442446
(unit_type)))
443447
(string (string_fragment)))))
444448

test/corpus/type_declarations.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ type t =
171171
(variant_identifier)
172172
(variant_parameters
173173
(module_pack
174-
(type_identifier_path
175-
(module_identifier_path (module_identifier)) (type_identifier))))))))
174+
(type_identifier_path (module_identifier) (type_identifier))))))))
176175

177176
===========================================
178177
Annotated variant

0 commit comments

Comments
 (0)