summaryrefslogtreecommitdiff
path: root/ext/ripper/lib/ripper/filter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ripper/lib/ripper/filter.rb')
-rw-r--r--ext/ripper/lib/ripper/filter.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/ext/ripper/lib/ripper/filter.rb b/ext/ripper/lib/ripper/filter.rb
index 898501b23c..239f9f00e1 100644
--- a/ext/ripper/lib/ripper/filter.rb
+++ b/ext/ripper/lib/ripper/filter.rb
@@ -13,9 +13,13 @@ require 'ripper/lexer'
class Ripper
# This class handles only scanner events,
- # and they are dispatched in the `right' order (same with input).
+ # which are dispatched in the 'right' order (same with input).
class Filter
+ # Creates a new Ripper::Filter instance, passes parameters +src+,
+ # +filename+, and +lineno+ to Ripper::Lexer.new
+ #
+ # The lexer is for internal use only.
def initialize(src, filename = '-', lineno = 1)
@__lexer = Lexer.new(src, filename, lineno)
@__line = nil
@@ -41,8 +45,9 @@ class Ripper
@__col
end
- # Starts parsing. _init_ is a data accumulator.
- # It is passed to the next event handler (as of Enumerable#inject).
+ # Starts the parser.
+ # +init+ is a data accumulator and is passed to the next event handler (as
+ # of Enumerable#inject).
def parse(init = nil)
data = init
@__lexer.lex.each do |pos, event, tok|
@@ -57,10 +62,12 @@ class Ripper
private
- # This method is called when some event handler have not defined.
- # _event_ is :on_XXX, _token_ is scanned token, _data_ is a data
- # accumulator. The return value of this method is passed to the
- # next event handler (as of Enumerable#inject).
+ # This method is called when some event handler is undefined.
+ # +event+ is :on_XXX, +token+ is the scanned token, and +data+ is a data
+ # accumulator.
+ #
+ # The return value of this method is passed to the next event handler (as
+ # of Enumerable#inject).
def on_default(event, token, data)
data
end