From cbdfdf654f422a0d334ba614287c6b54d46d0c34 Mon Sep 17 00:00:00 2001 From: c42f Date: Fri, 25 Nov 2022 19:54:46 +1000 Subject: [PATCH] Fix parsing of `.&(x,y)` --- src/parser.jl | 6 ++++-- test/parser.jl | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/parser.jl b/src/parser.jl index bc3877e7..ebf3b30e 100644 --- a/src/parser.jl +++ b/src/parser.jl @@ -1397,8 +1397,9 @@ end # flisp: parse-unary-prefix function parse_unary_prefix(ps::ParseState) mark = position(ps) - k = peek(ps) - if is_syntactic_unary_op(k) + t = peek_token(ps) + k = kind(t) + if is_syntactic_unary_op(k) && !is_dotted(t) k2 = peek(ps, 2) if k in KSet"& $" && (is_closing_token(ps, k2) || k2 == K"NewlineWs") # &) ==> & @@ -1418,6 +1419,7 @@ function parse_unary_prefix(ps::ParseState) emit(ps, mark, k) end else + # .&(x,y) ==> (call .& x y) parse_atom(ps) end end diff --git a/test/parser.jl b/test/parser.jl index 82b3e144..4956abfa 100644 --- a/test/parser.jl +++ b/test/parser.jl @@ -268,6 +268,7 @@ tests = [ # parse_call "f(x)" => "(call f x)" "\$f(x)" => "(call (\$ f) x)" + ".&(x,y)" => "(call .& x y)" # parse_call_chain "f(a).g(b)" => "(call (. (call f a) (quote g)) b)" "\$A.@x" => "(macrocall (. (\$ A) (quote @x)))"