irb 0.9.6 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/Gemfile +10 -2
- data/LICENSE.txt +3 -3
- data/README.md +3 -3
- data/Rakefile +17 -1
- data/doc/irb/irb-tools.rd.ja +184 -0
- data/doc/irb/irb.rd.ja +427 -0
- data/irb.gemspec +18 -4
- data/lib/irb/cmd/fork.rb +2 -4
- data/lib/irb/cmd/help.rb +10 -5
- data/lib/irb/cmd/info.rb +32 -0
- data/lib/irb/cmd/ls.rb +101 -0
- data/lib/irb/cmd/measure.rb +43 -0
- data/lib/irb/cmd/nop.rb +10 -4
- data/lib/irb/cmd/pushws.rb +0 -1
- data/lib/irb/cmd/show_source.rb +93 -0
- data/lib/irb/cmd/whereami.rb +20 -0
- data/lib/irb/color.rb +246 -0
- data/lib/irb/color_printer.rb +47 -0
- data/lib/irb/completion.rb +254 -55
- data/lib/irb/context.rb +165 -72
- data/lib/irb/easter-egg.rb +138 -0
- data/lib/irb/ext/change-ws.rb +0 -1
- data/lib/irb/ext/history.rb +47 -11
- data/lib/irb/ext/loader.rb +46 -20
- data/lib/irb/ext/multi-irb.rb +7 -7
- data/lib/irb/ext/save-history.rb +36 -11
- data/lib/irb/ext/tracer.rb +14 -2
- data/lib/irb/ext/use-loader.rb +4 -3
- data/lib/irb/ext/workspaces.rb +0 -1
- data/lib/irb/extend-command.rb +113 -63
- data/lib/irb/frame.rb +12 -7
- data/lib/irb/help.rb +0 -1
- data/lib/irb/init.rb +146 -26
- data/lib/irb/input-method.rb +287 -9
- data/lib/irb/inspector.rb +15 -11
- data/lib/irb/lc/error.rb +55 -16
- data/lib/irb/lc/help-message +25 -13
- data/lib/irb/lc/ja/error.rb +55 -14
- data/lib/irb/lc/ja/help-message +11 -6
- data/lib/irb/locale.rb +13 -4
- data/lib/irb/notifier.rb +12 -8
- data/lib/irb/output-method.rb +6 -6
- data/lib/irb/ruby-lex.rb +673 -992
- data/lib/irb/ruby_logo.aa +37 -0
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +65 -21
- data/lib/irb/xmp.rb +1 -1
- data/lib/irb.rb +276 -96
- data/man/irb.1 +229 -0
- metadata +25 -31
- data/.gitignore +0 -9
- data/.travis.yml +0 -6
- data/lib/irb/lc/.document +0 -4
- data/lib/irb/ruby-token.rb +0 -267
- data/lib/irb/slex.rb +0 -282
data/man/irb.1
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
.Dd August 11, 2019
|
3
|
+
.Dt IRB \&1 "Ruby Programmer's Reference Guide"
|
4
|
+
.Os UNIX
|
5
|
+
.Sh NAME
|
6
|
+
.Nm irb
|
7
|
+
.Nd Interactive Ruby Shell
|
8
|
+
.Sh SYNOPSIS
|
9
|
+
.Nm
|
10
|
+
.Op Fl -version
|
11
|
+
.Op Fl dfUw
|
12
|
+
.Op Fl I Ar directory
|
13
|
+
.Op Fl r Ar library
|
14
|
+
.Op Fl E Ar external Ns Op : Ns Ar internal
|
15
|
+
.Op Fl W Ns Op Ar level
|
16
|
+
.Op Fl - Ns Oo no Oc Ns inspect
|
17
|
+
.Op Fl - Ns Oo no Oc Ns multiline
|
18
|
+
.Op Fl - Ns Oo no Oc Ns singleline
|
19
|
+
.Op Fl - Ns Oo no Oc Ns echo
|
20
|
+
.Op Fl - Ns Oo no Oc Ns colorize
|
21
|
+
.Op Fl - Ns Oo no Oc Ns autocomplete
|
22
|
+
.Op Fl - Ns Oo no Oc Ns verbose
|
23
|
+
.Op Fl -prompt Ar mode
|
24
|
+
.Op Fl -prompt-mode Ar mode
|
25
|
+
.Op Fl -inf-ruby-mode
|
26
|
+
.Op Fl -simple-prompt
|
27
|
+
.Op Fl -noprompt
|
28
|
+
.Op Fl -tracer
|
29
|
+
.Op Fl -back-trace-limit Ar n
|
30
|
+
.Op Fl -
|
31
|
+
.Op program_file
|
32
|
+
.Op argument ...
|
33
|
+
.Pp
|
34
|
+
.Sh DESCRIPTION
|
35
|
+
.Nm
|
36
|
+
is the REPL(read-eval-print loop) environment for Ruby programs.
|
37
|
+
.Pp
|
38
|
+
.Sh OPTIONS
|
39
|
+
.Bl -tag -width "1234567890123" -compact
|
40
|
+
.Pp
|
41
|
+
.It Fl -version
|
42
|
+
Prints the version of
|
43
|
+
.Nm .
|
44
|
+
.Pp
|
45
|
+
.It Fl E Ar external Ns Op : Ns Ar internal
|
46
|
+
.It Fl -encoding Ar external Ns Op : Ns Ar internal
|
47
|
+
Same as `ruby -E' .
|
48
|
+
Specifies the default value(s) for external encodings and internal encoding. Values should be separated with colon (:).
|
49
|
+
.Pp
|
50
|
+
You can omit the one for internal encodings, then the value
|
51
|
+
.Pf ( Li "Encoding.default_internal" ) will be nil.
|
52
|
+
.Pp
|
53
|
+
.It Fl I Ar path
|
54
|
+
Same as `ruby -I' .
|
55
|
+
Specifies
|
56
|
+
.Li $LOAD_PATH
|
57
|
+
directory
|
58
|
+
.Pp
|
59
|
+
.It Fl U
|
60
|
+
Same as `ruby -U' .
|
61
|
+
Sets the default value for internal encodings
|
62
|
+
.Pf ( Li "Encoding.default_internal" ) to UTF-8.
|
63
|
+
.Pp
|
64
|
+
.It Fl d
|
65
|
+
Same as `ruby -d' .
|
66
|
+
Sets
|
67
|
+
.Li $DEBUG
|
68
|
+
to true.
|
69
|
+
.Pp
|
70
|
+
.It Fl f
|
71
|
+
Suppresses read of
|
72
|
+
.Pa ~/.irbrc .
|
73
|
+
.Pp
|
74
|
+
.It Fl w
|
75
|
+
Same as `ruby -w' .
|
76
|
+
.Pp
|
77
|
+
.Pp
|
78
|
+
.It Fl W
|
79
|
+
Same as `ruby -W' .
|
80
|
+
.Pp
|
81
|
+
.It Fl h
|
82
|
+
.It Fl -help
|
83
|
+
Prints a summary of the options.
|
84
|
+
.Pp
|
85
|
+
.It Fl r Ar library
|
86
|
+
Same as `ruby -r'.
|
87
|
+
Causes irb to load the library using require.
|
88
|
+
.Pp
|
89
|
+
.It Fl -inspect
|
90
|
+
Uses `inspect' for output (default except for bc mode)
|
91
|
+
.Pp
|
92
|
+
.It Fl -noinspect
|
93
|
+
Doesn't use inspect for output
|
94
|
+
.Pp
|
95
|
+
.It Fl -multiline
|
96
|
+
Uses multiline editor module.
|
97
|
+
.Pp
|
98
|
+
.It Fl -nomultiline
|
99
|
+
Doesn't use multiline editor module.
|
100
|
+
.Pp
|
101
|
+
.It Fl -singleline
|
102
|
+
Uses singleline editor module.
|
103
|
+
.Pp
|
104
|
+
.It Fl -nosingleline
|
105
|
+
Doesn't use singleline editor module.
|
106
|
+
.Pp
|
107
|
+
.Pp
|
108
|
+
.It Fl -extra-doc-dir
|
109
|
+
Add an extra doc dir for the doc dialog.
|
110
|
+
.Pp
|
111
|
+
.Pp
|
112
|
+
.It Fl -echo
|
113
|
+
Show result (default).
|
114
|
+
.Pp
|
115
|
+
.It Fl -noecho
|
116
|
+
Don't show result.
|
117
|
+
.Pp
|
118
|
+
.Pp
|
119
|
+
.It Fl -echo-on-assignment
|
120
|
+
Show result on assignment.
|
121
|
+
.Pp
|
122
|
+
.It Fl -noecho-on-assignment
|
123
|
+
Don't show result on assignment.
|
124
|
+
.Pp
|
125
|
+
.It Fl -truncate-echo-on-assignment
|
126
|
+
Show truncated result on assignment (default).
|
127
|
+
.Pp
|
128
|
+
.Pp
|
129
|
+
.It Fl -colorize
|
130
|
+
Use colorization.
|
131
|
+
.Pp
|
132
|
+
.It Fl -nocolorize
|
133
|
+
Don't use colorization.
|
134
|
+
.Pp
|
135
|
+
.Pp
|
136
|
+
.It Fl -autocomplete
|
137
|
+
Use autocompletion.
|
138
|
+
.Pp
|
139
|
+
.It Fl -noautocomplete
|
140
|
+
Don't use autocompletion.
|
141
|
+
.Pp
|
142
|
+
.Pp
|
143
|
+
.It Fl -verbose
|
144
|
+
Show details.
|
145
|
+
.Pp
|
146
|
+
.It Fl -noverbose
|
147
|
+
Don't show details.
|
148
|
+
.Pp
|
149
|
+
.It Fl -prompt Ar mode
|
150
|
+
.It Fl -prompt-mode Ar mode
|
151
|
+
Switch prompt mode. Pre-defined prompt modes are
|
152
|
+
`default', `simple', `xmp' and `inf-ruby'.
|
153
|
+
.Pp
|
154
|
+
.It Fl -inf-ruby-mode
|
155
|
+
Uses prompt appropriate for inf-ruby-mode on emacs.
|
156
|
+
Suppresses --multiline and --singleline.
|
157
|
+
.Pp
|
158
|
+
.It Fl -simple-prompt
|
159
|
+
Makes prompts simple.
|
160
|
+
.Pp
|
161
|
+
.It Fl -noprompt
|
162
|
+
No prompt mode.
|
163
|
+
.Pp
|
164
|
+
.It Fl -tracer
|
165
|
+
Displays trace for each execution of commands.
|
166
|
+
.Pp
|
167
|
+
.It Fl -back-trace-limit Ar n
|
168
|
+
Displays backtrace top
|
169
|
+
.Ar n
|
170
|
+
and tail
|
171
|
+
.Ar n Ns .
|
172
|
+
The default value is 16.
|
173
|
+
.El
|
174
|
+
.Pp
|
175
|
+
.Sh ENVIRONMENT
|
176
|
+
.Bl -tag -compact
|
177
|
+
.It Ev IRBRC
|
178
|
+
.Pp
|
179
|
+
.El
|
180
|
+
.Pp
|
181
|
+
Also
|
182
|
+
.Nm
|
183
|
+
depends on same variables as
|
184
|
+
.Xr ruby 1 .
|
185
|
+
.Pp
|
186
|
+
.Sh FILES
|
187
|
+
.Bl -tag -compact
|
188
|
+
.It Pa ~/.irbrc
|
189
|
+
Personal irb initialization.
|
190
|
+
.Pp
|
191
|
+
.El
|
192
|
+
.Pp
|
193
|
+
.Sh EXAMPLES
|
194
|
+
.Dl % irb
|
195
|
+
.Dl irb(main):001:0> Ic 1 + 1
|
196
|
+
.Dl 2
|
197
|
+
.Dl irb(main):002:0> Ic def t(x)
|
198
|
+
.Dl irb(main):003:1> Ic x + 1
|
199
|
+
.Dl irb(main):004:1> Ic end
|
200
|
+
.Dl => :t
|
201
|
+
.Dl irb(main):005:0> Ic t(3)
|
202
|
+
.Dl => 4
|
203
|
+
.Dl irb(main):006:0> Ic if t(3) == 4
|
204
|
+
.Dl irb(main):007:1> Ic p :ok
|
205
|
+
.Dl irb(main):008:1> Ic end
|
206
|
+
.Dl :ok
|
207
|
+
.Dl => :ok
|
208
|
+
.Dl irb(main):009:0> Ic quit
|
209
|
+
.Dl %
|
210
|
+
.Pp
|
211
|
+
.Sh SEE ALSO
|
212
|
+
.Xr ruby 1 .
|
213
|
+
.Pp
|
214
|
+
.Sh REPORTING BUGS
|
215
|
+
.Bl -bullet
|
216
|
+
.It
|
217
|
+
Security vulnerabilities should be reported via an email to
|
218
|
+
.Mt security@ruby-lang.org .
|
219
|
+
Reported problems will be published after being fixed.
|
220
|
+
.Pp
|
221
|
+
.It
|
222
|
+
Other bugs and feature requests can be reported via the
|
223
|
+
Ruby Issue Tracking System
|
224
|
+
.Pq Lk https://bugs.ruby-lang.org/ .
|
225
|
+
Do not report security vulnerabilities
|
226
|
+
via this system because it publishes the vulnerabilities immediately.
|
227
|
+
.El
|
228
|
+
.Sh AUTHORS
|
229
|
+
Written by Keiju ISHITSUKA.
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: reline
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 0.3.0
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: 0.3.0
|
41
27
|
description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
42
28
|
email:
|
43
29
|
- keiju@ruby-lang.org
|
@@ -46,26 +32,35 @@ executables:
|
|
46
32
|
extensions: []
|
47
33
|
extra_rdoc_files: []
|
48
34
|
files:
|
49
|
-
- ".
|
50
|
-
- ".travis.yml"
|
35
|
+
- ".document"
|
51
36
|
- Gemfile
|
52
37
|
- LICENSE.txt
|
53
38
|
- README.md
|
54
39
|
- Rakefile
|
55
40
|
- bin/console
|
56
41
|
- bin/setup
|
42
|
+
- doc/irb/irb-tools.rd.ja
|
43
|
+
- doc/irb/irb.rd.ja
|
57
44
|
- exe/irb
|
58
45
|
- irb.gemspec
|
59
46
|
- lib/irb.rb
|
60
47
|
- lib/irb/cmd/chws.rb
|
61
48
|
- lib/irb/cmd/fork.rb
|
62
49
|
- lib/irb/cmd/help.rb
|
50
|
+
- lib/irb/cmd/info.rb
|
63
51
|
- lib/irb/cmd/load.rb
|
52
|
+
- lib/irb/cmd/ls.rb
|
53
|
+
- lib/irb/cmd/measure.rb
|
64
54
|
- lib/irb/cmd/nop.rb
|
65
55
|
- lib/irb/cmd/pushws.rb
|
56
|
+
- lib/irb/cmd/show_source.rb
|
66
57
|
- lib/irb/cmd/subirb.rb
|
58
|
+
- lib/irb/cmd/whereami.rb
|
59
|
+
- lib/irb/color.rb
|
60
|
+
- lib/irb/color_printer.rb
|
67
61
|
- lib/irb/completion.rb
|
68
62
|
- lib/irb/context.rb
|
63
|
+
- lib/irb/easter-egg.rb
|
69
64
|
- lib/irb/ext/change-ws.rb
|
70
65
|
- lib/irb/ext/history.rb
|
71
66
|
- lib/irb/ext/loader.rb
|
@@ -80,7 +75,6 @@ files:
|
|
80
75
|
- lib/irb/init.rb
|
81
76
|
- lib/irb/input-method.rb
|
82
77
|
- lib/irb/inspector.rb
|
83
|
-
- lib/irb/lc/.document
|
84
78
|
- lib/irb/lc/error.rb
|
85
79
|
- lib/irb/lc/help-message
|
86
80
|
- lib/irb/lc/ja/encoding_aliases.rb
|
@@ -91,18 +85,19 @@ files:
|
|
91
85
|
- lib/irb/notifier.rb
|
92
86
|
- lib/irb/output-method.rb
|
93
87
|
- lib/irb/ruby-lex.rb
|
94
|
-
- lib/irb/
|
95
|
-
- lib/irb/slex.rb
|
88
|
+
- lib/irb/ruby_logo.aa
|
96
89
|
- lib/irb/src_encoding.rb
|
97
90
|
- lib/irb/version.rb
|
98
91
|
- lib/irb/workspace.rb
|
99
92
|
- lib/irb/ws-for-case-2.rb
|
100
93
|
- lib/irb/xmp.rb
|
94
|
+
- man/irb.1
|
101
95
|
homepage: https://github.com/ruby/irb
|
102
96
|
licenses:
|
97
|
+
- Ruby
|
103
98
|
- BSD-2-Clause
|
104
99
|
metadata: {}
|
105
|
-
post_install_message:
|
100
|
+
post_install_message:
|
106
101
|
rdoc_options: []
|
107
102
|
require_paths:
|
108
103
|
- lib
|
@@ -110,16 +105,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
105
|
requirements:
|
111
106
|
- - ">="
|
112
107
|
- !ruby/object:Gem::Version
|
113
|
-
version: '
|
108
|
+
version: '2.5'
|
114
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
110
|
requirements:
|
116
111
|
- - ">="
|
117
112
|
- !ruby/object:Gem::Version
|
118
113
|
version: '0'
|
119
114
|
requirements: []
|
120
|
-
|
121
|
-
|
122
|
-
signing_key:
|
115
|
+
rubygems_version: 3.2.22
|
116
|
+
signing_key:
|
123
117
|
specification_version: 4
|
124
118
|
summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
125
119
|
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/lib/irb/lc/.document
DELETED
data/lib/irb/ruby-token.rb
DELETED
@@ -1,267 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
#
|
3
|
-
# irb/ruby-token.rb - ruby tokens
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
|
-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
-
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# :stopdoc:
|
13
|
-
module RubyToken
|
14
|
-
EXPR_BEG = :EXPR_BEG
|
15
|
-
EXPR_MID = :EXPR_MID
|
16
|
-
EXPR_END = :EXPR_END
|
17
|
-
EXPR_ARG = :EXPR_ARG
|
18
|
-
EXPR_FNAME = :EXPR_FNAME
|
19
|
-
EXPR_DOT = :EXPR_DOT
|
20
|
-
EXPR_CLASS = :EXPR_CLASS
|
21
|
-
|
22
|
-
class Token
|
23
|
-
def initialize(seek, line_no, char_no)
|
24
|
-
@seek = seek
|
25
|
-
@line_no = line_no
|
26
|
-
@char_no = char_no
|
27
|
-
end
|
28
|
-
attr_reader :seek, :line_no, :char_no
|
29
|
-
end
|
30
|
-
|
31
|
-
class TkNode < Token
|
32
|
-
def initialize(seek, line_no, char_no)
|
33
|
-
super
|
34
|
-
end
|
35
|
-
attr_reader :node
|
36
|
-
end
|
37
|
-
|
38
|
-
class TkId < Token
|
39
|
-
def initialize(seek, line_no, char_no, name)
|
40
|
-
super(seek, line_no, char_no)
|
41
|
-
@name = name
|
42
|
-
end
|
43
|
-
attr_reader :name
|
44
|
-
end
|
45
|
-
|
46
|
-
class TkVal < Token
|
47
|
-
def initialize(seek, line_no, char_no, value = nil)
|
48
|
-
super(seek, line_no, char_no)
|
49
|
-
@value = value
|
50
|
-
end
|
51
|
-
attr_reader :value
|
52
|
-
end
|
53
|
-
|
54
|
-
class TkOp < Token
|
55
|
-
attr_accessor :name
|
56
|
-
end
|
57
|
-
|
58
|
-
class TkOPASGN < TkOp
|
59
|
-
def initialize(seek, line_no, char_no, op)
|
60
|
-
super(seek, line_no, char_no)
|
61
|
-
op = TkReading2Token[op][0] unless op.kind_of?(Symbol)
|
62
|
-
@op = op
|
63
|
-
end
|
64
|
-
attr_reader :op
|
65
|
-
end
|
66
|
-
|
67
|
-
class TkUnknownChar < Token
|
68
|
-
def initialize(seek, line_no, char_no, id)
|
69
|
-
super(seek, line_no, char_no)
|
70
|
-
@name = name
|
71
|
-
end
|
72
|
-
attr_reader :name
|
73
|
-
end
|
74
|
-
|
75
|
-
class TkError < Token
|
76
|
-
end
|
77
|
-
|
78
|
-
def Token(token, value = nil)
|
79
|
-
case token
|
80
|
-
when String
|
81
|
-
if (tk = TkReading2Token[token]).nil?
|
82
|
-
IRB.fail TkReading2TokenNoKey, token
|
83
|
-
end
|
84
|
-
tk = Token(tk[0], value)
|
85
|
-
if tk.kind_of?(TkOp)
|
86
|
-
tk.name = token
|
87
|
-
end
|
88
|
-
return tk
|
89
|
-
when Symbol
|
90
|
-
if (tk = TkSymbol2Token[token]).nil?
|
91
|
-
IRB.fail TkSymbol2TokenNoKey, token
|
92
|
-
end
|
93
|
-
return Token(tk[0], value)
|
94
|
-
else
|
95
|
-
if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
|
96
|
-
token.new(@prev_seek, @prev_line_no, @prev_char_no)
|
97
|
-
else
|
98
|
-
token.new(@prev_seek, @prev_line_no, @prev_char_no, value)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
TokenDefinitions = [
|
104
|
-
[:TkCLASS, TkId, "class", EXPR_CLASS],
|
105
|
-
[:TkMODULE, TkId, "module", EXPR_BEG],
|
106
|
-
[:TkDEF, TkId, "def", EXPR_FNAME],
|
107
|
-
[:TkUNDEF, TkId, "undef", EXPR_FNAME],
|
108
|
-
[:TkBEGIN, TkId, "begin", EXPR_BEG],
|
109
|
-
[:TkRESCUE, TkId, "rescue", EXPR_MID],
|
110
|
-
[:TkENSURE, TkId, "ensure", EXPR_BEG],
|
111
|
-
[:TkEND, TkId, "end", EXPR_END],
|
112
|
-
[:TkIF, TkId, "if", EXPR_BEG, :TkIF_MOD],
|
113
|
-
[:TkUNLESS, TkId, "unless", EXPR_BEG, :TkUNLESS_MOD],
|
114
|
-
[:TkTHEN, TkId, "then", EXPR_BEG],
|
115
|
-
[:TkELSIF, TkId, "elsif", EXPR_BEG],
|
116
|
-
[:TkELSE, TkId, "else", EXPR_BEG],
|
117
|
-
[:TkCASE, TkId, "case", EXPR_BEG],
|
118
|
-
[:TkWHEN, TkId, "when", EXPR_BEG],
|
119
|
-
[:TkWHILE, TkId, "while", EXPR_BEG, :TkWHILE_MOD],
|
120
|
-
[:TkUNTIL, TkId, "until", EXPR_BEG, :TkUNTIL_MOD],
|
121
|
-
[:TkFOR, TkId, "for", EXPR_BEG],
|
122
|
-
[:TkBREAK, TkId, "break", EXPR_END],
|
123
|
-
[:TkNEXT, TkId, "next", EXPR_END],
|
124
|
-
[:TkREDO, TkId, "redo", EXPR_END],
|
125
|
-
[:TkRETRY, TkId, "retry", EXPR_END],
|
126
|
-
[:TkIN, TkId, "in", EXPR_BEG],
|
127
|
-
[:TkDO, TkId, "do", EXPR_BEG],
|
128
|
-
[:TkRETURN, TkId, "return", EXPR_MID],
|
129
|
-
[:TkYIELD, TkId, "yield", EXPR_END],
|
130
|
-
[:TkSUPER, TkId, "super", EXPR_END],
|
131
|
-
[:TkSELF, TkId, "self", EXPR_END],
|
132
|
-
[:TkNIL, TkId, "nil", EXPR_END],
|
133
|
-
[:TkTRUE, TkId, "true", EXPR_END],
|
134
|
-
[:TkFALSE, TkId, "false", EXPR_END],
|
135
|
-
[:TkAND, TkId, "and", EXPR_BEG],
|
136
|
-
[:TkOR, TkId, "or", EXPR_BEG],
|
137
|
-
[:TkNOT, TkId, "not", EXPR_BEG],
|
138
|
-
[:TkIF_MOD, TkId],
|
139
|
-
[:TkUNLESS_MOD, TkId],
|
140
|
-
[:TkWHILE_MOD, TkId],
|
141
|
-
[:TkUNTIL_MOD, TkId],
|
142
|
-
[:TkALIAS, TkId, "alias", EXPR_FNAME],
|
143
|
-
[:TkDEFINED, TkId, "defined?", EXPR_END],
|
144
|
-
[:TklBEGIN, TkId, "BEGIN", EXPR_END],
|
145
|
-
[:TklEND, TkId, "END", EXPR_END],
|
146
|
-
[:Tk__LINE__, TkId, "__LINE__", EXPR_END],
|
147
|
-
[:Tk__FILE__, TkId, "__FILE__", EXPR_END],
|
148
|
-
|
149
|
-
[:TkIDENTIFIER, TkId],
|
150
|
-
[:TkFID, TkId],
|
151
|
-
[:TkGVAR, TkId],
|
152
|
-
[:TkCVAR, TkId],
|
153
|
-
[:TkIVAR, TkId],
|
154
|
-
[:TkCONSTANT, TkId],
|
155
|
-
|
156
|
-
[:TkINTEGER, TkVal],
|
157
|
-
[:TkFLOAT, TkVal],
|
158
|
-
[:TkSTRING, TkVal],
|
159
|
-
[:TkXSTRING, TkVal],
|
160
|
-
[:TkREGEXP, TkVal],
|
161
|
-
[:TkSYMBOL, TkVal],
|
162
|
-
|
163
|
-
[:TkDSTRING, TkNode],
|
164
|
-
[:TkDXSTRING, TkNode],
|
165
|
-
[:TkDREGEXP, TkNode],
|
166
|
-
[:TkNTH_REF, TkNode],
|
167
|
-
[:TkBACK_REF, TkNode],
|
168
|
-
|
169
|
-
[:TkUPLUS, TkOp, "+@"],
|
170
|
-
[:TkUMINUS, TkOp, "-@"],
|
171
|
-
[:TkPOW, TkOp, "**"],
|
172
|
-
[:TkCMP, TkOp, "<=>"],
|
173
|
-
[:TkEQ, TkOp, "=="],
|
174
|
-
[:TkEQQ, TkOp, "==="],
|
175
|
-
[:TkNEQ, TkOp, "!="],
|
176
|
-
[:TkGEQ, TkOp, ">="],
|
177
|
-
[:TkLEQ, TkOp, "<="],
|
178
|
-
[:TkANDOP, TkOp, "&&"],
|
179
|
-
[:TkOROP, TkOp, "||"],
|
180
|
-
[:TkMATCH, TkOp, "=~"],
|
181
|
-
[:TkNMATCH, TkOp, "!~"],
|
182
|
-
[:TkDOT2, TkOp, ".."],
|
183
|
-
[:TkDOT3, TkOp, "..."],
|
184
|
-
[:TkAREF, TkOp, "[]"],
|
185
|
-
[:TkASET, TkOp, "[]="],
|
186
|
-
[:TkLSHFT, TkOp, "<<"],
|
187
|
-
[:TkRSHFT, TkOp, ">>"],
|
188
|
-
[:TkCOLON2, TkOp],
|
189
|
-
[:TkCOLON3, TkOp],
|
190
|
-
[:TkASSOC, TkOp, "=>"],
|
191
|
-
[:TkQUESTION, TkOp, "?"], #?
|
192
|
-
[:TkCOLON, TkOp, ":"], #:
|
193
|
-
|
194
|
-
[:TkfLPAREN], # func( #
|
195
|
-
[:TkfLBRACK], # func[ #
|
196
|
-
[:TkfLBRACE], # func{ #
|
197
|
-
[:TkSTAR], # *arg
|
198
|
-
[:TkAMPER], # &arg #
|
199
|
-
[:TkSYMBEG], # :SYMBOL
|
200
|
-
|
201
|
-
[:TkGT, TkOp, ">"],
|
202
|
-
[:TkLT, TkOp, "<"],
|
203
|
-
[:TkPLUS, TkOp, "+"],
|
204
|
-
[:TkMINUS, TkOp, "-"],
|
205
|
-
[:TkMULT, TkOp, "*"],
|
206
|
-
[:TkDIV, TkOp, "/"],
|
207
|
-
[:TkMOD, TkOp, "%"],
|
208
|
-
[:TkBITOR, TkOp, "|"],
|
209
|
-
[:TkBITXOR, TkOp, "^"],
|
210
|
-
[:TkBITAND, TkOp, "&"],
|
211
|
-
[:TkBITNOT, TkOp, "~"],
|
212
|
-
[:TkNOTOP, TkOp, "!"],
|
213
|
-
|
214
|
-
[:TkBACKQUOTE, TkOp, "`"],
|
215
|
-
|
216
|
-
[:TkASSIGN, Token, "="],
|
217
|
-
[:TkDOT, Token, "."],
|
218
|
-
[:TkLPAREN, Token, "("], #(exp)
|
219
|
-
[:TkLBRACK, Token, "["], #[arry]
|
220
|
-
[:TkLBRACE, Token, "{"], #{hash}
|
221
|
-
[:TkRPAREN, Token, ")"],
|
222
|
-
[:TkRBRACK, Token, "]"],
|
223
|
-
[:TkRBRACE, Token, "}"],
|
224
|
-
[:TkCOMMA, Token, ","],
|
225
|
-
[:TkSEMICOLON, Token, ";"],
|
226
|
-
|
227
|
-
[:TkCOMMENT],
|
228
|
-
[:TkRD_COMMENT],
|
229
|
-
[:TkSPACE],
|
230
|
-
[:TkNL],
|
231
|
-
[:TkEND_OF_SCRIPT],
|
232
|
-
|
233
|
-
[:TkBACKSLASH, TkUnknownChar, "\\"],
|
234
|
-
[:TkAT, TkUnknownChar, "@"],
|
235
|
-
[:TkDOLLAR, TkUnknownChar, "$"],
|
236
|
-
]
|
237
|
-
|
238
|
-
# {reading => token_class}
|
239
|
-
# {reading => [token_class, *opt]}
|
240
|
-
TkReading2Token = {}
|
241
|
-
TkSymbol2Token = {}
|
242
|
-
|
243
|
-
def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
|
244
|
-
token_n = token_n.id2name if token_n.kind_of?(Symbol)
|
245
|
-
if RubyToken.const_defined?(token_n)
|
246
|
-
IRB.fail AlreadyDefinedToken, token_n
|
247
|
-
end
|
248
|
-
token_c = eval("class #{token_n} < #{super_token}; end; #{token_n}")
|
249
|
-
|
250
|
-
if reading
|
251
|
-
if TkReading2Token[reading]
|
252
|
-
IRB.fail TkReading2TokenDuplicateError, token_n, reading
|
253
|
-
end
|
254
|
-
if opts.empty?
|
255
|
-
TkReading2Token[reading] = [token_c]
|
256
|
-
else
|
257
|
-
TkReading2Token[reading] = [token_c].concat(opts)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
TkSymbol2Token[token_n.intern] = token_c
|
261
|
-
end
|
262
|
-
|
263
|
-
for defs in TokenDefinitions
|
264
|
-
def_token(*defs)
|
265
|
-
end
|
266
|
-
end
|
267
|
-
# :startdoc:
|