method
lex
v2_6_3 -
Show latest stable
-
0 notes -
Class: Ripper
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (2)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (38)
- 2_6_3 (0)
- What's this?
lex(src, filename = '-', lineno = 1)
public
Tokenizes the Ruby program and returns an array of an array, which is formatted like [[lineno, column], type, token, state].
require 'ripper' require 'pp' pp Ripper.lex("def m(a) nil end") #=> [[[1, 0], :on_kw, "def", Ripper::EXPR_FNAME ], [[1, 3], :on_sp, " ", Ripper::EXPR_FNAME ], [[1, 4], :on_ident, "m", Ripper::EXPR_ENDFN ], [[1, 5], :on_lparen, "(", Ripper::EXPR_LABEL | Ripper::EXPR_BEG], [[1, 6], :on_ident, "a", Ripper::EXPR_ARG ], [[1, 7], :on_rparen, ")", Ripper::EXPR_ENDFN ], [[1, 8], :on_sp, " ", Ripper::EXPR_BEG ], [[1, 9], :on_kw, "nil", Ripper::EXPR_END ], [[1, 12], :on_sp, " ", Ripper::EXPR_END ], [[1, 13], :on_kw, "end", Ripper::EXPR_END ]]