@@ -1461,7 +1461,7 @@ end
1461
1461
# $a ==> ($ a)
1462
1462
#
1463
1463
# flisp: parse-unary-prefix
1464
- function parse_unary_prefix (ps:: ParseState )
1464
+ function parse_unary_prefix (ps:: ParseState , has_unary_prefix = false )
1465
1465
mark = position (ps)
1466
1466
t = peek_token (ps)
1467
1467
k = kind (t)
@@ -1480,15 +1480,15 @@ function parse_unary_prefix(ps::ParseState)
1480
1480
# $a ==> ($ a)
1481
1481
# $$a ==> ($ ($ a))
1482
1482
# $&a ==> ($ (& a))
1483
- parse_unary_prefix (ps)
1483
+ parse_unary_prefix (ps, true )
1484
1484
end
1485
1485
# Only need PREFIX_OP_FLAG for ::
1486
1486
f = k == K " ::" ? PREFIX_OP_FLAG : EMPTY_FLAGS
1487
1487
emit (ps, mark, k, f)
1488
1488
end
1489
1489
else
1490
1490
# .&(x,y) ==> (call .& x y)
1491
- parse_atom (ps)
1491
+ parse_atom (ps, true , has_unary_prefix )
1492
1492
end
1493
1493
end
1494
1494
@@ -3066,7 +3066,7 @@ end
3066
3066
# *very* overloaded!
3067
3067
#
3068
3068
# flisp: parse-paren / parse-paren-
3069
- function parse_paren (ps:: ParseState , check_identifiers= true )
3069
+ function parse_paren (ps:: ParseState , check_identifiers= true , has_unary_prefix = false )
3070
3070
ps = ParseState (ps, range_colon_enabled= true ,
3071
3071
space_sensitive= false ,
3072
3072
where_enabled= true ,
@@ -3100,7 +3100,7 @@ function parse_paren(ps::ParseState, check_identifiers=true)
3100
3100
opts = parse_brackets (ps, K " )" ) do had_commas, had_splat, num_semis, num_subexprs
3101
3101
is_tuple = had_commas || (had_splat && num_semis >= 1 ) ||
3102
3102
(initial_semi && (num_semis == 1 || num_subexprs > 0 )) ||
3103
- (peek (ps, 2 ) == K " ->" && peek_behind (ps). kind != K " where" )
3103
+ (peek (ps, 2 ) == K " ->" && ( peek_behind (ps). kind != K " where" && ! has_unary_prefix) )
3104
3104
return (needs_parameters= is_tuple,
3105
3105
is_tuple= is_tuple,
3106
3106
is_block= num_semis > 0 )
@@ -3475,7 +3475,7 @@ end
3475
3475
# the syntactic operators or closing tokens.
3476
3476
#
3477
3477
# flisp: parse-atom
3478
- function parse_atom (ps:: ParseState , check_identifiers= true )
3478
+ function parse_atom (ps:: ParseState , check_identifiers= true , has_unary_prefix = false )
3479
3479
bump_trivia (ps)
3480
3480
mark = position (ps)
3481
3481
leading_kind = peek (ps)
@@ -3634,7 +3634,7 @@ function parse_atom(ps::ParseState, check_identifiers=true)
3634
3634
bump (ps, remap_kind= K " Identifier" )
3635
3635
end
3636
3636
elseif leading_kind == K " (" # parens or tuple
3637
- parse_paren (ps, check_identifiers)
3637
+ parse_paren (ps, check_identifiers, has_unary_prefix )
3638
3638
elseif leading_kind == K " [" # cat expression
3639
3639
bump (ps, TRIVIA_FLAG)
3640
3640
ckind, cflags = parse_cat (ps, K " ]" , ps. end_symbol)
0 commit comments