From 6c1f4dfb97ecd586e8545984de610844bfb70643 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Fri, 6 Aug 2021 19:15:34 +0200 Subject: [PATCH] fix blockquote in array exprs --- src/components/keywords.jl | 2 +- test/parser.jl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/keywords.jl b/src/components/keywords.jl index f0d4cb7a..019bb40e 100644 --- a/src/components/keywords.jl +++ b/src/components/keywords.jl @@ -29,7 +29,7 @@ function parse_kw(ps::ParseState) end end elseif k === Tokens.QUOTE - return @default ps @closer ps :block parse_blockexpr(ps, :quote) + return @default ps @nocloser ps :inref @closer ps :block parse_blockexpr(ps, :quote) elseif k === Tokens.FOR return @default ps @closer ps :block parse_blockexpr(ps, :for) elseif k === Tokens.WHILE diff --git a/test/parser.jl b/test/parser.jl index 51f00d39..fb3231f9 100644 --- a/test/parser.jl +++ b/test/parser.jl @@ -1289,4 +1289,36 @@ end x, ps = CSTParser.parse(CSTParser.ParseState(str), true) @test ps.errored == false end + + @testset "#304" begin + str = """ + const _examples = PlotExample[ + PlotExample( # 40 + "Lens", + "A lens lets you easily magnify a region of a plot. x and y coordinates refer to the to be magnified region and the via the `inset` keyword the subplot index and the bounding box (in relative coordinates) of the inset plot with the magnified plot can be specified. Additional attributes count for the inset plot.", + [ + quote + begin + plot( + [(0, 0), (0, 0.9), (1, 0.9), (2, 1), (3, 0.9), (80, 0)], + legend = :outertopright, + ) + plot!([(0, 0), (0, 0.9), (2, 0.9), (3, 1), (4, 0.9), (80, 0)]) + plot!([(0, 0), (0, 0.9), (3, 0.9), (4, 1), (5, 0.9), (80, 0)]) + plot!([(0, 0), (0, 0.9), (4, 0.9), (5, 1), (6, 0.9), (80, 0)]) + lens!( + [1, 6], + [0.9, 1.1], + inset = (1, bbox(0.5, 0.0, 0.4, 0.4)), + ) + end + end, + ], + ), + ] + """ + @test test_expr(str) + x, ps = CSTParser.parse(CSTParser.ParseState(str), true) + @test ps.errored == false + end end