@@ -21,24 +21,27 @@ struct ParseState
2121 whitespace_newline:: Bool
2222 # Enable parsing `where` with high precedence
2323 where_enabled:: Bool
24+ # Comma special
25+ low_precedence_comma:: Bool
2426end
2527
2628# Normal context
2729function ParseState (stream:: ParseStream )
28- ParseState (stream, true , false , false , false , false , true )
30+ ParseState (stream, true , false , false , false , false , true , false )
2931end
3032
3133function ParseState (ps:: ParseState ; range_colon_enabled= nothing ,
3234 space_sensitive= nothing , for_generator= nothing ,
3335 end_symbol= nothing , whitespace_newline= nothing ,
34- where_enabled= nothing )
36+ where_enabled= nothing , low_precedence_comma = nothing )
3537 ParseState (ps. stream,
3638 range_colon_enabled === nothing ? ps. range_colon_enabled : range_colon_enabled,
3739 space_sensitive === nothing ? ps. space_sensitive : space_sensitive,
3840 for_generator === nothing ? ps. for_generator : for_generator,
3941 end_symbol === nothing ? ps. end_symbol : end_symbol,
4042 whitespace_newline === nothing ? ps. whitespace_newline : whitespace_newline,
41- where_enabled === nothing ? ps. where_enabled : where_enabled)
43+ where_enabled === nothing ? ps. where_enabled : where_enabled,
44+ low_precedence_comma === nothing ? ps. low_precedence_comma : low_precedence_comma)
4245end
4346
4447# Functions to change parse state
@@ -50,7 +53,8 @@ function normal_context(ps::ParseState)
5053 where_enabled= true ,
5154 for_generator= false ,
5255 end_symbol= false ,
53- whitespace_newline= false )
56+ whitespace_newline= false ,
57+ low_precedence_comma= false )
5458end
5559
5660function with_space_sensitive (ps:: ParseState )
545549#
546550# flisp: parse-eq
547551function parse_eq (ps:: ParseState )
548- parse_assignment (ps, parse_comma)
552+ if ps. low_precedence_comma
553+ parse_eq_star (ps)
554+ else
555+ parse_assignment (ps, parse_comma)
556+ end
549557end
550558
551559# parse_eq_star is used where commas are special, for example in an argument list
@@ -2633,7 +2641,6 @@ end
26332641
26342642# flisp: parse-space-separated-exprs
26352643function parse_space_separated_exprs (ps:: ParseState )
2636- ps = with_space_sensitive (ps)
26372644 n_sep = 0
26382645 while true
26392646 k = peek (ps)
@@ -2984,7 +2991,8 @@ function parse_paren(ps::ParseState, check_identifiers=true)
29842991 ps = ParseState (ps, range_colon_enabled= true ,
29852992 space_sensitive= false ,
29862993 where_enabled= true ,
2987- whitespace_newline= true )
2994+ whitespace_newline= true ,
2995+ low_precedence_comma= true )
29882996 mark = position (ps)
29892997 @check peek (ps) == K " ("
29902998 bump (ps, TRIVIA_FLAG) # K"("
@@ -3074,7 +3082,8 @@ function parse_brackets(after_parse::Function,
30743082 ps = ParseState (ps, range_colon_enabled= true ,
30753083 space_sensitive= false ,
30763084 where_enabled= true ,
3077- whitespace_newline= true )
3085+ whitespace_newline= true ,
3086+ low_precedence_comma= true )
30783087 params_positions = acquire_positions (ps. stream)
30793088 last_eq_before_semi = 0
30803089 num_subexprs = 0
0 commit comments