@@ -1098,8 +1098,8 @@ function parse_where_chain(ps0::ParseState, mark)
10981098 # x where {y for y in ys} ==> (where x (braces (generator y (iteration (in y ys)))))
10991099 m = position (ps)
11001100 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 )
11031103 emit (ps, mark, K " where" )
11041104 else
11051105 # x where T ==> (where x T)
@@ -1589,7 +1589,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
15891589 # a [i] ==> (ref a (error-t) i)
15901590 bump_disallowed_space (ps)
15911591 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 ),
15931593 K " ]" , ps. end_symbol)
15941594 if is_macrocall
15951595 # @S[a,b] ==> (macrocall @S (vect a b))
@@ -1600,7 +1600,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
16001600 # v1.7: @S[a ;; b] ==> (macrocall @S (ncat-2 a b))
16011601 # v1.6: @S[a ;; b] ==> (macrocall @S (error (ncat-2 a b)))
16021602 fix_macro_name_kind! (ps, macro_name_position)
1603- emit (ps, m, ckind, cflags)
1603+ emit (ps, m, ckind, cflags | set_numeric_flags (dim) )
16041604 check_ncat_compat (ps, m, ckind)
16051605 emit (ps, mark, K " macrocall" )
16061606 is_macrocall = false
@@ -1621,7 +1621,7 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
16211621 ckind == K " comprehension" ? K " typed_comprehension" :
16221622 ckind == K " ncat" ? K " typed_ncat" :
16231623 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) )
16251625 check_ncat_compat (ps, mark, ckind)
16261626 end
16271627 elseif k == K " ."
@@ -2840,7 +2840,7 @@ function parse_array(ps::ParseState, mark, closer, end_is_symbol)
28402840 if binding_power == typemin (Int)
28412841 # [x@y ==> (hcat x (error-t ✘ y))
28422842 bump_closing_token (ps, closer)
2843- return (K " hcat" , EMPTY_FLAGS )
2843+ return (K " hcat" , 0 )
28442844 end
28452845 while true
28462846 (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)
28562856 binding_power = next_bp
28572857 end
28582858 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)
28622862end
28632863
28642864# Parse equal and ascending precedence chains of array concatenation operators -
@@ -3012,7 +3012,8 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
30123012 mark = position (ps)
30133013 if k == closer
30143014 # [] ==> (vect)
3015- return parse_vect (ps, closer, false )
3015+ ckind, cflags = parse_vect (ps, closer, false )
3016+ return (ckind, cflags, 0 )
30163017 elseif k == K " ;"
30173018 # v1.8: [;] ==> (ncat-1)
30183019 # v1.8: [;;] ==> (ncat-2)
@@ -3022,7 +3023,7 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
30223023 dim, _ = parse_array_separator (ps, Ref (:unknown ))
30233024 min_supported_version (v " 1.8" , ps, mark, " empty multidimensional array syntax" )
30243025 bump_closing_token (ps, closer)
3025- return (K " ncat" , set_numeric_flags ( dim) )
3026+ return (K " ncat" , EMPTY_FLAGS, dim)
30263027 end
30273028 parse_eq_star (ps)
30283029 k = peek (ps, skip_newlines= true )
@@ -3035,15 +3036,18 @@ function parse_cat(ps::ParseState, closer, end_is_symbol)
30353036 # [x] ==> (vect x)
30363037 # [x \n ] ==> (vect x)
30373038 # [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 )
30393041 elseif k == K " for"
30403042 # [x for a in as] ==> (comprehension (generator x (iteration (in a as))))
30413043 # [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 )
30433046 else
30443047 # [x y] ==> (hcat x y)
30453048 # 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)
30473051 end
30483052end
30493053
@@ -3448,13 +3452,13 @@ function parse_string(ps::ParseState, raw::Bool)
34483452 emit (ps, mark, string_kind, str_flags)
34493453end
34503454
3451- function emit_braces (ps, mark, ckind, cflags)
3455+ function emit_braces (ps, mark, ckind, cflags, dim = 0 )
34523456 if ckind == K " hcat"
34533457 # {x y} ==> (bracescat (row x y))
34543458 emit (ps, mark, K " row" , cflags & ~ TRAILING_COMMA_FLAG)
34553459 elseif ckind == K " ncat"
34563460 # {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) )
34583462 end
34593463 check_ncat_compat (ps, mark, ckind)
34603464 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
36383642 parse_paren (ps, check_identifiers, has_unary_prefix)
36393643 elseif leading_kind == K " [" # cat expression
36403644 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) )
36433647 check_ncat_compat (ps, mark, ckind)
36443648 elseif leading_kind == K " {" # cat expression
36453649 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 )
36483652 elseif leading_kind == K " @" # macro call
36493653 # Macro names can be keywords
36503654 # @end x ==> (macrocall @end x)
0 commit comments