@@ -113,6 +113,10 @@ function Base.position(ps::ParseState, args...)
113
113
position (ps. stream, args... )
114
114
end
115
115
116
+ function next_position (ps:: ParseState , args... )
117
+ next_position (ps. stream, args... )
118
+ end
119
+
116
120
function emit (ps:: ParseState , args... ; kws... )
117
121
emit (ps. stream, args... ; kws... )
118
122
end
@@ -1232,11 +1236,15 @@ function parse_unary(ps::ParseState)
1232
1236
# last case wrong)
1233
1237
op_pos = bump_dotsplit (ps, emit_dot_node= true )
1234
1238
1235
- # Setup possible whitespace error between operator and (
1236
- ws_mark = position (ps)
1237
- bump_trivia (ps)
1238
- ws_mark_end = position (ps)
1239
- ws_error_pos = emit (ps, ws_mark, K " TOMBSTONE" )
1239
+ space_before_paren = preceding_whitespace (t2)
1240
+ if space_before_paren
1241
+ # Setup possible whitespace error between operator and (
1242
+ ws_node_mark = position (ps)
1243
+ ws_mark = next_position (ps)
1244
+ bump_trivia (ps)
1245
+ ws_error_pos = emit (ps, ws_node_mark, K " TOMBSTONE" )
1246
+ ws_mark_end = next_position (ps)
1247
+ end
1240
1248
1241
1249
mark_before_paren = position (ps)
1242
1250
bump (ps, TRIVIA_FLAG) # (
@@ -1251,7 +1259,7 @@ function parse_unary(ps::ParseState)
1251
1259
# The precedence between unary + and any following infix ^ depends on
1252
1260
# whether the parens are a function call or not
1253
1261
if opts. is_paren_call
1254
- if preceding_whitespace (t2)
1262
+ if space_before_paren
1255
1263
# Whitespace not allowed before prefix function call bracket
1256
1264
# + (a,b) ==> (call + (error) a b)
1257
1265
reset_node! (ps, ws_error_pos, kind= K " error" )
@@ -1592,7 +1600,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1592
1600
# A.B.@x ==> (macrocall (. (. A (quote B)) (quote @x)))
1593
1601
# @A.B.x ==> (macrocall (. (. A (quote B)) (quote @x)))
1594
1602
# [email protected] ==> (macrocall (. (. A (error-t) B) (quote @x)))
1595
- emit_diagnostic (ps, macro_atname_range,
1603
+ emit_diagnostic (ps, macro_atname_range... ,
1596
1604
error= " `@` must appear on first or last macro name component" )
1597
1605
bump (ps, TRIVIA_FLAG, error= " Unexpected `.` after macro name" )
1598
1606
else
@@ -1646,7 +1654,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1646
1654
end
1647
1655
parse_macro_name (ps)
1648
1656
macro_name_position = position (ps)
1649
- macro_atname_range = (m, macro_name_position )
1657
+ macro_atname_range = (m, next_position (ps) )
1650
1658
emit (ps, m, K " quote" )
1651
1659
emit (ps, mark, K " ." )
1652
1660
elseif k == K " '"
@@ -2484,10 +2492,12 @@ function parse_import_path(ps::ParseState)
2484
2492
# import . .A ==> (import (. . . A))
2485
2493
first_dot = true
2486
2494
while true
2487
- m = position (ps)
2488
- bump_trivia (ps)
2489
- m2 = position (ps)
2490
- k = peek (ps)
2495
+ t = peek_token (ps)
2496
+ k = kind (t)
2497
+ if ! first_dot && preceding_whitespace (t)
2498
+ emit_diagnostic (ps, whitespace= true ,
2499
+ warning= " space between dots in import path" )
2500
+ end
2491
2501
if k == K " ."
2492
2502
bump (ps)
2493
2503
elseif k == K " .."
@@ -2497,9 +2507,6 @@ function parse_import_path(ps::ParseState)
2497
2507
else
2498
2508
break
2499
2509
end
2500
- if ! first_dot && m != m2
2501
- emit_diagnostic (ps, m, m2, warning= " space between dots in import path" )
2502
- end
2503
2510
first_dot = false
2504
2511
end
2505
2512
if is_dotted (peek_token (ps))
0 commit comments