Stefan. this is great! With something like that, it might not be too far of a stretch to create a Ruby equivalant of the kjParser project (the Python parser generator). On Wed, 23 May 2001, Stefan Matthias Aust wrote: > Stefan Matthias Aust <sma / 3plus4.de> wrote: > > >I'm afraid, the only complete reference for Ruby's grammar is the YACC > >input file "parse.y" from the ruby source distribution. One Ruby > >overview document contains a simplified BNF but that's probably not > >enough to create a correct Ruby parser. > > Bad style, I know... but this tiny ugly script can extract the BNF > rules from parse.y with all C code stripped. > > #!/usr/local/bin/ruby -w > while gets > break if /^%%/ > end > i = 0; j = true > while gets > break if /^%%/ > $_.each_byte do |c| > if i == 0 && c == ?' then j = !j end > i += 1 if j && c == ?{ > print c.chr if i == 0 > i -= 1 if j && c == ?} > raise "oops" if i < 0 > end > end > > Perhaps it's useful. If the script is called eg, then > > ./eg parse.y|ruby -n -e 'next if /^\s*$/; print'|less > > shows just the grammar rules. > > bye > -- > Stefan Matthias Aust \/ Truth Until Paradox -- Glen Starchman Enabled Ventures/Enabled Technology Group glen / enabledventures.com 206.234.7330