From: Logan Capaldo Date: 2005-03-18T00:36:08+09:00 Subject: Re: Examples for racc? On Thu, 17 Mar 2005 17:29:46 +0900, Jonathan Paisley wrote: > On Thu, 17 Mar 2005 10:12:57 +0900, Logan Capaldo wrote: > > > optparser = OptionParser.new > > optparser.on("-D") do |arg| > > gcc_inv.debug << arg > > end > > > > The above is sloppy and mostly wrong, but I don't have Ruby on this > > machine to do it properly. Just an alternative idea. Especailly since > > you won't have to write a new regexp everytime you want to add a > > option to your class. > > I suppose the problem with this approach is that optparse will raise an > exception for unspecified options. So, to get it to work correctly you'd > need to know all the possible options to gcc (and whether or not they take > an argument). > > It'd be a really neat solution if this can be resolved! > > Well you can rescue those exceptions. As for needing to know all the possible options (a least all the ones to pass to GCC), you need to know them anyway to obtain the output he desired anyway. I imagine there's an option to pass-through unrecognized options anyway. There's definitely one for Perl's Getopt::Long.