tags:

views:

144

answers:

1

I am writing a search engine using the Lucene Java framework.

What I want to do is to create an index of Ruby source code files. For that I would like to have the option of using a stop word filter, i.e. I want the stop words of the ruby language be ignored when indexing the files.

--> Does anyone know of a nice complete list of Ruby stop words? (e.g. def, end, module, ...)

Surprisingly enough, Google did not provide me with an answer... So any help would be appreciated!

+5  A: 
alias   and     BEGIN   begin   break   case    class   def     defined?
do      else    elsif   END     end     ensure  false   for     if 
in      module  next    nil     not     or      redo    rescue  retry 
return  self    super   then    true    undef   unless  until   when 
while   yield 

From Ruby QuickRef.

For what it's worth, these are generally called "reserved words" - and I found this list by Googling for Ruby reserved words.

Dominic Rodger
This is a good list to begin with, but I am looking for more:For example I'd also like to have:include, require, extend, private, public, ...These are also frequently used and should not be read into the index...
fgysin
`rescue` cannot be reserved, at least not in the sense of the keywords of a context-free grammar: I was able to do `a = ""; def a.rescue; 42; end; a.rescue`…
Adrian
Seems to work with 'self' or any other "reserved" word as well. Obviously Ruby does not tell you that these words are reserved at compile time, but just ignores the new definitions during the run.
fgysin