Class: RDoc::Parser::RipperStateLex::InnerStateLex
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Ripper::Filter
|
|
Instance Chain:
self,
Ripper::Filter
|
|
Inherits: |
Ripper::Filter
|
Defined in: | lib/rdoc/parser/ripper_state_lex.rb, lib/rdoc/parser/ripper_state_lex.rb |
Class Method Summary
- .new(code) ⇒ InnerStateLex constructor
Instance Attribute Summary
- #lex_state rw
Instance Method Summary
-
#initialize(code) ⇒ InnerStateLex
constructor
See additional method definition at line 32.
- #on_backref(tok, data)
- #on_CHAR(tok, data)
- #on_comma(tok, data)
- #on_comment(tok, data)
- #on_const(tok, data)
- #on_cvar(tok, data)
-
#on_default(event, tok, data)
See additional method definition at line 301.
- #on_float(tok, data)
- #on_gvar(tok, data)
- #on_heredoc_beg(tok, data)
- #on_heredoc_end(tok, data)
- #on_ident(tok, data)
- #on_ignored_nl(tok, data)
- #on_ignored_sp(tok, data)
- #on_imaginary(tok, data)
- #on_int(tok, data)
- #on_ivar(tok, data)
- #on_kw(tok, data)
- #on_lbrace(tok, data)
- #on_lbracket(tok, data)
- #on_lparen(tok, data)
- #on_nl(tok, data)
- #on_op(tok, data)
- #on_period(tok, data)
- #on_rational(tok, data)
- #on_rbrace(tok, data)
- #on_rbracket(tok, data)
- #on_rparen(tok, data)
- #on_sp(tok, data)
- #on_symbeg(tok, data)
- #on_tstring_beg(tok, data)
- #on_tstring_end(tok, data)
- #reset
- #on_variables(event, tok, data) private
Constructor Details
.new(code) ⇒ InnerStateLex
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 32
def initialize(code) @lex_state = EXPR_BEG @in_fname = false @continue = false reset super(code) end
#initialize(code) ⇒ InnerStateLex
See additional method definition at line 32.
Instance Attribute Details
#lex_state (rw)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 30
attr_accessor :lex_state
Instance Method Details
#on_backref(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 223
def on_backref(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end
#on_CHAR(tok, data)
[ GitHub ]#on_comma(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 274
def on_comma(tok, data) @lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0 data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_comment(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 279
def on_comment(tok, data) @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0 data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_const(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 258
def on_const(tok, data) case @lex_state when EXPR_FNAME @lex_state = EXPR_ENDFN when EXPR_CLASS, EXPR_CMDARG, EXPR_MID @lex_state = EXPR_ARG else @lex_state = EXPR_CMDARG end data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_cvar(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 213
def on_cvar(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end
#on_default(event, tok, data)
See additional method definition at line 301.
#on_float(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 163
def on_float(tok, data) @lex_state = EXPR_END | EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_gvar(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 218
def on_gvar(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end
#on_heredoc_beg(tok, data)
[ GitHub ]#on_heredoc_end(tok, data)
[ GitHub ]#on_ident(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 204
def on_ident(tok, data) on_variables(__method__, tok, data) end
#on_ignored_nl(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 56
def on_ignored_nl(tok, data) case @lex_state when EXPR_FNAME, EXPR_DOT @continue = true else @continue = false @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0 end data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_ignored_sp(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 284
def on_ignored_sp(tok, data) @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0 data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_imaginary(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 173
def on_imaginary(tok, data) @lex_state = EXPR_END | EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_int(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 158
def on_int(tok, data) @lex_state = EXPR_END | EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_ivar(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 208
def on_ivar(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end
#on_kw(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 109
def on_kw(tok, data) case tok when 'class' @lex_state = EXPR_CLASS @in_fname = true when 'def' @lex_state = EXPR_FNAME @continue = true @in_fname = true when 'if', 'unless', 'while', 'until' if ((EXPR_MID | EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if @lex_state = EXPR_BEG | EXPR_LABEL else @lex_state = EXPR_BEG end when 'begin', 'case', 'when' @lex_state = EXPR_BEG when 'return', 'break' @lex_state = EXPR_MID else if @lex_state == EXPR_FNAME @lex_state = EXPR_END else @lex_state = EXPR_END end end data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_lbrace(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 238
def on_lbrace(tok, data) @lex_state = EXPR_LABEL | EXPR_BEG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_lbracket(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 248
def on_lbracket(tok, data) @lex_state = EXPR_LABEL | EXPR_BEG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_lparen(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 228
def on_lparen(tok, data) @lex_state = EXPR_LABEL | EXPR_BEG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_nl(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 45
def on_nl(tok, data) case @lex_state when EXPR_FNAME, EXPR_DOT @continue = true else @continue = false @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0 end data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_op(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 67
def on_op(tok, data) case tok when '&', '|', '!', '!=', '!~' case @lex_state when EXPR_FNAME, EXPR_DOT @lex_state = EXPR_ARG else @lex_state = EXPR_BEG end when '<<' # TODO next token? case @lex_state when EXPR_FNAME, EXPR_DOT @lex_state = EXPR_ARG else @lex_state = EXPR_BEG end when '?' @lex_state = EXPR_BEG when '&&', '||', '+=', '-=', '*=', '**=', '&=', '|=', '^=', '<<=', '>>=', '||=', '&&=' @lex_state = EXPR_BEG when '::' case @lex_state when EXPR_ARG, EXPR_CMDARG @lex_state = EXPR_DOT when EXPR_FNAME, EXPR_DOT @lex_state = EXPR_ARG else @lex_state = EXPR_BEG end else case @lex_state when EXPR_FNAME, EXPR_DOT @lex_state = EXPR_ARG else @lex_state = EXPR_BEG end end data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_period(tok, data)
[ GitHub ]#on_rational(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 168
def on_rational(tok, data) @lex_state = EXPR_END | EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_rbrace(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 243
def on_rbrace(tok, data) @lex_state = EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_rbracket(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 253
def on_rbracket(tok, data) @lex_state = EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_rparen(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 233
def on_rparen(tok, data) @lex_state = EXPR_ENDFN data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_sp(tok, data)
[ GitHub ]#on_symbeg(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 178
def on_symbeg(tok, data) @lex_state = EXPR_FNAME @continue = true @in_fname = true data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_tstring_beg(tok, data)
[ GitHub ]#on_tstring_end(tok, data)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 143
def on_tstring_end(tok, data) @lex_state = EXPR_END | EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end
#on_variables(event, tok, data) (private)
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 185
private def on_variables(event, tok, data) if @in_fname @lex_state = EXPR_ENDFN @in_fname = false @continue = false elsif @continue case @lex_state when EXPR_DOT @lex_state = EXPR_ARG else @lex_state = EXPR_ENDFN @continue = false end else @lex_state = EXPR_CMDARG end data << Token.new(lineno, column, event, tok, @lex_state) end
#reset
[ GitHub ]# File 'lib/rdoc/parser/ripper_state_lex.rb', line 40
def reset @command_start = false @cmd_state = @command_start end