This repository was archived by the owner on Sep 20, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 4040"""
4141 @pygen
4242
43- Making julie walking a little *more* like python. Stick the @pygen macro in front of a
44- function declaration and you can use `yield` statements to make a python style
43+ Making julie walking a little *more* like python. Stick
44+ the @pygen macro in front of a function declaration and
45+ you can use `yield` statements to make a python style
4546generator!
4647"""
4748macro pygen(f)
4849 f′ = replace(f, yregex, asput)
4950 lines = f′ |> IOBuffer |> readlines
50- insert!(lines, 2 , " function γ(c::Channel)" )
51+ ind = findfirst(x -> contains(x, " function" ), lines)
52+ insert!(lines, ind + 1 , " function γ(c::Channel)" )
5153 push!(lines, " return Channel(γ)\n end" )
5254 return join(lines, " \n " ) |> parse |> esc
5355end
Original file line number Diff line number Diff line change @@ -2,4 +2,14 @@ using PyGen
22using Base. Test
33
44# write your own tests here
5- @test PyGen. asput(" yield pi" ) == " put!(c, pi)"
5+ @test PyGen. asput(" yield pi" ) == " put!(c, pi)"
6+
7+ @pygen "
8+
9+ function λ()
10+ yield 10
11+ end
12+ "
13+
14+ # Test for \n in first line issue
15+ @test isdefined(:λ) == true
You can’t perform that action at this time.
0 commit comments