Jonathan Paisley
3/16/2005 8:18:00 PM
On Thu, 17 Mar 2005 04:43:50 +0900, Ben Giddings wrote:
> Yeah, that would work (with tweaked regexps), but I would imagine it
> would be less efficient. Each regexp is essentially a complex parser,
> and so in your example above, you have five parsers per gcc line. If I
> could do it in one parser, it would probably be quicker. I also think
> it might be easier to avoid mistakes due to complex regexps. I might
> try it though, it might be enough to do it the simple way.
If you use a regexp-based scanner as input to your parser, you may
actually end up with more regexp matching!
I disagree with the statement that a regexp is essentially a complex
parser. As I understand it, parsers like racc describe a more complicated
language than that described by regular expressions.
I've found that doing things with regular expressions in Ruby tends to be
much faster than anything involving interpreting Ruby code and creating
lots of objects.
Efficiency shouldn't be too much of a concern here anyway - the input data
rate is limited by how quickly your machine can do compilations -
certainly much slower than a few gsub!s on some very small input strings.
Good luck!
Jonathan