@@ -1461,7 +1461,7 @@ end
14611461# $a ==> ($ a)
14621462#
14631463# flisp: parse-unary-prefix
1464- function parse_unary_prefix (ps:: ParseState )
1464+ function parse_unary_prefix (ps:: ParseState , has_unary_prefix = false )
14651465 mark = position (ps)
14661466 t = peek_token (ps)
14671467 k = kind (t)
@@ -1480,15 +1480,15 @@ function parse_unary_prefix(ps::ParseState)
14801480 # $a ==> ($ a)
14811481 # $$a ==> ($ ($ a))
14821482 # $&a ==> ($ (& a))
1483- parse_unary_prefix (ps)
1483+ parse_unary_prefix (ps, true )
14841484 end
14851485 # Only need PREFIX_OP_FLAG for ::
14861486 f = k == K " ::" ? PREFIX_OP_FLAG : EMPTY_FLAGS
14871487 emit (ps, mark, k, f)
14881488 end
14891489 else
14901490 # .&(x,y) ==> (call .& x y)
1491- parse_atom (ps)
1491+ parse_atom (ps, true , has_unary_prefix )
14921492 end
14931493end
14941494
@@ -3066,7 +3066,7 @@ end
30663066# *very* overloaded!
30673067#
30683068# 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 )
30703070 ps = ParseState (ps, range_colon_enabled= true ,
30713071 space_sensitive= false ,
30723072 where_enabled= true ,
@@ -3100,7 +3100,7 @@ function parse_paren(ps::ParseState, check_identifiers=true)
31003100 opts = parse_brackets (ps, K " )" ) do had_commas, had_splat, num_semis, num_subexprs
31013101 is_tuple = had_commas || (had_splat && num_semis >= 1 ) ||
31023102 (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) )
31043104 return (needs_parameters= is_tuple,
31053105 is_tuple= is_tuple,
31063106 is_block= num_semis > 0 )
@@ -3475,7 +3475,7 @@ end
34753475# the syntactic operators or closing tokens.
34763476#
34773477# 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 )
34793479 bump_trivia (ps)
34803480 mark = position (ps)
34813481 leading_kind = peek (ps)
@@ -3634,7 +3634,7 @@ function parse_atom(ps::ParseState, check_identifiers=true)
36343634 bump (ps, remap_kind= K " Identifier" )
36353635 end
36363636 elseif leading_kind == K " (" # parens or tuple
3637- parse_paren (ps, check_identifiers)
3637+ parse_paren (ps, check_identifiers, has_unary_prefix )
36383638 elseif leading_kind == K " [" # cat expression
36393639 bump (ps, TRIVIA_FLAG)
36403640 ckind, cflags = parse_cat (ps, K " ]" , ps. end_symbol)
0 commit comments