From: Logan Capaldo Date: 2006-04-04T13:18:22+09:00 Subject: Re: while something do end (was Re: GStreamer Woes) On Apr 3, 2006, at 10:51 PM, Ryan Davis wrote: > > On Apr 3, 2006, at 2:20 PM, Logan Capaldo wrote: > >> Frankly I'm confused that >> while obj.meth do end isn't a syntax error... >> >> while 1 do end >> [...] >> I tried fiddling with it with ParseTree, but it was less than >> enlightening: >> ParseTree.new.parse_tree(A)[0][3] >> => [:defn, :m, [:scope, [:block, [:args], [:while, [:call, >> [:self], :class], true]]]] > > Why are you confused that it isn't a syntax error? Is it simply > because of the lack of a semi between do/end? > > while bool-expr [do] > body > end > > Given that body is zero or more expressions, it would seem to me to > be perfectly valid as-is. > > BTW, there is a much easier way to use ParseTree: > > % echo "while 1 do end" | parse_tree_show -f > (eval):1: warning: literal in condition > [[:class, > :Example, > :Object, > [:defn, :example, [:scope, [:block, [:args], [:while, [:lit, 1], > true]]]]]] > % echo "while obj.meth do end" | parse_tree_show -f > [[:class, > :Example, > :Object, > [:defn, > :example, > [:scope, > [:block, [:args], [:while, [:call, [:vcall, :obj], :meth], > true]]]]]] > > The next release of ParseTree will make it outputs just: > > [[:while, [:call, [:vcall, :obj], :meth], true]] > > -- > _why: zenspider's most intense moments of solice are immediately > following the slaughter [...] > _why: that topknot's the only thing keeping a lid on the righteous > anger > bricolage: yeah, that and his flagrant obsession with dvorak > > while takes a block argument? I was always under the impression it was syntax not a method...