@@ -21,24 +21,27 @@ struct ParseState
21
21
whitespace_newline:: Bool
22
22
# Enable parsing `where` with high precedence
23
23
where_enabled:: Bool
24
+ # Comma special
25
+ low_precedence_comma:: Bool
24
26
end
25
27
26
28
# Normal context
27
29
function ParseState (stream:: ParseStream )
28
- ParseState (stream, true , false , false , false , false , true )
30
+ ParseState (stream, true , false , false , false , false , true , false )
29
31
end
30
32
31
33
function ParseState (ps:: ParseState ; range_colon_enabled= nothing ,
32
34
space_sensitive= nothing , for_generator= nothing ,
33
35
end_symbol= nothing , whitespace_newline= nothing ,
34
- where_enabled= nothing )
36
+ where_enabled= nothing , low_precedence_comma = nothing )
35
37
ParseState (ps. stream,
36
38
range_colon_enabled === nothing ? ps. range_colon_enabled : range_colon_enabled,
37
39
space_sensitive === nothing ? ps. space_sensitive : space_sensitive,
38
40
for_generator === nothing ? ps. for_generator : for_generator,
39
41
end_symbol === nothing ? ps. end_symbol : end_symbol,
40
42
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)
42
45
end
43
46
44
47
# Functions to change parse state
@@ -50,7 +53,8 @@ function normal_context(ps::ParseState)
50
53
where_enabled= true ,
51
54
for_generator= false ,
52
55
end_symbol= false ,
53
- whitespace_newline= false )
56
+ whitespace_newline= false ,
57
+ low_precedence_comma= false )
54
58
end
55
59
56
60
function with_space_sensitive (ps:: ParseState )
545
549
#
546
550
# flisp: parse-eq
547
551
function 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
549
557
end
550
558
551
559
# parse_eq_star is used where commas are special, for example in an argument list
@@ -2633,7 +2641,6 @@ end
2633
2641
2634
2642
# flisp: parse-space-separated-exprs
2635
2643
function parse_space_separated_exprs (ps:: ParseState )
2636
- ps = with_space_sensitive (ps)
2637
2644
n_sep = 0
2638
2645
while true
2639
2646
k = peek (ps)
@@ -2984,7 +2991,8 @@ function parse_paren(ps::ParseState, check_identifiers=true)
2984
2991
ps = ParseState (ps, range_colon_enabled= true ,
2985
2992
space_sensitive= false ,
2986
2993
where_enabled= true ,
2987
- whitespace_newline= true )
2994
+ whitespace_newline= true ,
2995
+ low_precedence_comma= true )
2988
2996
mark = position (ps)
2989
2997
@check peek (ps) == K " ("
2990
2998
bump (ps, TRIVIA_FLAG) # K"("
@@ -3074,7 +3082,8 @@ function parse_brackets(after_parse::Function,
3074
3082
ps = ParseState (ps, range_colon_enabled= true ,
3075
3083
space_sensitive= false ,
3076
3084
where_enabled= true ,
3077
- whitespace_newline= true )
3085
+ whitespace_newline= true ,
3086
+ low_precedence_comma= true )
3078
3087
params_positions = acquire_positions (ps. stream)
3079
3088
last_eq_before_semi = 0
3080
3089
num_subexprs = 0
0 commit comments