method
lex
v1_9_2_180 -
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 Ruby program and returns an Array of Array, which is formatted like [[lineno, column], type, token].
require 'ripper' require 'pp' p Ripper.lex("def m(a) nil end") #=> [[[1, 0], :on_kw, "def"], [[1, 3], :on_sp, " " ], [[1, 4], :on_ident, "m" ], [[1, 5], :on_lparen, "(" ], [[1, 6], :on_ident, "a" ], [[1, 7], :on_rparen, ")" ], [[1, 8], :on_sp, " " ], [[1, 9], :on_kw, "nil"], [[1, 12], :on_sp, " " ], [[1, 13], :on_kw, "end"]]