summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/ripper/lib/ripper/lexer.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb
index a2d4d655b5..23db3a0570 100644
--- a/ext/ripper/lib/ripper/lexer.rb
+++ b/ext/ripper/lib/ripper/lexer.rb
@@ -62,6 +62,17 @@ class Ripper
freeze
end
+ def [](index)
+ case index
+ when 0
+ warn "Calling `Lexer::State#[0]` is deprecated, please use `Lexer::State#to_int` instead"
+ @to_int
+ when 1
+ warn "Calling `Lexer::State#[1]` is deprecated, please use `Lexer::State#to_s` instead"
+ @event
+ end
+ end
+
alias to_i to_int
alias inspect to_s
def pretty_print(q) q.text(to_s) end
@@ -84,6 +95,26 @@ class Ripper
@message = message
end
+ def [](index)
+ case index
+ when 0
+ warn "Calling `Lexer::Elem#[0]` is deprecated, please use `Lexer::Elem#pos` instead"
+ @pos
+ when 1
+ warn "Calling `Lexer::Elem#[1]` is deprecated, please use `Lexer::Elem#event` instead"
+ @event
+ when 2
+ warn "Calling `Lexer::Elem#[2]` is deprecated, please use `Lexer::Elem#tok` instead"
+ @tok
+ when 3
+ warn "Calling `Lexer::Elem#[3]` is deprecated, please use `Lexer::Elem#state` instead"
+ @state
+ when 4
+ warn "Calling `Lexer::Elem#[4]` is deprecated, please use `Lexer::Elem#message` instead"
+ @message
+ end
+ end
+
def inspect
"#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>"
end