@@ -2374,21 +2374,21 @@ function parse_atsym(ps::ParseState, allow_quotes=true)
2374
2374
# export ($f) ==> (export ($ f))
2375
2375
mark = position (ps)
2376
2376
if allow_quotes && peek (ps) == K " :"
2377
- # import A.:+ ==> (import (. A (quote +)))
2377
+ # import A.:+ ==> (import (importpath A (quote +)))
2378
2378
emit_diagnostic (ps, warning= " quoting with `:` is not required here" )
2379
2379
end
2380
2380
parse_unary_prefix (ps)
2381
2381
pos = position (ps)
2382
2382
warn_parens = false
2383
2383
if peek_behind (ps, pos). kind == K " parens"
2384
- # import A.(:+) ==> (import (. A (parens (quote +))))
2384
+ # import A.(:+) ==> (import (importpath A (parens (quote +))))
2385
2385
pos = first_child_position (ps, pos)
2386
2386
warn_parens = true
2387
2387
end
2388
2388
if allow_quotes && peek_behind (ps, pos). kind == K " quote"
2389
2389
pos = first_child_position (ps, pos)
2390
2390
if peek_behind (ps, pos). kind == K " parens"
2391
- # import A.:(+) ==> (import (. A (quote (parens +))))
2391
+ # import A.:(+) ==> (import (importpath A (quote (parens +))))
2392
2392
pos = first_child_position (ps, pos)
2393
2393
warn_parens = true
2394
2394
end
@@ -2423,22 +2423,22 @@ function parse_imports(ps::ParseState)
2423
2423
bump (ps, TRIVIA_FLAG)
2424
2424
has_import_prefix = true
2425
2425
if initial_as
2426
- # import A as B: x ==> (import (: (error (as (. A) B)) (. x)))
2426
+ # import A as B: x ==> (import (: (error (as (importpath A) B)) (importpath x)))
2427
2427
emit (ps, emark, K " error" , error= " `as` before `:` in import/using" )
2428
2428
end
2429
2429
elseif k == K " ,"
2430
2430
bump (ps, TRIVIA_FLAG)
2431
2431
has_comma = true
2432
2432
end
2433
2433
if has_import_prefix || has_comma
2434
- # import A, y ==> (import (. A) (. y))
2435
- # import A: x, y ==> (import (: (. A) (. x) (. y)))
2436
- # import A: +, == ==> (import (: (. A) (. +) (. ==)))
2434
+ # import A, y ==> (import (importpath A) (importpath y))
2435
+ # import A: x, y ==> (import (: (importpath A) (importpath x) (importpath y)))
2436
+ # import A: +, == ==> (import (: (importpath A) (importpath +) (importpath ==)))
2437
2437
has_import_prefix_ = has_import_prefix
2438
2438
parse_comma_separated (ps, ps1-> parse_import (ps1, word, has_import_prefix_))
2439
2439
if peek (ps) == K " :"
2440
2440
# Error recovery
2441
- # import A: x, B: y ==> (import (: (. A) (. x) (. B) (error-t (. y))))
2441
+ # import A: x, B: y ==> (import (: (importpath A) (importpath x) (importpath B) (error-t (importpath y))))
2442
2442
emark = position (ps)
2443
2443
bump (ps, TRIVIA_FLAG)
2444
2444
parse_comma_separated (ps, ps1-> parse_import (ps1, word, has_import_prefix_))
@@ -2447,11 +2447,11 @@ function parse_imports(ps::ParseState)
2447
2447
end
2448
2448
end
2449
2449
if has_import_prefix
2450
- # import A: x ==> (import (: (. A) (. x)))
2450
+ # import A: x ==> (import (: (importpath A) (importpath x)))
2451
2451
emit (ps, mark, K " :" )
2452
2452
end
2453
- # using A ==> (using (. A))
2454
- # import A ==> (import (. A))
2453
+ # using A ==> (using (importpath A))
2454
+ # import A ==> (import (importpath A))
2455
2455
emit (ps, mark, word)
2456
2456
end
2457
2457
@@ -2461,21 +2461,21 @@ end
2461
2461
function parse_import (ps:: ParseState , word, has_import_prefix)
2462
2462
mark = position (ps)
2463
2463
parse_import_path (ps)
2464
- # import A: x, y ==> (import (: (. A) (. x) (. y)))
2464
+ # import A: x, y ==> (import (: (importpath A) (importpath x) (importpath y)))
2465
2465
if peek (ps) == K " as"
2466
- # import A as B ==> (import (as (. A) B))
2467
- # import A: x as y ==> (import (: (. A) (as (. x) y)))
2468
- # using A: x as y ==> (using (: (. A) (as (. x) y)))
2466
+ # import A as B ==> (import (as (importpath A) B))
2467
+ # import A: x as y ==> (import (: (importpath A) (as (importpath x) y)))
2468
+ # using A: x as y ==> (using (: (importpath A) (as (importpath x) y)))
2469
2469
bump (ps, TRIVIA_FLAG)
2470
2470
parse_atsym (ps)
2471
2471
emit (ps, mark, K " as" )
2472
2472
if word == K " using" && ! has_import_prefix
2473
- # using A as B ==> (using (error (as (. A) B)))
2474
- # using A, B as C ==> (using (. A) (error (as (. B) C)))
2473
+ # using A as B ==> (using (error (as (importpath A) B)))
2474
+ # using A, B as C ==> (using (importpath A) (error (as (importpath B) C)))
2475
2475
emit (ps, mark, K " error" ,
2476
2476
error= " `using` with `as` renaming requires a `:` and context module" )
2477
2477
end
2478
- # v1.5: import A as B ==> (import (error (as (. A) B)))
2478
+ # v1.5: import A as B ==> (import (error (as (importpath A) B)))
2479
2479
min_supported_version (v " 1.6" , ps, mark, " `import ... as`" )
2480
2480
return true
2481
2481
else
@@ -2489,12 +2489,12 @@ function parse_import_path(ps::ParseState)
2489
2489
bump_trivia (ps)
2490
2490
# The tokenizer produces conjoined dotted tokens .. and ...
2491
2491
# When parsing import we must split these into single dots
2492
- # import .A ==> (import (. . A))
2493
- # import ..A ==> (import (. . . A))
2494
- # import ...A ==> (import (. . . . A))
2495
- # import ....A ==> (import (. . . . . A))
2492
+ # import .A ==> (import (importpath . A))
2493
+ # import ..A ==> (import (importpath . . A))
2494
+ # import ...A ==> (import (importpath . . . A))
2495
+ # import ....A ==> (import (importpath . . . . A))
2496
2496
# Dots with spaces are allowed (a misfeature?)
2497
- # import . .A ==> (import (. . . A))
2497
+ # import . .A ==> (import (importpath . . A))
2498
2498
first_dot = true
2499
2499
while true
2500
2500
t = peek_token (ps)
@@ -2516,50 +2516,50 @@ function parse_import_path(ps::ParseState)
2516
2516
end
2517
2517
if is_dotted (peek_token (ps))
2518
2518
# Modules with operator symbol names
2519
- # import .⋆ ==> (import (. . ⋆))
2519
+ # import .⋆ ==> (import (importpath . ⋆))
2520
2520
bump_trivia (ps)
2521
2521
bump_split (ps, (1 ,K " ." ,EMPTY_FLAGS), (1 ,peek (ps),EMPTY_FLAGS))
2522
2522
else
2523
- # import @x ==> (import (. @x))
2524
- # import $A ==> (import (. ($ A)))
2523
+ # import @x ==> (import (importpath @x))
2524
+ # import $A ==> (import (importpath ($ A)))
2525
2525
parse_atsym (ps)
2526
2526
end
2527
2527
while true
2528
2528
t = peek_token (ps)
2529
2529
k = kind (t)
2530
2530
if k == K " ."
2531
- # import A.B ==> (import (. A B))
2532
- # import $A.@x ==> (import (. ($ A) @x))
2533
- # import A.B.C ==> (import (. A B C))
2531
+ # import A.B ==> (import (importpath A B))
2532
+ # import $A.@x ==> (import (importpath ($ A) @x))
2533
+ # import A.B.C ==> (import (importpath A B C))
2534
2534
bump_disallowed_space (ps)
2535
2535
bump (ps, TRIVIA_FLAG)
2536
2536
parse_atsym (ps)
2537
2537
elseif is_dotted (t)
2538
2538
# Resolve tokenization ambiguity: In imports, dots are part of the
2539
2539
# path, not operators
2540
- # import A.== ==> (import (. A ==))
2541
- # import A.⋆.f ==> (import (. A ⋆ f))
2540
+ # import A.== ==> (import (importpath A ==))
2541
+ # import A.⋆.f ==> (import (importpath A ⋆ f))
2542
2542
if preceding_whitespace (t)
2543
2543
# Whitespace in import path allowed but discouraged
2544
- # import A .== ==> (import (. A ==))
2544
+ # import A .== ==> (import (importpath A ==))
2545
2545
emit_diagnostic (ps, whitespace= true ,
2546
2546
warning= " space between dots in import path" )
2547
2547
end
2548
2548
bump_trivia (ps)
2549
2549
bump_split (ps, (1 ,K " ." ,TRIVIA_FLAG), (1 ,k,EMPTY_FLAGS))
2550
2550
elseif k == K " ..."
2551
2551
# Import the .. operator
2552
- # import A... ==> (import (. A ..))
2552
+ # import A... ==> (import (importpath A ..))
2553
2553
bump_split (ps, (1 ,K " ." ,TRIVIA_FLAG), (2 ,K " .." ,EMPTY_FLAGS))
2554
2554
elseif k in KSet " NewlineWs ; , : EndMarker"
2555
- # import A; B ==> (import (. A))
2555
+ # import A; B ==> (import (importpath A))
2556
2556
break
2557
2557
else
2558
2558
# Could we emit a more comprehensible error here?
2559
2559
break
2560
2560
end
2561
2561
end
2562
- emit (ps, mark, K ". " )
2562
+ emit (ps, mark, K "importpath " )
2563
2563
end
2564
2564
2565
2565
# parse comma-separated assignments, like "i=1:n,j=1:m,..."
0 commit comments