Chad Fowler (chad / chadfowler.com) wrote:
> 
> $ ruby -e '1.upto(1029) do |num|; print "-\n  x:z\n  y:#{num}\n"; end' >big.yaml 
> 

Yeah, I'm not sure this is the YAML you want to be generating.  I
believe this is valid YAML, but I'll need to check the specification.
It looks like you're trying to generate a Mapping within a Sequence.

Which would be done with spaces after the colons:

$ ruby -e '1.upto(1029) do |num|; print "-\n  x: z\n  y: #{num}\n"; end' >big.yaml 

> $ ruby -ryaml -e 'YAML.load(File.read("big.yaml"))' 
> /usr/local/lib/ruby/1.8/yaml.rb:39:in `load': parse error on line 3088, 
> col -1: `' (ArgumentError)
>         from /usr/local/lib/ruby/1.8/yaml.rb:39:in `load'
>         from -e:1
> 

Indeed, there is a bug.  It is in the syck string buffering mechanism.
The Ruby extension has a separate buffering mechanism for Ruby IO, so
you can circumvent this bug by using File.open rather than File.read:

$ ruby -ryaml -e 'YAML.load(File.open("big.yaml"))' 

Does that work okay?

I have a fix and it will be checked in shortly.  Thanks a lot for this.

> 
> I noticed that we have gram.c, which is a bison-generated file, but we 
> don't have gram.y.  Is that desirable?
> 

Gram.y is maintained in Syck CVS.

_why