Class: RDoc::Parser::RipperStateLex::InnerStateLex
- Inherits:
-
Ripper::Filter
- Object
- Ripper::Filter
- RDoc::Parser::RipperStateLex::InnerStateLex
- Defined in:
- lib/rdoc/parser/ripper_state_lex.rb,
lib/rdoc/parser/ripper_state_lex.rb
Instance Attribute Summary collapse
-
#lex_state ⇒ Object
Returns the value of attribute lex_state.
Instance Method Summary collapse
-
#initialize(code) ⇒ InnerStateLex
constructor
A new instance of InnerStateLex.
- #on_backref(tok, data) ⇒ Object
- #on_CHAR(tok, data) ⇒ Object
- #on_comma(tok, data) ⇒ Object
- #on_comment(tok, data) ⇒ Object
- #on_const(tok, data) ⇒ Object
- #on_cvar(tok, data) ⇒ Object
- #on_default(event, tok, data) ⇒ Object
- #on_float(tok, data) ⇒ Object
- #on_gvar(tok, data) ⇒ Object
- #on_heredoc_beg(tok, data) ⇒ Object
- #on_heredoc_end(tok, data) ⇒ Object
- #on_ident(tok, data) ⇒ Object
- #on_ignored_nl(tok, data) ⇒ Object
- #on_ignored_sp(tok, data) ⇒ Object
- #on_imaginary(tok, data) ⇒ Object
- #on_int(tok, data) ⇒ Object
- #on_ivar(tok, data) ⇒ Object
- #on_kw(tok, data) ⇒ Object
- #on_lbrace(tok, data) ⇒ Object
- #on_lbracket(tok, data) ⇒ Object
- #on_lparen(tok, data) ⇒ Object
- #on_nl(tok, data) ⇒ Object
- #on_op(tok, data) ⇒ Object
- #on_period(tok, data) ⇒ Object
- #on_rational(tok, data) ⇒ Object
- #on_rbrace(tok, data) ⇒ Object
- #on_rbracket(tok, data) ⇒ Object
- #on_rparen(tok, data) ⇒ Object
- #on_sp(tok, data) ⇒ Object
- #on_symbeg(tok, data) ⇒ Object
- #on_tstring_beg(tok, data) ⇒ Object
- #on_tstring_end(tok, data) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(code) ⇒ InnerStateLex
Returns a new instance of InnerStateLex.
37 38 39 40 41 42 43 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 37 def initialize(code) @lex_state = EXPR_BEG @in_fname = false @continue = false reset super(code) end |
Instance Attribute Details
#lex_state ⇒ Object
Returns the value of attribute lex_state.
35 36 37 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 35 def lex_state @lex_state end |
Instance Method Details
#on_backref(tok, data) ⇒ Object
228 229 230 231 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 228 def on_backref(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end |
#on_CHAR(tok, data) ⇒ Object
153 154 155 156 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 153 def on_CHAR(tok, data) @lex_state = EXPR_END data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_comma(tok, data) ⇒ Object
279 280 281 282 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 279 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) ⇒ Object
284 285 286 287 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 284 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) ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 263 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) ⇒ Object
218 219 220 221 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 218 def on_cvar(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end |
#on_default(event, tok, data) ⇒ Object
306 307 308 309 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 306 def on_default(event, tok, data) reset data << Token.new(lineno, column, event, tok, @lex_state) end |
#on_float(tok, data) ⇒ Object
168 169 170 171 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 168 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) ⇒ Object
223 224 225 226 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 223 def on_gvar(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end |
#on_heredoc_beg(tok, data) ⇒ Object
294 295 296 297 298 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 294 def on_heredoc_beg(tok, data) data << Token.new(lineno, column, __method__, tok, @lex_state) @lex_state = EXPR_END data end |
#on_heredoc_end(tok, data) ⇒ Object
300 301 302 303 304 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 300 def on_heredoc_end(tok, data) data << Token.new(lineno, column, __method__, tok, @lex_state) @lex_state = EXPR_BEG data end |
#on_ident(tok, data) ⇒ Object
209 210 211 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 209 def on_ident(tok, data) on_variables(__method__, tok, data) end |
#on_ignored_nl(tok, data) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 61 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) ⇒ Object
289 290 291 292 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 289 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) ⇒ Object
178 179 180 181 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 178 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) ⇒ Object
163 164 165 166 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 163 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) ⇒ Object
213 214 215 216 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 213 def on_ivar(tok, data) @lex_state = EXPR_END on_variables(__method__, tok, data) end |
#on_kw(tok, data) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 114 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) ⇒ Object
243 244 245 246 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 243 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) ⇒ Object
253 254 255 256 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 253 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) ⇒ Object
233 234 235 236 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 233 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) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 50 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) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 72 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) ⇒ Object
158 159 160 161 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 158 def on_period(tok, data) @lex_state = EXPR_DOT data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_rational(tok, data) ⇒ Object
173 174 175 176 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 173 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) ⇒ Object
248 249 250 251 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 248 def on_rbrace(tok, data) @lex_state = EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_rbracket(tok, data) ⇒ Object
258 259 260 261 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 258 def on_rbracket(tok, data) @lex_state = EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_rparen(tok, data) ⇒ Object
238 239 240 241 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 238 def on_rparen(tok, data) @lex_state = EXPR_ENDFN data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_sp(tok, data) ⇒ Object
275 276 277 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 275 def on_sp(tok, data) data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_symbeg(tok, data) ⇒ Object
183 184 185 186 187 188 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 183 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) ⇒ Object
143 144 145 146 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 143 def on_tstring_beg(tok, data) @lex_state = EXPR_BEG data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#on_tstring_end(tok, data) ⇒ Object
148 149 150 151 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 148 def on_tstring_end(tok, data) @lex_state = EXPR_END | EXPR_ENDARG data << Token.new(lineno, column, __method__, tok, @lex_state) end |
#reset ⇒ Object
45 46 47 48 |
# File 'lib/rdoc/parser/ripper_state_lex.rb', line 45 def reset @command_start = false @cmd_state = @command_start end |