Skip to content

Commit 49e5c29

Browse files
committed
Support mod idents <A.B />
1 parent 6d0da78 commit 49e5c29

File tree

7 files changed

+7011
-6774
lines changed

7 files changed

+7011
-6774
lines changed

mlx/parser.ml

Lines changed: 2382 additions & 2278 deletions
Large diffs are not rendered by default.

mlx/parser.mly

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,6 +3660,13 @@ mk_longident(prefix,final):
36603660
jsx_longident(uident, lident):
36613661
| id = uident { `Module, $sloc, Lident id }
36623662
| id = lident { `Value, $sloc, Lident id }
3663+
| prefix = uident DOT id = mod_longident {
3664+
let rec rebase = function
3665+
| Lident id -> Ldot (Lident prefix, id)
3666+
| Ldot (prefix', id) -> Ldot (rebase prefix', id)
3667+
| Lapply _ -> assert false
3668+
in
3669+
`Module, $sloc, rebase id }
36633670
| prefix = uident DOT id = val_longident {
36643671
let rec rebase = function
36653672
| Lident id -> Ldot (Lident prefix, id)
1.01 KB
Binary file not shown.

ocamlmerlin_mlx/preprocess/parser_raw.ml

Lines changed: 2247 additions & 2143 deletions
Large diffs are not rendered by default.

ocamlmerlin_mlx/preprocess/parser_raw.mly

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,6 +3846,13 @@ val_longident:
38463846
jsx_longident(uident, lident):
38473847
| id = uident { `Module, $sloc, Lident id }
38483848
| id = lident { `Value, $sloc, Lident id }
3849+
| prefix = uident DOT id = mod_longident {
3850+
let rec rebase = function
3851+
| Lident id -> Ldot (Lident prefix, id)
3852+
| Ldot (prefix', id) -> Ldot (rebase prefix', id)
3853+
| Lapply _ -> assert false
3854+
in
3855+
`Module, $sloc, rebase id }
38493856
| prefix = uident DOT id = val_longident {
38503857
let rec rebase = function
38513858
| Lident id -> Ldot (Lident prefix, id)

ocamlmerlin_mlx/preprocess/parser_recover.ml

Lines changed: 2344 additions & 2353 deletions
Large diffs are not rendered by default.

test/mlx.t

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,36 @@
2323
MERLIN
2424
let _ = Hello.createElement () ~children:[] ~attr ~with_value:1 [@JSX]
2525

26+
$ echo 'let _ = <Hello.ok attr with_value=1 />' | ./mlx
27+
BATCH
28+
let _ = Hello.ok () ~children:[] ~attr ~with_value:1 [@JSX]
29+
MERLIN
30+
let _ = Hello.ok () ~children:[] ~attr ~with_value:1 [@JSX]
31+
32+
$ echo 'let _ = <Hello.Ok attr with_value=1 />' | ./mlx
33+
BATCH
34+
let _ = Hello.Ok.createElement () ~children:[] ~attr ~with_value:1 [@JSX]
35+
MERLIN
36+
let _ = Hello.Ok.createElement () ~children:[] ~attr ~with_value:1 [@JSX]
37+
2638
$ echo 'let _ = <Hello>world</Hello>' | ./mlx
2739
BATCH
2840
let _ = Hello.createElement () ~children:[ world ] [@JSX]
2941
MERLIN
3042
let _ = Hello.createElement () ~children:[ world ] [@JSX]
3143

44+
$ echo 'let _ = <Hello.ok>world</Hello.ok>' | ./mlx
45+
BATCH
46+
let _ = Hello.ok () ~children:[ world ] [@JSX]
47+
MERLIN
48+
let _ = Hello.ok () ~children:[ world ] [@JSX]
49+
50+
$ echo 'let _ = <Hello.Ok>world</Hello.Ok>' | ./mlx
51+
BATCH
52+
let _ = Hello.Ok.createElement () ~children:[ world ] [@JSX]
53+
MERLIN
54+
let _ = Hello.Ok.createElement () ~children:[ world ] [@JSX]
55+
3256
$ echo 'let _ = <one>world</two>' | ./mlx
3357
BATCH
3458
File "*stdin*", line 1, characters 18-24:

0 commit comments

Comments
 (0)