@@ -1098,8 +1098,8 @@ function parse_where_chain(ps0::ParseState, mark)
1098
1098
# x where {y for y in ys} ==> (where x (braces (generator y (iteration (in y ys)))))
1099
1099
m = position (ps)
1100
1100
bump (ps, TRIVIA_FLAG)
1101
- ckind, cflags = parse_cat (ps, K " }" , ps. end_symbol)
1102
- emit_braces (ps, m, ckind, cflags)
1101
+ ckind, cflags, dim = parse_cat (ps, K " }" , ps. end_symbol)
1102
+ emit_braces (ps, m, ckind, cflags, dim )
1103
1103
emit (ps, mark, K " where" )
1104
1104
else
1105
1105
# x where T ==> (where x T)
@@ -1589,7 +1589,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1589
1589
# a [i] ==> (ref a (error-t) i)
1590
1590
bump_disallowed_space (ps)
1591
1591
bump (ps, TRIVIA_FLAG)
1592
- ckind, cflags = parse_cat (ParseState (ps, end_symbol= true ),
1592
+ ckind, cflags, dim = parse_cat (ParseState (ps, end_symbol= true ),
1593
1593
K " ]" , ps. end_symbol)
1594
1594
if is_macrocall
1595
1595
# @S[a,b] ==> (macrocall @S (vect a b))
@@ -1600,7 +1600,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1600
1600
# v1.7: @S[a ;; b] ==> (macrocall @S (ncat-2 a b))
1601
1601
# v1.6: @S[a ;; b] ==> (macrocall @S (error (ncat-2 a b)))
1602
1602
fix_macro_name_kind! (ps, macro_name_position)
1603
- emit (ps, m, ckind, cflags)
1603
+ emit (ps, m, ckind, cflags | set_numeric_flags (dim) )
1604
1604
check_ncat_compat (ps, m, ckind)
1605
1605
emit (ps, mark, K " macrocall" )
1606
1606
is_macrocall = false
@@ -1621,7 +1621,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
1621
1621
ckind == K " comprehension" ? K " typed_comprehension" :
1622
1622
ckind == K " ncat" ? K " typed_ncat" :
1623
1623
internal_error (" unrecognized kind in parse_cat " , string (ckind))
1624
- emit (ps, mark, outk, cflags)
1624
+ emit (ps, mark, outk, cflags | set_numeric_flags (dim) )
1625
1625
check_ncat_compat (ps, mark, ckind)
1626
1626
end
1627
1627
elseif k == K " ."
@@ -2840,7 +2840,7 @@ function parse_array(ps::ParseState, mark, closer, end_is_symbol)
2840
2840
if binding_power == typemin (Int)
2841
2841
# [x@y ==> (hcat x (error-t ✘ y))
2842
2842
bump_closing_token (ps, closer)
2843
- return (K " hcat" , EMPTY_FLAGS )
2843
+ return (K " hcat" , 0 )
2844
2844
end
2845
2845
while true
2846
2846
(next_dim, next_bp) = parse_array_inner (ps, binding_power, array_order)
@@ -2856,9 +2856,9 @@ function parse_array(ps::ParseState, mark, closer, end_is_symbol)
2856
2856
binding_power = next_bp
2857
2857
end
2858
2858
bump_closing_token (ps, closer)
2859
- return binding_power == - 1 ? (K " vcat" , EMPTY_FLAGS ) :
2860
- binding_power == 0 ? (K " hcat" , EMPTY_FLAGS ) :
2861
- (K " ncat" , set_numeric_flags ( dim) )
2859
+ return binding_power == - 1 ? (K " vcat" , 0 ) :
2860
+ binding_power == 0 ? (K " hcat" , 0 ) :
2861
+ (K " ncat" , dim)
2862
2862
end
2863
2863
2864
2864
# Parse equal and ascending precedence chains of array concatenation operators -
@@ -3012,7 +3012,8 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
3012
3012
mark = position (ps)
3013
3013
if k == closer
3014
3014
# [] ==> (vect)
3015
- return parse_vect (ps, closer, false )
3015
+ ckind, cflags = parse_vect (ps, closer, false )
3016
+ return (ckind, cflags, 0 )
3016
3017
elseif k == K " ;"
3017
3018
# v1.8: [;] ==> (ncat-1)
3018
3019
# v1.8: [;;] ==> (ncat-2)
@@ -3022,7 +3023,7 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
3022
3023
dim, _ = parse_array_separator (ps, Ref (:unknown ))
3023
3024
min_supported_version (v " 1.8" , ps, mark, " empty multidimensional array syntax" )
3024
3025
bump_closing_token (ps, closer)
3025
- return (K " ncat" , set_numeric_flags ( dim) )
3026
+ return (K " ncat" , EMPTY_FLAGS, dim)
3026
3027
end
3027
3028
parse_eq_star (ps)
3028
3029
k = peek (ps, skip_newlines= true )
@@ -3035,15 +3036,18 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
3035
3036
# [x] ==> (vect x)
3036
3037
# [x \n ] ==> (vect x)
3037
3038
# [x ==> (vect x (error-t))
3038
- parse_vect (ps, closer, prefix_trailing_comma)
3039
+ ckind, cflags = parse_vect (ps, closer, prefix_trailing_comma)
3040
+ return (ckind, cflags, 0 )
3039
3041
elseif k == K " for"
3040
3042
# [x for a in as] ==> (comprehension (generator x (iteration (in a as))))
3041
3043
# [x \n\n for a in as] ==> (comprehension (generator x (iteration (in a as))))
3042
- parse_comprehension (ps, mark, closer)
3044
+ ckind, cflags = parse_comprehension (ps, mark, closer)
3045
+ return (ckind, cflags, 0 )
3043
3046
else
3044
3047
# [x y] ==> (hcat x y)
3045
3048
# and other forms; See parse_array.
3046
- parse_array (ps, mark, closer, end_is_symbol)
3049
+ ckind, dim = parse_array (ps, mark, closer, end_is_symbol)
3050
+ return (ckind, EMPTY_FLAGS, dim)
3047
3051
end
3048
3052
end
3049
3053
@@ -3448,13 +3452,13 @@ function parse_string(ps::ParseState, raw::Bool)
3448
3452
emit (ps, mark, string_kind, str_flags)
3449
3453
end
3450
3454
3451
- function emit_braces (ps, mark, ckind, cflags)
3455
+ function emit_braces (ps, mark, ckind, cflags, dim = 0 )
3452
3456
if ckind == K " hcat"
3453
3457
# {x y} ==> (bracescat (row x y))
3454
3458
emit (ps, mark, K " row" , cflags & ~ TRAILING_COMMA_FLAG)
3455
3459
elseif ckind == K " ncat"
3456
3460
# {x ;;; y} ==> (bracescat (nrow-3 x y))
3457
- emit (ps, mark, K " nrow" , cflags & ~ TRAILING_COMMA_FLAG )
3461
+ emit (ps, mark, K " nrow" , set_numeric_flags (dim) )
3458
3462
end
3459
3463
check_ncat_compat (ps, mark, ckind)
3460
3464
outk = ckind in KSet " vect comprehension" ? K " braces" : K " bracescat"
@@ -3638,13 +3642,13 @@ function parse_atom(ps::ParseState, check_identifiers=true, has_unary_prefix=fal
3638
3642
parse_paren (ps, check_identifiers, has_unary_prefix)
3639
3643
elseif leading_kind == K " [" # cat expression
3640
3644
bump (ps, TRIVIA_FLAG)
3641
- ckind, cflags = parse_cat (ps, K " ]" , ps. end_symbol)
3642
- emit (ps, mark, ckind, cflags)
3645
+ ckind, cflags, dim = parse_cat (ps, K " ]" , ps. end_symbol)
3646
+ emit (ps, mark, ckind, cflags | set_numeric_flags (dim) )
3643
3647
check_ncat_compat (ps, mark, ckind)
3644
3648
elseif leading_kind == K " {" # cat expression
3645
3649
bump (ps, TRIVIA_FLAG)
3646
- ckind, cflags = parse_cat (ps, K " }" , ps. end_symbol)
3647
- emit_braces (ps, mark, ckind, cflags)
3650
+ ckind, cflags, dim = parse_cat (ps, K " }" , ps. end_symbol)
3651
+ emit_braces (ps, mark, ckind, cflags, dim )
3648
3652
elseif leading_kind == K " @" # macro call
3649
3653
# Macro names can be keywords
3650
3654
# @end x ==> (macrocall @end x)
0 commit comments