@@ -544,7 +544,7 @@ function parse_assignment_with_initial_ex(ps::ParseState, mark, down::T) where {
544
544
if k == K " ~"
545
545
if ps. space_sensitive && ! preceding_whitespace (peek_token (ps, 2 ))
546
546
# Unary ~ in space sensitive context is not assignment precedence
547
- # [a ~b] ==> (hcat a (call ~ b))
547
+ # [a ~b] ==> (hcat a (call-pre ~ b))
548
548
return
549
549
end
550
550
# ~ is the only non-syntactic assignment-precedence operator.
@@ -885,8 +885,8 @@ function parse_with_chains(ps::ParseState, down, is_op, chain_ops)
885
885
is_both_unary_and_binary (t) &&
886
886
! preceding_whitespace (peek_token (ps, 2 ))
887
887
# The following is two elements of a hcat
888
- # [x +y] ==> (hcat x (call + y))
889
- # [x+y +z] ==> (hcat (call-i x + y) (call + z))
888
+ # [x +y] ==> (hcat x (call-pre + y))
889
+ # [x+y +z] ==> (hcat (call-i x + y) (call-pre + z))
890
890
# Conversely the following are infix calls
891
891
# [x +₁y] ==> (vect (call-i x +₁ y))
892
892
# [x+y+z] ==> (vect (call-i x + y z))
@@ -914,7 +914,7 @@ function parse_chain(ps::ParseState, down, op_kind)
914
914
if ps. space_sensitive && preceding_whitespace (t) &&
915
915
is_both_unary_and_binary (t) &&
916
916
! preceding_whitespace (peek_token (ps, 2 ))
917
- # [x +y] ==> (hcat x (call + y))
917
+ # [x +y] ==> (hcat x (call-pre + y))
918
918
break
919
919
end
920
920
bump (ps, TRIVIA_FLAG)
@@ -948,16 +948,16 @@ function parse_unary_subtype(ps::ParseState)
948
948
elseif k2 in KSet " { ("
949
949
# parse <:{T}(x::T) or <:(x::T) like other unary operators
950
950
# <:{T}(x::T) ==> (call (curly <: T) (:: x T))
951
- # <:(x::T) ==> (<: (:: x T))
951
+ # <:(x::T) ==> (<:-pre (:: x T))
952
952
parse_where (ps, parse_juxtapose)
953
953
else
954
- # <: A where B ==> (<: (where A B))
954
+ # <: A where B ==> (<:-pre (where A B))
955
955
mark = position (ps)
956
956
bump (ps, TRIVIA_FLAG)
957
957
parse_where (ps, parse_juxtapose)
958
958
# Flisp parser handled this, but I don't know how it can happen...
959
959
@check peek_behind (ps). kind != K " tuple"
960
- emit (ps, mark, k)
960
+ emit (ps, mark, k, PREFIX_OP_FLAG )
961
961
end
962
962
else
963
963
parse_where (ps, parse_juxtapose)
@@ -1015,7 +1015,7 @@ function is_juxtapose(ps, prev_k, t)
1015
1015
# Not juxtaposition - parse_juxtapose will consume only the first token.
1016
1016
# x.3 ==> x
1017
1017
# sqrt(2)2 ==> (call sqrt 2)
1018
- # x' y ==> x
1018
+ # x' y ==> (call-post x ')
1019
1019
# x 'y ==> x
1020
1020
1021
1021
return ! preceding_whitespace (t) &&
@@ -1039,7 +1039,7 @@ end
1039
1039
# 2(x) ==> (call-i 2 * x)
1040
1040
# (2)(3)x ==> (call-i 2 * 3 x)
1041
1041
# (x-1)y ==> (call-i (call-i x - 1) * y)
1042
- # x'y ==> x
1042
+ # x'y ==> (call-i (call-post x ') * y)
1043
1043
#
1044
1044
# flisp: parse-juxtapose
1045
1045
function parse_juxtapose (ps:: ParseState )
@@ -1098,11 +1098,11 @@ function parse_unary(ps::ParseState)
1098
1098
if is_prec_power (k3) || k3 in KSet " [ {"
1099
1099
# `[`, `{` (issue #18851) and `^` have higher precedence than
1100
1100
# unary negation
1101
- # -2^x ==> (call - (call-i 2 ^ x))
1102
- # -2[1, 3] ==> (call - (ref 2 1 3))
1101
+ # -2^x ==> (call-pre - (call-i 2 ^ x))
1102
+ # -2[1, 3] ==> (call-pre - (ref 2 1 3))
1103
1103
bump (ps)
1104
1104
parse_factor (ps)
1105
- emit (ps, mark, K " call" )
1105
+ emit (ps, mark, K " call" , PREFIX_OP_FLAG )
1106
1106
else
1107
1107
# We have a signed numeric literal. Glue the operator to the
1108
1108
# next token to create a signed literal:
@@ -1115,17 +1115,17 @@ function parse_unary(ps::ParseState)
1115
1115
end
1116
1116
end
1117
1117
# Things which are not quite negative literals result in a unary call instead
1118
- # -0x1 ==> (call - 0x01)
1119
- # - 2 ==> (call - 2)
1120
- # .-2 ==> (call .- 2)
1118
+ # -0x1 ==> (call-pre - 0x01)
1119
+ # - 2 ==> (call-pre - 2)
1120
+ # .-2 ==> (call-pre .- 2)
1121
1121
parse_unary_call (ps)
1122
1122
end
1123
1123
1124
1124
# Parse calls to unary operators and prefix calls involving arbitrary operators
1125
1125
# with bracketed arglists (as opposed to infix notation)
1126
1126
#
1127
- # +a ==> (call + a)
1128
- # +(a,b) ==> (call + a b)
1127
+ # +a ==> (call-pre + a)
1128
+ # +(a,b) ==> (call-pre + a b)
1129
1129
#
1130
1130
# flisp: parse-unary-call
1131
1131
function parse_unary_call (ps:: ParseState )
@@ -1208,33 +1208,33 @@ function parse_unary_call(ps::ParseState)
1208
1208
else
1209
1209
# Unary function calls with brackets as grouping, not an arglist
1210
1210
if opts. is_block
1211
- # +(a;b) ==> (call + (block a b))
1211
+ # +(a;b) ==> (call-pre + (block a b))
1212
1212
emit (ps, mark_before_paren, K " block" )
1213
1213
end
1214
1214
# Not a prefix operator call but a block; `=` is not `kw`
1215
- # +(a=1) ==> (call + (= a 1))
1215
+ # +(a=1) ==> (call-pre + (= a 1))
1216
1216
# Unary operators have lower precedence than ^
1217
- # +(a)^2 ==> (call + (call-i a ^ 2))
1218
- # +(a)(x,y)^2 ==> (call + (call-i (call a x y) ^ 2))
1217
+ # +(a)^2 ==> (call-pre + (call-i a ^ 2))
1218
+ # +(a)(x,y)^2 ==> (call-pre + (call-i (call a x y) ^ 2))
1219
1219
parse_call_chain (ps, mark_before_paren)
1220
1220
parse_factor_with_initial_ex (ps, mark_before_paren)
1221
- emit (ps, mark, op_node_kind)
1221
+ emit (ps, mark, op_node_kind, PREFIX_OP_FLAG )
1222
1222
end
1223
1223
else
1224
1224
if is_unary_op (op_t)
1225
1225
# Normal unary calls
1226
- # +x ==> (call + x)
1227
- # √x ==> (call √ x)
1228
- # ±x ==> (call ± x)
1226
+ # +x ==> (call-pre + x)
1227
+ # √x ==> (call-pre √ x)
1228
+ # ±x ==> (call-pre ± x)
1229
1229
bump (ps, op_tok_flags)
1230
1230
else
1231
- # /x ==> (call (error /) x)
1232
- # +₁ x ==> (call (error +₁) x)
1233
- # .<: x ==> (call (error .<:) x)
1231
+ # /x ==> (call-pre (error /) x)
1232
+ # +₁ x ==> (call-pre (error +₁) x)
1233
+ # .<: x ==> (call-pre (error .<:) x)
1234
1234
bump (ps, error= " not a unary operator" )
1235
1235
end
1236
1236
parse_unary (ps)
1237
- emit (ps, mark, op_node_kind)
1237
+ emit (ps, mark, op_node_kind, PREFIX_OP_FLAG )
1238
1238
end
1239
1239
end
1240
1240
@@ -1433,6 +1433,8 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1433
1433
finish_macroname (ps, mark, valid_macroname, macro_name_position)
1434
1434
end
1435
1435
# f(a,b) ==> (call f a b)
1436
+ # f(a; b=1) ==> (call f a (parameters (b 1)))
1437
+ # (a=1)() ==> (call (= a 1))
1436
1438
# f (a) ==> (call f (error-t) a b)
1437
1439
bump_disallowed_space (ps)
1438
1440
bump (ps, TRIVIA_FLAG)
@@ -1457,6 +1459,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1457
1459
K " ]" , ps. end_symbol)
1458
1460
# a[i] ==> (ref a i)
1459
1461
# a[i,j] ==> (ref a i j)
1462
+ # (a=1)[] ==> (ref (= a 1))
1460
1463
# T[x y] ==> (typed_hcat T x y)
1461
1464
# T[x ; y] ==> (typed_vcat T x y)
1462
1465
# T[a b; c d] ==> (typed_vcat T (row a b) (row c d))
@@ -1562,15 +1565,10 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1562
1565
this_iter_valid_macroname = true
1563
1566
end
1564
1567
elseif k == K " '" && ! preceding_whitespace (t)
1565
- if ! is_suffixed (t)
1566
- # f' ==> (' f)
1567
- bump (ps, TRIVIA_FLAG)
1568
- emit (ps, mark, k)
1569
- else
1570
- # f'ᵀ ==> (call 'ᵀ f)
1571
- bump (ps)
1572
- emit (ps, mark, K " call" , INFIX_FLAG)
1573
- end
1568
+ # f' ==> (call-post f ')
1569
+ # f'ᵀ ==> (call-post f 'ᵀ)
1570
+ bump (ps)
1571
+ emit (ps, mark, K " call" , POSTFIX_OP_FLAG)
1574
1572
elseif k == K " {"
1575
1573
# Type parameter curlies and macro calls
1576
1574
if is_macrocall
0 commit comments