How do I run the PNG example?

62 views
Skip to first unread message

Daniel Casimiro

unread,
Aug 23, 2012, 5:20:43 PM8/23/12
to juli...@googlegroups.com

Hi,

I can't get the PNG example from 76c4a68c844b8afd3079f9b2b26a3598d97656de to work. It always prints out the following:

./julia examples/png.jl /Users/dan/QtSDK/Examples/4.7/network/torrent/icons/1uparrow.png 
in @s_str: _jl_interp_parse not defined
 in @s_str at /Users/dan/src/julia/extras/strpack.jl:328
 in load at util.jl:230
 in load at util.jl:242
 in process_options at client.jl:175
 in _start at client.jl:227
 in load at util.jl:230
 in load at util.jl:242
 in process_options at client.jl:175
 in _start at client.jl:227
at /Users/dan/src/julia/examples/png.jl:7
 in load at util.jl:253
 in process_options at client.jl:175
 in _start at client.jl:227

It looks like there is a definition of _jl_interp_parse in base/string.jl, but it's not being found. Am I doing something wrong?

Thanks,
~Dan

Stefan Karpinski

unread,
Aug 23, 2012, 5:27:00 PM8/23/12
to juli...@googlegroups.com
Looks like that needs to be updated to Base._jl_interp_parse.

--
 
 
 

Jeff Bezanson

unread,
Aug 23, 2012, 7:08:17 PM8/23/12
to juli...@googlegroups.com
That macro is suspicious:

macro s_str(str)
interp_struct_parse(eval(_jl_interp_parse(str)))
end

A macro should not call eval. I know the purpose of this is to allow
interpolation in struct strings, which is reasonable, but there can be
local variables. In that case you can't have it both ways --- doing
both compile-time interpolation parsing and compile-time struct string
parsing. I would say s"" strings should not allow interpolation, and
you have to call struct_parse manually if you want to use a run-time
string.
> --
>
>
>

Daniel Casimiro

unread,
Aug 23, 2012, 7:24:18 PM8/23/12
to juli...@googlegroups.com
I added "Base." to strpack.jl,

diff --git a/extras/strpack.jl b/extras/strpack.jl
index c9d167b..a03c6ee 100644
--- a/extras/strpack.jl
+++ b/extras/strpack.jl
@@ -156,7 +156,7 @@ function struct_parse(s::String)
)
"x, s[i:end])
if isa(m, Nothing)
- error("Failed to compile struct; syntax error at ...$(s[i])...")
+ error("Failed to compile struct; syntax error at index $i...$(s[i])...within '$(s[i:end])'")
end
name, oneD, nD, typ, custtyp = m.captures
dims = if isa(oneD, Nothing) && isa(nD, Nothing)
@@ -325,7 +325,7 @@ function interp_struct_parse(str::String)
end

macro s_str(str)
- interp_struct_parse(eval(_jl_interp_parse(str)))
+ interp_struct_parse(eval(Base._jl_interp_parse(str)))
end

# Julian aliases for the "object-style" calls to pack/unpack/struct


However, now the regular expression parsing is failing now.

[dan@new-host-2 julia]$ ./julia examples/png.jl /Users/dan/QtSDK/Examples/4.7/network/torrent/icons/peertopeer.png
Failed to compile struct; syntax error at index 1...B...within 'BcccBBBB'
in struct_parse at /Users/dan/src/julia/extras/strpack.jl:160
in interp_struct_parse at /Users/dan/src/julia/extras/strpack.jl:319
in @s_str at /Users/dan/src/julia/extras/strpack.jl:329
in load at util.jl:230
in load at util.jl:242
in process_options at client.jl:175
in _start at client.jl:227
in load at util.jl:230
in load at util.jl:242
in process_options at client.jl:175
in _start at client.jl:227
at /Users/dan/src/julia/examples/png.jl:7
in load at util.jl:253
in process_options at client.jl:175
in _start at client.jl:227

I tried to simplify the regular expression, but I couldn't get it to mach anything. Is that related to Jeff's warning?
> --
>
>
>

Patrick O'Leary

unread,
Aug 23, 2012, 10:31:45 PM8/23/12
to juli...@googlegroups.com
On Thursday, August 23, 2012 6:08:17 PM UTC-5, Jeff Bezanson wrote:
That macro is suspicious:

macro s_str(str)
    interp_struct_parse(eval(_jl_interp_parse(str)))
end

I wrote that before I knew better. It is indeed evil. The whole syntax thing is probably going away in the next revision, in which I plan to steal some ideas from Construct. I'm not sure when I'm going to attempt to tackle that, though.

Patrick O'Leary

unread,
Aug 23, 2012, 10:59:12 PM8/23/12
to juli...@googlegroups.com

 I don't think so; I've removed the variable interpolation hack (it isn't used in the example) and this still comes up. Works from the REPL though. Really not sure what's going on here.

Patrick O'Leary

unread,
Aug 23, 2012, 11:35:22 PM8/23/12
to juli...@googlegroups.com
On Thursday, August 23, 2012 9:59:12 PM UTC-5, Patrick O'Leary wrote:
 I don't think so; I've removed the variable interpolation hack (it isn't used in the example) and this still comes up. Works from the REPL though. Really not sure what's going on here.

The regular expression actually succeeds. If I print the match object, everything looks fine. Yet, in context, isa(m, Nothing) is evaluating to true. That's now filed as a bug (https://github.com/JuliaLang/julia/issues/1204). If I comment out the error test, it gets farther, but at some point something else broke so that size, which should be a two-element vector, ends up as a scalar.
Reply all
Reply to author
Forward
0 new messages