Skip to content

Commit 16e97b5

Browse files
committed
feat: revert/unnest module_identifier_path for simplest cases
1 parent d3d6d5e commit 16e97b5

File tree

6 files changed

+27
-36
lines changed

6 files changed

+27
-36
lines changed

grammar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = grammar({
5050
],
5151
[$._jsx_attribute_value, $.pipe_expression],
5252
[$.function_type_parameters, $.function_type],
53+
[$.module_expression, $.module_identifier_path],
5354
[$.module_identifier_path, $.module_type_of],
5455
],
5556

@@ -1240,6 +1241,7 @@ module.exports = grammar({
12401241
),
12411242

12421243
module_expression: $ => choice(
1244+
$.module_identifier,
12431245
$.module_identifier_path,
12441246
$.type_identifier_path,
12451247
$.module_type_of,

test/corpus/expressions.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ f(raise)
165165
arguments: (arguments
166166
(number)
167167
(block
168-
(open_statement (module_identifier_path (module_identifier)))
168+
(open_statement (module_identifier))
169169
(expression_statement (value_identifier)))
170170
(labeled_argument
171171
label: (value_identifier)
@@ -247,7 +247,7 @@ foo->{
247247
(pipe_expression
248248
(value_identifier)
249249
(block
250-
(open_statement (module_identifier_path (module_identifier)))
250+
(open_statement (module_identifier))
251251
(expression_statement (value_identifier))))))
252252

253253
===========================================
@@ -821,7 +821,7 @@ switch { open Mod; foo() } {
821821
(expression_statement
822822
(switch_expression
823823
(block
824-
(open_statement (module_identifier_path (module_identifier)))
824+
(open_statement (module_identifier))
825825
(expression_statement
826826
(call_expression (value_identifier) (arguments))))
827827
(switch_match

test/corpus/jsx.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ Attribute Block
209209
(jsx_attribute
210210
(property_identifier)
211211
(jsx_expression
212-
(open_statement
213-
(module_identifier_path (module_identifier)))
212+
(open_statement (module_identifier))
214213
(expression_statement
215214
(record
216215
(record_field

test/corpus/let_bindings.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ let {baz, _} = module(User.Inner)
296296
(record_pattern
297297
(value_identifier)
298298
(value_identifier))
299-
(module_pack
300-
(module_identifier_path
301-
(module_identifier))))
299+
(module_pack (module_identifier)))
302300
(let_binding
303301
(record_pattern
304302
(value_identifier)
@@ -320,7 +318,7 @@ let foo = module(Bar)
320318
(source_file
321319
(let_binding
322320
(value_identifier)
323-
(module_pack (module_identifier_path (module_identifier)))))
321+
(module_pack (module_identifier))))
324322

325323
===========================================
326324
Unpacking module

test/corpus/modules.txt

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ open! Foo.Bar
88
---
99

1010
(source_file
11-
(open_statement
12-
(module_identifier_path (module_identifier)))
11+
(open_statement (module_identifier))
1312
(open_statement
1413
(module_identifier_path
1514
(module_identifier_path
@@ -38,9 +37,7 @@ include module type of {
3837
---
3938

4039
(source_file
41-
(include_statement
42-
(module_identifier_path
43-
(module_identifier)))
40+
(include_statement (module_identifier))
4441
(include_statement
4542
(module_identifier_path
4643
(module_identifier_path
@@ -52,7 +49,7 @@ include module type of {
5249
(module_identifier_path
5350
(module_identifier))
5451
(module_identifier))
55-
(arguments (module_identifier_path (module_identifier)))))
52+
(arguments (module_identifier))))
5653
(include_statement
5754
(functor_use
5855
(module_identifier_path
@@ -98,9 +95,7 @@ include module type of {
9895

9996
(include_statement
10097
(module_type_of
101-
(block
102-
(include_statement
103-
(module_identifier_path (module_identifier)))))))
98+
(block (include_statement (module_identifier))))))
10499

105100
===========================================
106101
Simple definition
@@ -199,19 +194,19 @@ module(SomeFunctor(unpack(x)))
199194

200195
(source_file
201196
(expression_statement
202-
(module_pack (module_identifier_path (module_identifier))))
197+
(module_pack (module_identifier)))
203198
(expression_statement
204199
(module_pack
205-
(module_identifier_path (module_identifier))
206-
(module_type_annotation (module_identifier_path (module_identifier)))))
200+
(module_identifier)
201+
(module_type_annotation (module_identifier))))
207202
(expression_statement
208203
(module_pack
209204
(block
210205
(type_declaration (type_identifier))
211206
(let_binding
212207
(value_identifier)
213208
(string (string_fragment))))
214-
(module_type_annotation (module_identifier_path (module_identifier)))))
209+
(module_type_annotation (module_identifier))))
215210
(expression_statement
216211
(module_pack
217212
(functor_use
@@ -264,7 +259,9 @@ module Make: (Content: StaticContent) => {
264259
(module_identifier)
265260
(functor
266261
(functor_parameters
267-
(functor_parameter (module_identifier_path (module_identifier)) (module_type_annotation (module_identifier_path (module_identifier)))))
262+
(functor_parameter
263+
(module_identifier_path (module_identifier))
264+
(module_type_annotation (module_identifier))))
268265
(block
269266
(let_binding
270267
(value_identifier)
@@ -285,8 +282,7 @@ module M = MyFunctor(Foo, Bar.Baz)
285282
(functor_use
286283
(module_identifier_path (module_identifier))
287284
(arguments
288-
(module_identifier_path
289-
(module_identifier))
285+
(module_identifier)
290286
(module_identifier_path
291287
(module_identifier_path
292288
(module_identifier))
@@ -324,9 +320,8 @@ module rec BYOBReader: {
324320
(module_declaration
325321
(module_identifier)
326322
(block
327-
(include_statement
328-
(module_identifier_path (module_identifier))))
329-
(module_identifier_path (module_identifier))))
323+
(include_statement (module_identifier)))
324+
(module_identifier)))
330325

331326
===========================================
332327
Definition through extension
@@ -502,7 +497,7 @@ module M = (Na: N, Nb: N): (
502497
(source_file
503498
(expression_statement
504499
(module_pack
505-
(module_identifier_path (module_identifier))
500+
(module_identifier)
506501
(module_type_annotation
507502
(module_type_constraint
508503
(module_identifier_path (module_identifier))
@@ -519,7 +514,7 @@ module M = (Na: N, Nb: N): (
519514
(functor_parameters)
520515
(module_type_annotation
521516
(module_type_constraint
522-
(module_identifier_path (module_identifier))
517+
(module_identifier_path (module_identifier))
523518
(constrain_type
524519
(type_identifier)
525520
(type_identifier))))
@@ -531,12 +526,10 @@ module M = (Na: N, Nb: N): (
531526
(functor_parameters
532527
(functor_parameter
533528
(module_identifier_path (module_identifier))
534-
(module_type_annotation
535-
(module_identifier_path (module_identifier))))
529+
(module_type_annotation (module_identifier)))
536530
(functor_parameter
537531
(module_identifier_path (module_identifier))
538-
(module_type_annotation
539-
(module_identifier_path (module_identifier)))))
532+
(module_type_annotation (module_identifier))))
540533
(module_type_annotation
541534
(module_type_constraint
542535
(module_identifier_path (module_identifier))

test/corpus/type_declarations.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ type t =
166166
(variant_declaration
167167
(variant_identifier)
168168
(variant_parameters
169-
(module_pack
170-
(module_identifier_path (module_identifier)))))
169+
(module_pack (module_identifier))))
171170
(variant_declaration
172171
(variant_identifier)
173172
(variant_parameters

0 commit comments

Comments
 (0)