[rspec-users] Step matchers

Wincent Colaiuta win at wincent.com
Mon Oct 15 10:11:33 EDT 2007

El 15/10/2007, a las 14:21, "Pat Maddox" <pergesu at gmail.com> escribió:

> On 10/14/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>> On 10/14/07, Pat Maddox <pergesu at gmail.com> wrote:
>>> Actually a parser for this would be quite simple
>> Dead simple. It would also allow us to do away with methods like
>> Given, When and Then, which some people have objected to (because of
>> the capitalization), because the stories are no longer expressed
>> directly in Ruby. Internally, the parser could use a StepFactory  
>> to do
>> things like create_given, create_when, etc (or however we decide to
>> name these).
> Jay mentioned antlr.  This parser is so simple though that I doubt we
> would need/want that.  There's not really any parsing at all in fact.
> You just look at each line, figure out what token it is, and pass the
> following string to a constructor.  It should be like 60 lines of Ruby
> code, and we don't have any external dependencies.

I've done a couple of month's work with ANTLR (3.0) this year and  
based on my experiences I'd say it's not the right tool for this kind  
of job. You use ANTLR if:

1. Parsing speed is really important.
2. You need to recognize a relatively complex grammar (most likely a  
context-sensitive language).
3. You don't mind being tied to Java tool-chain (even though your  
output target language is non-Java, the ANTLR tool itself is Java).
4. You have lots of time on your hands to develop, debug and fine- 
tune the delicate and complex machinery that is an ANTLR-generated  

In short, I found ANTLR fiendishly difficult to use, so for a simple  
task like this, especially one where parsing is *not* going to be a  
bottleneck, the simplest possible solution (parsing with hand-written  
Ruby) is going to be the best one.


More information about the rspec-users mailing list