shoesgem 0.1424.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +30 -0
- data/README.rdoc +31 -0
- data/lib/shoes.rb +4 -0
- data/shoes/CHANGELOG.txt +21 -0
- data/shoes/COPYING.txt +30 -0
- data/shoes/README.txt +117 -0
- data/shoes/VERSION.txt +1 -0
- data/shoes/fonts/Coolvetica.ttf +0 -0
- data/shoes/fonts/Lacuna.ttf +0 -0
- data/shoes/freetype6.dll +0 -0
- data/shoes/lib/shoes/cache.rb +54 -0
- data/shoes/lib/shoes/data.rb +39 -0
- data/shoes/lib/shoes/help.rb +421 -0
- data/shoes/lib/shoes/image.rb +25 -0
- data/shoes/lib/shoes/inspect.rb +128 -0
- data/shoes/lib/shoes/log.rb +48 -0
- data/shoes/lib/shoes/minitar.rb +986 -0
- data/shoes/lib/shoes/override.rb +38 -0
- data/shoes/lib/shoes/pack.rb +503 -0
- data/shoes/lib/shoes/search.rb +46 -0
- data/shoes/lib/shoes/setup.rb +329 -0
- data/shoes/lib/shoes/shy.rb +131 -0
- data/shoes/lib/shoes/shybuilder.rb +44 -0
- data/shoes/lib/shoes.rb +522 -0
- data/shoes/libcairo-2.dll +0 -0
- data/shoes/libeay32.dll +0 -0
- data/shoes/libexpat-1.dll +0 -0
- data/shoes/libfontconfig-1.dll +0 -0
- data/shoes/libgio-2.0-0.dll +0 -0
- data/shoes/libglib-2.0-0.dll +0 -0
- data/shoes/libgmodule-2.0-0.dll +0 -0
- data/shoes/libgobject-2.0-0.dll +0 -0
- data/shoes/libgthread-2.0-0.dll +0 -0
- data/shoes/libiconv2.dll +0 -0
- data/shoes/libjpeg-8.dll +0 -0
- data/shoes/libpango-1.0-0.dll +0 -0
- data/shoes/libpangocairo-1.0-0.dll +0 -0
- data/shoes/libpangoft2-1.0-0.dll +0 -0
- data/shoes/libpangowin32-1.0-0.dll +0 -0
- data/shoes/libpng14-14.dll +0 -0
- data/shoes/libportaudio-2.dll +0 -0
- data/shoes/libshoes.dll +0 -0
- data/shoes/libssl32.dll +0 -0
- data/shoes/libungif4.dll +0 -0
- data/shoes/msvcrt-ruby191.dll +0 -0
- data/shoes/readline5.dll +0 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/fast_xs.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/blankslate.rb +63 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/builder.rb +216 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/elements.rb +510 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/htmlinfo.rb +691 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/inspect.rb +103 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/modules.rb +40 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/parse.rb +38 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/tag.rb +202 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/tags.rb +164 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/traverse.rb +838 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/xchar.rb +94 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot.rb +26 -0
- data/shoes/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot_scan.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/add/core.rb +135 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/add/rails.rb +58 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/common.rb +354 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext/generator.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext/parser.so +0 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/ext.rb +13 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json/version.rb +9 -0
- data/shoes/ruby/gems/1.9.1/gems/json-shoes-1.1.3/lib/json.rb +8 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/constants.rb +49 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/database.rb +721 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/api.rb +152 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/dl/driver.rb +307 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/driver/native/driver.rb +219 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/errors.rb +68 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/pragmas.rb +271 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/resultset.rb +180 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/statement.rb +231 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/translator.rb +109 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/value.rb +57 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3/version.rb +16 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3.rb +1 -0
- data/shoes/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5-x86-mswin32/lib/sqlite3_api.so +0 -0
- data/shoes/ruby/gems/1.9.1/specifications/hpricot-0.8.1.gemspec +32 -0
- data/shoes/ruby/gems/1.9.1/specifications/json-shoes-1.1.3.gemspec +34 -0
- data/shoes/ruby/gems/1.9.1/specifications/sqlite3-ruby-1.2.5-x86-mswin32.gemspec +46 -0
- data/shoes/ruby/lib/English.rb +155 -0
- data/shoes/ruby/lib/Win32API.rb +28 -0
- data/shoes/ruby/lib/abbrev.rb +103 -0
- data/shoes/ruby/lib/base64.rb +91 -0
- data/shoes/ruby/lib/benchmark.rb +573 -0
- data/shoes/ruby/lib/bigdecimal/jacobian.rb +85 -0
- data/shoes/ruby/lib/bigdecimal/ludcmp.rb +86 -0
- data/shoes/ruby/lib/bigdecimal/math.rb +237 -0
- data/shoes/ruby/lib/bigdecimal/newton.rb +77 -0
- data/shoes/ruby/lib/bigdecimal/util.rb +53 -0
- data/shoes/ruby/lib/cgi/cookie.rb +144 -0
- data/shoes/ruby/lib/cgi/core.rb +786 -0
- data/shoes/ruby/lib/cgi/html.rb +1021 -0
- data/shoes/ruby/lib/cgi/session/pstore.rb +111 -0
- data/shoes/ruby/lib/cgi/session.rb +537 -0
- data/shoes/ruby/lib/cgi/util.rb +181 -0
- data/shoes/ruby/lib/cgi.rb +274 -0
- data/shoes/ruby/lib/cmath.rb +233 -0
- data/shoes/ruby/lib/complex.rb +24 -0
- data/shoes/ruby/lib/csv.rb +2320 -0
- data/shoes/ruby/lib/date/format.rb +1313 -0
- data/shoes/ruby/lib/date.rb +1834 -0
- data/shoes/ruby/lib/debug.rb +907 -0
- data/shoes/ruby/lib/delegate.rb +311 -0
- data/shoes/ruby/lib/digest/hmac.rb +274 -0
- data/shoes/ruby/lib/digest/sha2.rb +74 -0
- data/shoes/ruby/lib/digest.rb +50 -0
- data/shoes/ruby/lib/dl/callback.rb +69 -0
- data/shoes/ruby/lib/dl/cparser.rb +109 -0
- data/shoes/ruby/lib/dl/func.rb +153 -0
- data/shoes/ruby/lib/dl/import.rb +215 -0
- data/shoes/ruby/lib/dl/pack.rb +173 -0
- data/shoes/ruby/lib/dl/stack.rb +146 -0
- data/shoes/ruby/lib/dl/struct.rb +213 -0
- data/shoes/ruby/lib/dl/types.rb +40 -0
- data/shoes/ruby/lib/dl/value.rb +112 -0
- data/shoes/ruby/lib/drb/acl.rb +146 -0
- data/shoes/ruby/lib/drb/drb.rb +1778 -0
- data/shoes/ruby/lib/drb/eq.rb +16 -0
- data/shoes/ruby/lib/drb/extserv.rb +71 -0
- data/shoes/ruby/lib/drb/extservm.rb +85 -0
- data/shoes/ruby/lib/drb/gw.rb +122 -0
- data/shoes/ruby/lib/drb/invokemethod.rb +34 -0
- data/shoes/ruby/lib/drb/observer.rb +22 -0
- data/shoes/ruby/lib/drb/ssl.rb +190 -0
- data/shoes/ruby/lib/drb/timeridconv.rb +91 -0
- data/shoes/ruby/lib/drb/unix.rb +108 -0
- data/shoes/ruby/lib/drb.rb +2 -0
- data/shoes/ruby/lib/e2mmap.rb +172 -0
- data/shoes/ruby/lib/erb.rb +902 -0
- data/shoes/ruby/lib/fileutils.rb +1592 -0
- data/shoes/ruby/lib/find.rb +81 -0
- data/shoes/ruby/lib/forwardable.rb +270 -0
- data/shoes/ruby/lib/ftsearch/analysis/analyzer.rb +16 -0
- data/shoes/ruby/lib/ftsearch/analysis/simple_identifier_analyzer.rb +23 -0
- data/shoes/ruby/lib/ftsearch/analysis/whitespace_analyzer.rb +22 -0
- data/shoes/ruby/lib/ftsearch/document_map_reader.rb +106 -0
- data/shoes/ruby/lib/ftsearch/document_map_writer.rb +46 -0
- data/shoes/ruby/lib/ftsearch/field_infos.rb +46 -0
- data/shoes/ruby/lib/ftsearch/fragment_writer.rb +114 -0
- data/shoes/ruby/lib/ftsearch/fulltext_reader.rb +52 -0
- data/shoes/ruby/lib/ftsearch/fulltext_writer.rb +75 -0
- data/shoes/ruby/lib/ftsearch/suffix_array_reader.rb +275 -0
- data/shoes/ruby/lib/ftsearch/suffix_array_writer.rb +99 -0
- data/shoes/ruby/lib/ftsearch/util.rb +21 -0
- data/shoes/ruby/lib/getoptlong.rb +610 -0
- data/shoes/ruby/lib/gserver.rb +253 -0
- data/shoes/ruby/lib/i386-mingw32/bigdecimal.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/binject.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/bloops.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/continuation.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/coverage.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/curses.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/bubblebabble.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/md5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/rmd160.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/sha1.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest/sha2.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/digest.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/dl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/big5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/cp949.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/emacs_mule.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/encdb.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_jp.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_kr.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/euc_tw.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gb18030.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gb2312.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/gbk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_1.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_10.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_11.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_13.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_14.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_15.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_16.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_2.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_3.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_4.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_6.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_7.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_8.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/iso_8859_9.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/koi8_r.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/koi8_u.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/shift_jis.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/big5.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/chinese.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/escape.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/gb18030.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/gbk.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/iso2022.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese_euc.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/japanese_sjis.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/korean.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/single_byte.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/transdb.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/trans/utf_16_32.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_16be.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_16le.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_32be.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/utf_32le.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/enc/windows_1251.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/etc.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/fcntl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/fiber.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/ftsearchrt.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/gdbm.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/iconv.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/io/wait.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/json/ext/generator.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/json/ext/parser.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/mathn/complex.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/mathn/rational.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/nkf.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/openssl.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/racc/cparse.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/rbconfig.rb +196 -0
- data/shoes/ruby/lib/i386-mingw32/readline.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/ripper.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/sdbm.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/socket.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/stringio.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/strscan.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/syck.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/win32ole.so +0 -0
- data/shoes/ruby/lib/i386-mingw32/zlib.so +0 -0
- data/shoes/ruby/lib/io/nonblock.rb +23 -0
- data/shoes/ruby/lib/ipaddr.rb +813 -0
- data/shoes/ruby/lib/irb/cmd/chws.rb +32 -0
- data/shoes/ruby/lib/irb/cmd/fork.rb +38 -0
- data/shoes/ruby/lib/irb/cmd/help.rb +36 -0
- data/shoes/ruby/lib/irb/cmd/load.rb +66 -0
- data/shoes/ruby/lib/irb/cmd/nop.rb +38 -0
- data/shoes/ruby/lib/irb/cmd/pushws.rb +38 -0
- data/shoes/ruby/lib/irb/cmd/subirb.rb +42 -0
- data/shoes/ruby/lib/irb/completion.rb +207 -0
- data/shoes/ruby/lib/irb/context.rb +255 -0
- data/shoes/ruby/lib/irb/ext/change-ws.rb +61 -0
- data/shoes/ruby/lib/irb/ext/history.rb +109 -0
- data/shoes/ruby/lib/irb/ext/loader.rb +119 -0
- data/shoes/ruby/lib/irb/ext/math-mode.rb +36 -0
- data/shoes/ruby/lib/irb/ext/multi-irb.rb +240 -0
- data/shoes/ruby/lib/irb/ext/save-history.rb +100 -0
- data/shoes/ruby/lib/irb/ext/tracer.rb +60 -0
- data/shoes/ruby/lib/irb/ext/use-loader.rb +64 -0
- data/shoes/ruby/lib/irb/ext/workspaces.rb +55 -0
- data/shoes/ruby/lib/irb/extend-command.rb +272 -0
- data/shoes/ruby/lib/irb/frame.rb +66 -0
- data/shoes/ruby/lib/irb/help.rb +35 -0
- data/shoes/ruby/lib/irb/init.rb +288 -0
- data/shoes/ruby/lib/irb/input-method.rb +142 -0
- data/shoes/ruby/lib/irb/lc/error.rb +29 -0
- data/shoes/ruby/lib/irb/lc/help-message +38 -0
- data/shoes/ruby/lib/irb/lc/ja/encoding_aliases.rb +8 -0
- data/shoes/ruby/lib/irb/lc/ja/error.rb +27 -0
- data/shoes/ruby/lib/irb/lc/ja/help-message +39 -0
- data/shoes/ruby/lib/irb/locale.rb +195 -0
- data/shoes/ruby/lib/irb/magic-file.rb +36 -0
- data/shoes/ruby/lib/irb/notifier.rb +144 -0
- data/shoes/ruby/lib/irb/output-method.rb +69 -0
- data/shoes/ruby/lib/irb/ruby-lex.rb +1188 -0
- data/shoes/ruby/lib/irb/ruby-token.rb +270 -0
- data/shoes/ruby/lib/irb/slex.rb +282 -0
- data/shoes/ruby/lib/irb/src_encoding.rb +4 -0
- data/shoes/ruby/lib/irb/version.rb +15 -0
- data/shoes/ruby/lib/irb/workspace.rb +108 -0
- data/shoes/ruby/lib/irb/ws-for-case-2.rb +14 -0
- data/shoes/ruby/lib/irb/xmp.rb +97 -0
- data/shoes/ruby/lib/irb.rb +354 -0
- data/shoes/ruby/lib/json/add/core.rb +135 -0
- data/shoes/ruby/lib/json/add/rails.rb +58 -0
- data/shoes/ruby/lib/json/common.rb +354 -0
- data/shoes/ruby/lib/json/editor.rb +1371 -0
- data/shoes/ruby/lib/json/ext.rb +15 -0
- data/shoes/ruby/lib/json/version.rb +9 -0
- data/shoes/ruby/lib/json.rb +297 -0
- data/shoes/ruby/lib/kconv.rb +282 -0
- data/shoes/ruby/lib/logger.rb +732 -0
- data/shoes/ruby/lib/mathn.rb +206 -0
- data/shoes/ruby/lib/matrix.rb +1381 -0
- data/shoes/ruby/lib/minitest/autorun.rb +9 -0
- data/shoes/ruby/lib/minitest/mock.rb +37 -0
- data/shoes/ruby/lib/minitest/spec.rb +89 -0
- data/shoes/ruby/lib/minitest/unit.rb +497 -0
- data/shoes/ruby/lib/mkmf.rb +1958 -0
- data/shoes/ruby/lib/monitor.rb +265 -0
- data/shoes/ruby/lib/mutex_m.rb +91 -0
- data/shoes/ruby/lib/net/ftp.rb +981 -0
- data/shoes/ruby/lib/net/http.rb +2399 -0
- data/shoes/ruby/lib/net/https.rb +136 -0
- data/shoes/ruby/lib/net/imap.rb +3500 -0
- data/shoes/ruby/lib/net/pop.rb +1000 -0
- data/shoes/ruby/lib/net/protocol.rb +382 -0
- data/shoes/ruby/lib/net/smtp.rb +1014 -0
- data/shoes/ruby/lib/net/telnet.rb +759 -0
- data/shoes/ruby/lib/observer.rb +193 -0
- data/shoes/ruby/lib/open-uri.rb +832 -0
- data/shoes/ruby/lib/open3.rb +98 -0
- data/shoes/ruby/lib/openssl/bn.rb +35 -0
- data/shoes/ruby/lib/openssl/buffering.rb +242 -0
- data/shoes/ruby/lib/openssl/cipher.rb +65 -0
- data/shoes/ruby/lib/openssl/digest.rb +61 -0
- data/shoes/ruby/lib/openssl/ssl.rb +178 -0
- data/shoes/ruby/lib/openssl/x509.rb +155 -0
- data/shoes/ruby/lib/openssl.rb +24 -0
- data/shoes/ruby/lib/optparse/date.rb +17 -0
- data/shoes/ruby/lib/optparse/shellwords.rb +6 -0
- data/shoes/ruby/lib/optparse/time.rb +10 -0
- data/shoes/ruby/lib/optparse/uri.rb +6 -0
- data/shoes/ruby/lib/optparse/version.rb +70 -0
- data/shoes/ruby/lib/optparse.rb +1810 -0
- data/shoes/ruby/lib/ostruct.rb +145 -0
- data/shoes/ruby/lib/pathname.rb +1099 -0
- data/shoes/ruby/lib/pp.rb +532 -0
- data/shoes/ruby/lib/prettyprint.rb +896 -0
- data/shoes/ruby/lib/prime.rb +471 -0
- data/shoes/ruby/lib/profile.rb +10 -0
- data/shoes/ruby/lib/profiler.rb +59 -0
- data/shoes/ruby/lib/pstore.rb +543 -0
- data/shoes/ruby/lib/racc/parser.rb +441 -0
- data/shoes/ruby/lib/rake/classic_namespace.rb +8 -0
- data/shoes/ruby/lib/rake/clean.rb +33 -0
- data/shoes/ruby/lib/rake/gempackagetask.rb +97 -0
- data/shoes/ruby/lib/rake/loaders/makefile.rb +35 -0
- data/shoes/ruby/lib/rake/packagetask.rb +185 -0
- data/shoes/ruby/lib/rake/rake_test_loader.rb +5 -0
- data/shoes/ruby/lib/rake/rdoctask.rb +147 -0
- data/shoes/ruby/lib/rake/runtest.rb +23 -0
- data/shoes/ruby/lib/rake/tasklib.rb +23 -0
- data/shoes/ruby/lib/rake/testtask.rb +161 -0
- data/shoes/ruby/lib/rake/win32.rb +34 -0
- data/shoes/ruby/lib/rake.rb +2465 -0
- data/shoes/ruby/lib/rational.rb +19 -0
- data/shoes/ruby/lib/rbconfig/datadir.rb +24 -0
- data/shoes/ruby/lib/rdoc/code_objects.rb +1061 -0
- data/shoes/ruby/lib/rdoc/diagram.rb +340 -0
- data/shoes/ruby/lib/rdoc/dot.rb +249 -0
- data/shoes/ruby/lib/rdoc/generator/chm/chm.rb +100 -0
- data/shoes/ruby/lib/rdoc/generator/chm.rb +113 -0
- data/shoes/ruby/lib/rdoc/generator/html/common.rb +24 -0
- data/shoes/ruby/lib/rdoc/generator/html/frameless.rb +92 -0
- data/shoes/ruby/lib/rdoc/generator/html/hefss.rb +150 -0
- data/shoes/ruby/lib/rdoc/generator/html/html.rb +769 -0
- data/shoes/ruby/lib/rdoc/generator/html/kilmer.rb +151 -0
- data/shoes/ruby/lib/rdoc/generator/html/kilmerfactory.rb +427 -0
- data/shoes/ruby/lib/rdoc/generator/html/one_page_html.rb +122 -0
- data/shoes/ruby/lib/rdoc/generator/html.rb +445 -0
- data/shoes/ruby/lib/rdoc/generator/ri.rb +226 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/class.texinfo.erb +44 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/file.texinfo.erb +6 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/method.texinfo.erb +6 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo/texinfo.erb +28 -0
- data/shoes/ruby/lib/rdoc/generator/texinfo.rb +81 -0
- data/shoes/ruby/lib/rdoc/generator/xml/rdf.rb +113 -0
- data/shoes/ruby/lib/rdoc/generator/xml/xml.rb +123 -0
- data/shoes/ruby/lib/rdoc/generator/xml.rb +117 -0
- data/shoes/ruby/lib/rdoc/generator.rb +1082 -0
- data/shoes/ruby/lib/rdoc/known_classes.rb +68 -0
- data/shoes/ruby/lib/rdoc/markup/attribute_manager.rb +265 -0
- data/shoes/ruby/lib/rdoc/markup/formatter.rb +14 -0
- data/shoes/ruby/lib/rdoc/markup/fragments.rb +337 -0
- data/shoes/ruby/lib/rdoc/markup/inline.rb +101 -0
- data/shoes/ruby/lib/rdoc/markup/lines.rb +152 -0
- data/shoes/ruby/lib/rdoc/markup/preprocess.rb +75 -0
- data/shoes/ruby/lib/rdoc/markup/to_flow.rb +185 -0
- data/shoes/ruby/lib/rdoc/markup/to_html.rb +403 -0
- data/shoes/ruby/lib/rdoc/markup/to_html_crossref.rb +148 -0
- data/shoes/ruby/lib/rdoc/markup/to_latex.rb +328 -0
- data/shoes/ruby/lib/rdoc/markup/to_test.rb +50 -0
- data/shoes/ruby/lib/rdoc/markup/to_texinfo.rb +69 -0
- data/shoes/ruby/lib/rdoc/markup.rb +378 -0
- data/shoes/ruby/lib/rdoc/options.rb +638 -0
- data/shoes/ruby/lib/rdoc/parser/c.rb +661 -0
- data/shoes/ruby/lib/rdoc/parser/f95.rb +1835 -0
- data/shoes/ruby/lib/rdoc/parser/perl.rb +165 -0
- data/shoes/ruby/lib/rdoc/parser/ruby.rb +2829 -0
- data/shoes/ruby/lib/rdoc/parser/simple.rb +38 -0
- data/shoes/ruby/lib/rdoc/parser.rb +142 -0
- data/shoes/ruby/lib/rdoc/rdoc.rb +293 -0
- data/shoes/ruby/lib/rdoc/ri/cache.rb +187 -0
- data/shoes/ruby/lib/rdoc/ri/descriptions.rb +156 -0
- data/shoes/ruby/lib/rdoc/ri/display.rb +392 -0
- data/shoes/ruby/lib/rdoc/ri/driver.rb +669 -0
- data/shoes/ruby/lib/rdoc/ri/formatter.rb +616 -0
- data/shoes/ruby/lib/rdoc/ri/paths.rb +99 -0
- data/shoes/ruby/lib/rdoc/ri/reader.rb +106 -0
- data/shoes/ruby/lib/rdoc/ri/util.rb +79 -0
- data/shoes/ruby/lib/rdoc/ri/writer.rb +68 -0
- data/shoes/ruby/lib/rdoc/ri.rb +8 -0
- data/shoes/ruby/lib/rdoc/stats.rb +115 -0
- data/shoes/ruby/lib/rdoc/template.rb +64 -0
- data/shoes/ruby/lib/rdoc/tokenstream.rb +33 -0
- data/shoes/ruby/lib/rdoc.rb +395 -0
- data/shoes/ruby/lib/resolv-replace.rb +63 -0
- data/shoes/ruby/lib/resolv.rb +2262 -0
- data/shoes/ruby/lib/rexml/attlistdecl.rb +62 -0
- data/shoes/ruby/lib/rexml/attribute.rb +188 -0
- data/shoes/ruby/lib/rexml/cdata.rb +67 -0
- data/shoes/ruby/lib/rexml/child.rb +96 -0
- data/shoes/ruby/lib/rexml/comment.rb +80 -0
- data/shoes/ruby/lib/rexml/doctype.rb +270 -0
- data/shoes/ruby/lib/rexml/document.rb +231 -0
- data/shoes/ruby/lib/rexml/dtd/attlistdecl.rb +10 -0
- data/shoes/ruby/lib/rexml/dtd/dtd.rb +51 -0
- data/shoes/ruby/lib/rexml/dtd/elementdecl.rb +17 -0
- data/shoes/ruby/lib/rexml/dtd/entitydecl.rb +56 -0
- data/shoes/ruby/lib/rexml/dtd/notationdecl.rb +39 -0
- data/shoes/ruby/lib/rexml/element.rb +1246 -0
- data/shoes/ruby/lib/rexml/encoding.rb +71 -0
- data/shoes/ruby/lib/rexml/encodings/CP-1252.rb +103 -0
- data/shoes/ruby/lib/rexml/encodings/EUC-JP.rb +35 -0
- data/shoes/ruby/lib/rexml/encodings/ICONV.rb +22 -0
- data/shoes/ruby/lib/rexml/encodings/ISO-8859-1.rb +7 -0
- data/shoes/ruby/lib/rexml/encodings/ISO-8859-15.rb +72 -0
- data/shoes/ruby/lib/rexml/encodings/SHIFT-JIS.rb +37 -0
- data/shoes/ruby/lib/rexml/encodings/SHIFT_JIS.rb +1 -0
- data/shoes/ruby/lib/rexml/encodings/UNILE.rb +34 -0
- data/shoes/ruby/lib/rexml/encodings/US-ASCII.rb +30 -0
- data/shoes/ruby/lib/rexml/encodings/UTF-16.rb +35 -0
- data/shoes/ruby/lib/rexml/encodings/UTF-8.rb +18 -0
- data/shoes/ruby/lib/rexml/entity.rb +166 -0
- data/shoes/ruby/lib/rexml/formatters/default.rb +109 -0
- data/shoes/ruby/lib/rexml/formatters/pretty.rb +139 -0
- data/shoes/ruby/lib/rexml/formatters/transitive.rb +58 -0
- data/shoes/ruby/lib/rexml/functions.rb +388 -0
- data/shoes/ruby/lib/rexml/instruction.rb +70 -0
- data/shoes/ruby/lib/rexml/light/node.rb +196 -0
- data/shoes/ruby/lib/rexml/namespace.rb +47 -0
- data/shoes/ruby/lib/rexml/node.rb +75 -0
- data/shoes/ruby/lib/rexml/output.rb +24 -0
- data/shoes/ruby/lib/rexml/parent.rb +166 -0
- data/shoes/ruby/lib/rexml/parseexception.rb +51 -0
- data/shoes/ruby/lib/rexml/parsers/baseparser.rb +530 -0
- data/shoes/ruby/lib/rexml/parsers/lightparser.rb +58 -0
- data/shoes/ruby/lib/rexml/parsers/pullparser.rb +196 -0
- data/shoes/ruby/lib/rexml/parsers/sax2parser.rb +247 -0
- data/shoes/ruby/lib/rexml/parsers/streamparser.rb +46 -0
- data/shoes/ruby/lib/rexml/parsers/treeparser.rb +100 -0
- data/shoes/ruby/lib/rexml/parsers/ultralightparser.rb +56 -0
- data/shoes/ruby/lib/rexml/parsers/xpathparser.rb +698 -0
- data/shoes/ruby/lib/rexml/quickpath.rb +263 -0
- data/shoes/ruby/lib/rexml/rexml.rb +31 -0
- data/shoes/ruby/lib/rexml/sax2listener.rb +97 -0
- data/shoes/ruby/lib/rexml/source.rb +258 -0
- data/shoes/ruby/lib/rexml/streamlistener.rb +92 -0
- data/shoes/ruby/lib/rexml/syncenumerator.rb +32 -0
- data/shoes/ruby/lib/rexml/text.rb +404 -0
- data/shoes/ruby/lib/rexml/undefinednamespaceexception.rb +8 -0
- data/shoes/ruby/lib/rexml/validation/relaxng.rb +559 -0
- data/shoes/ruby/lib/rexml/validation/validation.rb +155 -0
- data/shoes/ruby/lib/rexml/validation/validationexception.rb +9 -0
- data/shoes/ruby/lib/rexml/xmldecl.rb +119 -0
- data/shoes/ruby/lib/rexml/xmltokens.rb +18 -0
- data/shoes/ruby/lib/rexml/xpath.rb +77 -0
- data/shoes/ruby/lib/rexml/xpath_parser.rb +792 -0
- data/shoes/ruby/lib/rinda/rinda.rb +283 -0
- data/shoes/ruby/lib/rinda/ring.rb +271 -0
- data/shoes/ruby/lib/rinda/tuplespace.rb +642 -0
- data/shoes/ruby/lib/ripper/core.rb +70 -0
- data/shoes/ruby/lib/ripper/filter.rb +70 -0
- data/shoes/ruby/lib/ripper/lexer.rb +179 -0
- data/shoes/ruby/lib/ripper/sexp.rb +99 -0
- data/shoes/ruby/lib/ripper.rb +4 -0
- data/shoes/ruby/lib/rss/0.9.rb +427 -0
- data/shoes/ruby/lib/rss/1.0.rb +452 -0
- data/shoes/ruby/lib/rss/2.0.rb +111 -0
- data/shoes/ruby/lib/rss/atom.rb +748 -0
- data/shoes/ruby/lib/rss/content/1.0.rb +10 -0
- data/shoes/ruby/lib/rss/content/2.0.rb +12 -0
- data/shoes/ruby/lib/rss/content.rb +31 -0
- data/shoes/ruby/lib/rss/converter.rb +170 -0
- data/shoes/ruby/lib/rss/dublincore/1.0.rb +13 -0
- data/shoes/ruby/lib/rss/dublincore/2.0.rb +13 -0
- data/shoes/ruby/lib/rss/dublincore/atom.rb +17 -0
- data/shoes/ruby/lib/rss/dublincore.rb +161 -0
- data/shoes/ruby/lib/rss/image.rb +193 -0
- data/shoes/ruby/lib/rss/itunes.rb +410 -0
- data/shoes/ruby/lib/rss/maker/0.9.rb +467 -0
- data/shoes/ruby/lib/rss/maker/1.0.rb +434 -0
- data/shoes/ruby/lib/rss/maker/2.0.rb +223 -0
- data/shoes/ruby/lib/rss/maker/atom.rb +172 -0
- data/shoes/ruby/lib/rss/maker/base.rb +880 -0
- data/shoes/ruby/lib/rss/maker/content.rb +21 -0
- data/shoes/ruby/lib/rss/maker/dublincore.rb +124 -0
- data/shoes/ruby/lib/rss/maker/entry.rb +163 -0
- data/shoes/ruby/lib/rss/maker/feed.rb +430 -0
- data/shoes/ruby/lib/rss/maker/image.rb +111 -0
- data/shoes/ruby/lib/rss/maker/itunes.rb +242 -0
- data/shoes/ruby/lib/rss/maker/slash.rb +33 -0
- data/shoes/ruby/lib/rss/maker/syndication.rb +18 -0
- data/shoes/ruby/lib/rss/maker/taxonomy.rb +118 -0
- data/shoes/ruby/lib/rss/maker/trackback.rb +61 -0
- data/shoes/ruby/lib/rss/maker.rb +44 -0
- data/shoes/ruby/lib/rss/parser.rb +568 -0
- data/shoes/ruby/lib/rss/rexmlparser.rb +54 -0
- data/shoes/ruby/lib/rss/rss.rb +1313 -0
- data/shoes/ruby/lib/rss/slash.rb +49 -0
- data/shoes/ruby/lib/rss/syndication.rb +67 -0
- data/shoes/ruby/lib/rss/taxonomy.rb +145 -0
- data/shoes/ruby/lib/rss/trackback.rb +288 -0
- data/shoes/ruby/lib/rss/utils.rb +111 -0
- data/shoes/ruby/lib/rss/xml-stylesheet.rb +105 -0
- data/shoes/ruby/lib/rss/xml.rb +71 -0
- data/shoes/ruby/lib/rss/xmlparser.rb +93 -0
- data/shoes/ruby/lib/rss/xmlscanner.rb +121 -0
- data/shoes/ruby/lib/rss.rb +19 -0
- data/shoes/ruby/lib/rubygems/builder.rb +88 -0
- data/shoes/ruby/lib/rubygems/command.rb +406 -0
- data/shoes/ruby/lib/rubygems/command_manager.rb +146 -0
- data/shoes/ruby/lib/rubygems/commands/build_command.rb +53 -0
- data/shoes/ruby/lib/rubygems/commands/cert_command.rb +86 -0
- data/shoes/ruby/lib/rubygems/commands/check_command.rb +75 -0
- data/shoes/ruby/lib/rubygems/commands/cleanup_command.rb +91 -0
- data/shoes/ruby/lib/rubygems/commands/contents_command.rb +74 -0
- data/shoes/ruby/lib/rubygems/commands/dependency_command.rb +188 -0
- data/shoes/ruby/lib/rubygems/commands/environment_command.rb +128 -0
- data/shoes/ruby/lib/rubygems/commands/fetch_command.rb +62 -0
- data/shoes/ruby/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/shoes/ruby/lib/rubygems/commands/help_command.rb +172 -0
- data/shoes/ruby/lib/rubygems/commands/install_command.rb +148 -0
- data/shoes/ruby/lib/rubygems/commands/list_command.rb +35 -0
- data/shoes/ruby/lib/rubygems/commands/lock_command.rb +110 -0
- data/shoes/ruby/lib/rubygems/commands/mirror_command.rb +111 -0
- data/shoes/ruby/lib/rubygems/commands/outdated_command.rb +33 -0
- data/shoes/ruby/lib/rubygems/commands/pristine_command.rb +93 -0
- data/shoes/ruby/lib/rubygems/commands/query_command.rb +233 -0
- data/shoes/ruby/lib/rubygems/commands/rdoc_command.rb +82 -0
- data/shoes/ruby/lib/rubygems/commands/search_command.rb +37 -0
- data/shoes/ruby/lib/rubygems/commands/server_command.rb +48 -0
- data/shoes/ruby/lib/rubygems/commands/sources_command.rb +152 -0
- data/shoes/ruby/lib/rubygems/commands/specification_command.rb +77 -0
- data/shoes/ruby/lib/rubygems/commands/stale_command.rb +27 -0
- data/shoes/ruby/lib/rubygems/commands/uninstall_command.rb +73 -0
- data/shoes/ruby/lib/rubygems/commands/unpack_command.rb +95 -0
- data/shoes/ruby/lib/rubygems/commands/update_command.rb +181 -0
- data/shoes/ruby/lib/rubygems/commands/which_command.rb +87 -0
- data/shoes/ruby/lib/rubygems/config_file.rb +266 -0
- data/shoes/ruby/lib/rubygems/custom_require.rb +46 -0
- data/shoes/ruby/lib/rubygems/defaults.rb +89 -0
- data/shoes/ruby/lib/rubygems/dependency.rb +119 -0
- data/shoes/ruby/lib/rubygems/dependency_installer.rb +258 -0
- data/shoes/ruby/lib/rubygems/dependency_list.rb +165 -0
- data/shoes/ruby/lib/rubygems/digest/digest_adapter.rb +40 -0
- data/shoes/ruby/lib/rubygems/digest/md5.rb +23 -0
- data/shoes/ruby/lib/rubygems/digest/sha1.rb +17 -0
- data/shoes/ruby/lib/rubygems/digest/sha2.rb +17 -0
- data/shoes/ruby/lib/rubygems/doc_manager.rb +214 -0
- data/shoes/ruby/lib/rubygems/exceptions.rb +84 -0
- data/shoes/ruby/lib/rubygems/ext/builder.rb +56 -0
- data/shoes/ruby/lib/rubygems/ext/configure_builder.rb +24 -0
- data/shoes/ruby/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/shoes/ruby/lib/rubygems/ext/rake_builder.rb +27 -0
- data/shoes/ruby/lib/rubygems/ext.rb +18 -0
- data/shoes/ruby/lib/rubygems/format.rb +87 -0
- data/shoes/ruby/lib/rubygems/gem_openssl.rb +83 -0
- data/shoes/ruby/lib/rubygems/gem_path_searcher.rb +100 -0
- data/shoes/ruby/lib/rubygems/gem_runner.rb +58 -0
- data/shoes/ruby/lib/rubygems/indexer/abstract_index_builder.rb +88 -0
- data/shoes/ruby/lib/rubygems/indexer/latest_index_builder.rb +35 -0
- data/shoes/ruby/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/shoes/ruby/lib/rubygems/indexer/master_index_builder.rb +54 -0
- data/shoes/ruby/lib/rubygems/indexer/quick_index_builder.rb +50 -0
- data/shoes/ruby/lib/rubygems/indexer.rb +370 -0
- data/shoes/ruby/lib/rubygems/install_update_options.rb +113 -0
- data/shoes/ruby/lib/rubygems/installer.rb +578 -0
- data/shoes/ruby/lib/rubygems/local_remote_options.rb +134 -0
- data/shoes/ruby/lib/rubygems/old_format.rb +148 -0
- data/shoes/ruby/lib/rubygems/package/f_sync_dir.rb +24 -0
- data/shoes/ruby/lib/rubygems/package/tar_header.rb +245 -0
- data/shoes/ruby/lib/rubygems/package/tar_input.rb +219 -0
- data/shoes/ruby/lib/rubygems/package/tar_output.rb +143 -0
- data/shoes/ruby/lib/rubygems/package/tar_reader/entry.rb +99 -0
- data/shoes/ruby/lib/rubygems/package/tar_reader.rb +86 -0
- data/shoes/ruby/lib/rubygems/package/tar_writer.rb +180 -0
- data/shoes/ruby/lib/rubygems/package.rb +95 -0
- data/shoes/ruby/lib/rubygems/platform.rb +178 -0
- data/shoes/ruby/lib/rubygems/remote_fetcher.rb +344 -0
- data/shoes/ruby/lib/rubygems/require_paths_builder.rb +15 -0
- data/shoes/ruby/lib/rubygems/requirement.rb +163 -0
- data/shoes/ruby/lib/rubygems/rubygems_version.rb +6 -0
- data/shoes/ruby/lib/rubygems/security.rb +786 -0
- data/shoes/ruby/lib/rubygems/server.rb +629 -0
- data/shoes/ruby/lib/rubygems/source_index.rb +559 -0
- data/shoes/ruby/lib/rubygems/source_info_cache.rb +393 -0
- data/shoes/ruby/lib/rubygems/source_info_cache_entry.rb +56 -0
- data/shoes/ruby/lib/rubygems/spec_fetcher.rb +249 -0
- data/shoes/ruby/lib/rubygems/specification.rb +1262 -0
- data/shoes/ruby/lib/rubygems/test_utilities.rb +131 -0
- data/shoes/ruby/lib/rubygems/timer.rb +25 -0
- data/shoes/ruby/lib/rubygems/uninstaller.rb +242 -0
- data/shoes/ruby/lib/rubygems/user_interaction.rb +360 -0
- data/shoes/ruby/lib/rubygems/validator.rb +208 -0
- data/shoes/ruby/lib/rubygems/version.rb +167 -0
- data/shoes/ruby/lib/rubygems/version_option.rb +48 -0
- data/shoes/ruby/lib/rubygems.rb +888 -0
- data/shoes/ruby/lib/scanf.rb +703 -0
- data/shoes/ruby/lib/securerandom.rb +182 -0
- data/shoes/ruby/lib/set.rb +1274 -0
- data/shoes/ruby/lib/shell/builtin-command.rb +160 -0
- data/shoes/ruby/lib/shell/command-processor.rb +593 -0
- data/shoes/ruby/lib/shell/error.rb +25 -0
- data/shoes/ruby/lib/shell/filter.rb +109 -0
- data/shoes/ruby/lib/shell/process-controller.rb +319 -0
- data/shoes/ruby/lib/shell/system-command.rb +159 -0
- data/shoes/ruby/lib/shell/version.rb +15 -0
- data/shoes/ruby/lib/shell.rb +300 -0
- data/shoes/ruby/lib/shellwords.rb +156 -0
- data/shoes/ruby/lib/singleton.rb +313 -0
- data/shoes/ruby/lib/sync.rb +307 -0
- data/shoes/ruby/lib/tempfile.rb +218 -0
- data/shoes/ruby/lib/test/unit/assertions.rb +122 -0
- data/shoes/ruby/lib/test/unit/testcase.rb +12 -0
- data/shoes/ruby/lib/test/unit.rb +66 -0
- data/shoes/ruby/lib/thread.rb +367 -0
- data/shoes/ruby/lib/thwait.rb +168 -0
- data/shoes/ruby/lib/time.rb +869 -0
- data/shoes/ruby/lib/timeout.rb +108 -0
- data/shoes/ruby/lib/tmpdir.rb +138 -0
- data/shoes/ruby/lib/tracer.rb +166 -0
- data/shoes/ruby/lib/tsort.rb +290 -0
- data/shoes/ruby/lib/ubygems.rb +10 -0
- data/shoes/ruby/lib/un.rb +304 -0
- data/shoes/ruby/lib/uri/common.rb +727 -0
- data/shoes/ruby/lib/uri/ftp.rb +198 -0
- data/shoes/ruby/lib/uri/generic.rb +1128 -0
- data/shoes/ruby/lib/uri/http.rb +100 -0
- data/shoes/ruby/lib/uri/https.rb +20 -0
- data/shoes/ruby/lib/uri/ldap.rb +190 -0
- data/shoes/ruby/lib/uri/ldaps.rb +12 -0
- data/shoes/ruby/lib/uri/mailto.rb +266 -0
- data/shoes/ruby/lib/uri.rb +29 -0
- data/shoes/ruby/lib/weakref.rb +80 -0
- data/shoes/ruby/lib/webrick/accesslog.rb +75 -0
- data/shoes/ruby/lib/webrick/cgi.rb +260 -0
- data/shoes/ruby/lib/webrick/compat.rb +15 -0
- data/shoes/ruby/lib/webrick/config.rb +100 -0
- data/shoes/ruby/lib/webrick/cookie.rb +110 -0
- data/shoes/ruby/lib/webrick/htmlutils.rb +25 -0
- data/shoes/ruby/lib/webrick/httpauth/authenticator.rb +79 -0
- data/shoes/ruby/lib/webrick/httpauth/basicauth.rb +65 -0
- data/shoes/ruby/lib/webrick/httpauth/digestauth.rb +344 -0
- data/shoes/ruby/lib/webrick/httpauth/htdigest.rb +91 -0
- data/shoes/ruby/lib/webrick/httpauth/htgroup.rb +61 -0
- data/shoes/ruby/lib/webrick/httpauth/htpasswd.rb +83 -0
- data/shoes/ruby/lib/webrick/httpauth/userdb.rb +29 -0
- data/shoes/ruby/lib/webrick/httpauth.rb +45 -0
- data/shoes/ruby/lib/webrick/httpproxy.rb +288 -0
- data/shoes/ruby/lib/webrick/httprequest.rb +402 -0
- data/shoes/ruby/lib/webrick/httpresponse.rb +326 -0
- data/shoes/ruby/lib/webrick/https.rb +63 -0
- data/shoes/ruby/lib/webrick/httpserver.rb +217 -0
- data/shoes/ruby/lib/webrick/httpservlet/abstract.rb +70 -0
- data/shoes/ruby/lib/webrick/httpservlet/cgi_runner.rb +47 -0
- data/shoes/ruby/lib/webrick/httpservlet/cgihandler.rb +110 -0
- data/shoes/ruby/lib/webrick/httpservlet/erbhandler.rb +54 -0
- data/shoes/ruby/lib/webrick/httpservlet/filehandler.rb +435 -0
- data/shoes/ruby/lib/webrick/httpservlet/prochandler.rb +33 -0
- data/shoes/ruby/lib/webrick/httpservlet.rb +22 -0
- data/shoes/ruby/lib/webrick/httpstatus.rb +132 -0
- data/shoes/ruby/lib/webrick/httputils.rb +392 -0
- data/shoes/ruby/lib/webrick/httpversion.rb +49 -0
- data/shoes/ruby/lib/webrick/log.rb +88 -0
- data/shoes/ruby/lib/webrick/server.rb +210 -0
- data/shoes/ruby/lib/webrick/ssl.rb +126 -0
- data/shoes/ruby/lib/webrick/utils.rb +175 -0
- data/shoes/ruby/lib/webrick/version.rb +13 -0
- data/shoes/ruby/lib/webrick.rb +29 -0
- data/shoes/ruby/lib/win32/registry.rb +832 -0
- data/shoes/ruby/lib/win32/resolv.rb +370 -0
- data/shoes/ruby/lib/win32/sspi.rb +330 -0
- data/shoes/ruby/lib/win32ole/property.rb +16 -0
- data/shoes/ruby/lib/xmlrpc/base64.rb +81 -0
- data/shoes/ruby/lib/xmlrpc/client.rb +625 -0
- data/shoes/ruby/lib/xmlrpc/config.rb +40 -0
- data/shoes/ruby/lib/xmlrpc/create.rb +290 -0
- data/shoes/ruby/lib/xmlrpc/datetime.rb +142 -0
- data/shoes/ruby/lib/xmlrpc/httpserver.rb +178 -0
- data/shoes/ruby/lib/xmlrpc/marshal.rb +76 -0
- data/shoes/ruby/lib/xmlrpc/parser.rb +813 -0
- data/shoes/ruby/lib/xmlrpc/server.rb +778 -0
- data/shoes/ruby/lib/xmlrpc/utils.rb +165 -0
- data/shoes/ruby/lib/yaml/baseemitter.rb +242 -0
- data/shoes/ruby/lib/yaml/basenode.rb +216 -0
- data/shoes/ruby/lib/yaml/constants.rb +45 -0
- data/shoes/ruby/lib/yaml/dbm.rb +111 -0
- data/shoes/ruby/lib/yaml/encoding.rb +33 -0
- data/shoes/ruby/lib/yaml/error.rb +34 -0
- data/shoes/ruby/lib/yaml/loader.rb +14 -0
- data/shoes/ruby/lib/yaml/rubytypes.rb +446 -0
- data/shoes/ruby/lib/yaml/store.rb +43 -0
- data/shoes/ruby/lib/yaml/stream.rb +40 -0
- data/shoes/ruby/lib/yaml/stringio.rb +83 -0
- data/shoes/ruby/lib/yaml/syck.rb +19 -0
- data/shoes/ruby/lib/yaml/tag.rb +91 -0
- data/shoes/ruby/lib/yaml/types.rb +192 -0
- data/shoes/ruby/lib/yaml/yamlnode.rb +54 -0
- data/shoes/ruby/lib/yaml/ypath.rb +52 -0
- data/shoes/ruby/lib/yaml.rb +440 -0
- data/shoes/samples/class-book.rb +43 -0
- data/shoes/samples/class-book.yaml +387 -0
- data/shoes/samples/expert-definr.rb +23 -0
- data/shoes/samples/expert-funnies.rb +51 -0
- data/shoes/samples/expert-irb.rb +112 -0
- data/shoes/samples/expert-minesweeper.rb +267 -0
- data/shoes/samples/expert-othello.rb +319 -0
- data/shoes/samples/expert-pong.rb +62 -0
- data/shoes/samples/expert-tankspank.rb +385 -0
- data/shoes/samples/good-arc.rb +37 -0
- data/shoes/samples/good-clock.rb +51 -0
- data/shoes/samples/good-follow.rb +26 -0
- data/shoes/samples/good-reminder.rb +174 -0
- data/shoes/samples/good-vjot.rb +56 -0
- data/shoes/samples/simple-accordion.rb +75 -0
- data/shoes/samples/simple-anim-shapes.rb +17 -0
- data/shoes/samples/simple-anim-text.rb +13 -0
- data/shoes/samples/simple-arc.rb +23 -0
- data/shoes/samples/simple-bounce.rb +24 -0
- data/shoes/samples/simple-calc.rb +70 -0
- data/shoes/samples/simple-control-sizes.rb +24 -0
- data/shoes/samples/simple-curve.rb +26 -0
- data/shoes/samples/simple-dialogs.rb +29 -0
- data/shoes/samples/simple-downloader.rb +27 -0
- data/shoes/samples/simple-draw.rb +13 -0
- data/shoes/samples/simple-editor.rb +28 -0
- data/shoes/samples/simple-form.rb +28 -0
- data/shoes/samples/simple-form.shy +0 -0
- data/shoes/samples/simple-mask.rb +21 -0
- data/shoes/samples/simple-menu.rb +31 -0
- data/shoes/samples/simple-menu1.rb +35 -0
- data/shoes/samples/simple-rubygems.rb +29 -0
- data/shoes/samples/simple-slide.rb +45 -0
- data/shoes/samples/simple-sphere.rb +28 -0
- data/shoes/samples/simple-timer.rb +13 -0
- data/shoes/samples/simple-video.rb +13 -0
- data/shoes/shoes +21 -0
- data/shoes/shoes.exe +0 -0
- data/shoes/shoes.exe.manifest +17 -0
- data/shoes/sqlite3.dll +0 -0
- data/shoes/static/Shoes.icns +0 -0
- data/shoes/static/Thumbs.db +0 -0
- data/shoes/static/app-icon.png +0 -0
- data/shoes/static/avatar.png +0 -0
- data/shoes/static/code_highlighter.js +188 -0
- data/shoes/static/code_highlighter_ruby.js +26 -0
- data/shoes/static/icon-debug.png +0 -0
- data/shoes/static/icon-error.png +0 -0
- data/shoes/static/icon-info.png +0 -0
- data/shoes/static/icon-warn.png +0 -0
- data/shoes/static/listbox_button1.png +0 -0
- data/shoes/static/listbox_button2.png +0 -0
- data/shoes/static/man-app.png +0 -0
- data/shoes/static/man-builds.png +0 -0
- data/shoes/static/man-editor-notepad.png +0 -0
- data/shoes/static/man-editor-osx.png +0 -0
- data/shoes/static/man-ele-background.png +0 -0
- data/shoes/static/man-ele-border.png +0 -0
- data/shoes/static/man-ele-button.png +0 -0
- data/shoes/static/man-ele-check.png +0 -0
- data/shoes/static/man-ele-editbox.png +0 -0
- data/shoes/static/man-ele-editline.png +0 -0
- data/shoes/static/man-ele-image.png +0 -0
- data/shoes/static/man-ele-listbox.png +0 -0
- data/shoes/static/man-ele-progress.png +0 -0
- data/shoes/static/man-ele-radio.png +0 -0
- data/shoes/static/man-ele-shape.png +0 -0
- data/shoes/static/man-ele-textblock.png +0 -0
- data/shoes/static/man-ele-video.png +0 -0
- data/shoes/static/man-intro-dmg.png +0 -0
- data/shoes/static/man-intro-exe.png +0 -0
- data/shoes/static/man-look-tiger.png +0 -0
- data/shoes/static/man-look-ubuntu.png +0 -0
- data/shoes/static/man-look-vista.png +0 -0
- data/shoes/static/man-run-osx.png +0 -0
- data/shoes/static/man-run-vista.png +0 -0
- data/shoes/static/man-run-xp.png +0 -0
- data/shoes/static/man-shot1.png +0 -0
- data/shoes/static/manual-en.txt +2783 -0
- data/shoes/static/manual-ja.txt +2780 -0
- data/shoes/static/manual.css +167 -0
- data/shoes/static/menu-corner1.png +0 -0
- data/shoes/static/menu-corner2.png +0 -0
- data/shoes/static/menu-gray.png +0 -0
- data/shoes/static/menu-left.png +0 -0
- data/shoes/static/menu-right.png +0 -0
- data/shoes/static/menu-top.png +0 -0
- data/shoes/static/shoes-dmg.jpg +0 -0
- data/shoes/static/shoes-icon-blue.png +0 -0
- data/shoes/static/shoes-icon.png +0 -0
- data/shoes/static/shoes-manual-apps.gif +0 -0
- data/shoes/static/stripe.png +0 -0
- data/shoes/static/stubs/blank.exe +0 -0
- data/shoes/static/stubs/blank.hfz +0 -0
- data/shoes/static/stubs/blank.run +375 -0
- data/shoes/static/stubs/cocoa-install +0 -0
- data/shoes/static/stubs/sh-install +48 -0
- data/shoes/static/tutor-back.png +0 -0
- data/shoes/zlib.dll +0 -0
- data/shoes/zlib1.dll +0 -0
- metadata +887 -0
|
@@ -0,0 +1,2829 @@
|
|
|
1
|
+
##
|
|
2
|
+
# This file contains stuff stolen outright from:
|
|
3
|
+
#
|
|
4
|
+
# rtags.rb -
|
|
5
|
+
# ruby-lex.rb - ruby lexcal analyzer
|
|
6
|
+
# ruby-token.rb - ruby tokens
|
|
7
|
+
# by Keiju ISHITSUKA (Nippon Rational Inc.)
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
require 'e2mmap'
|
|
11
|
+
require 'irb/slex'
|
|
12
|
+
|
|
13
|
+
require 'rdoc/code_objects'
|
|
14
|
+
require 'rdoc/tokenstream'
|
|
15
|
+
require 'rdoc/markup/preprocess'
|
|
16
|
+
require 'rdoc/parser'
|
|
17
|
+
|
|
18
|
+
$TOKEN_DEBUG ||= nil
|
|
19
|
+
#$TOKEN_DEBUG = $DEBUG_RDOC
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# Definitions of all tokens involved in the lexical analysis
|
|
23
|
+
|
|
24
|
+
module RDoc::RubyToken
|
|
25
|
+
|
|
26
|
+
EXPR_BEG = :EXPR_BEG
|
|
27
|
+
EXPR_MID = :EXPR_MID
|
|
28
|
+
EXPR_END = :EXPR_END
|
|
29
|
+
EXPR_ARG = :EXPR_ARG
|
|
30
|
+
EXPR_FNAME = :EXPR_FNAME
|
|
31
|
+
EXPR_DOT = :EXPR_DOT
|
|
32
|
+
EXPR_CLASS = :EXPR_CLASS
|
|
33
|
+
|
|
34
|
+
class Token
|
|
35
|
+
NO_TEXT = "??".freeze
|
|
36
|
+
|
|
37
|
+
attr_accessor :text
|
|
38
|
+
attr_reader :line_no
|
|
39
|
+
attr_reader :char_no
|
|
40
|
+
|
|
41
|
+
def initialize(line_no, char_no)
|
|
42
|
+
@line_no = line_no
|
|
43
|
+
@char_no = char_no
|
|
44
|
+
@text = NO_TEXT
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def ==(other)
|
|
48
|
+
self.class == other.class and
|
|
49
|
+
other.line_no == @line_no and
|
|
50
|
+
other.char_no == @char_no and
|
|
51
|
+
other.text == @text
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# Because we're used in contexts that expect to return a token, we set the
|
|
56
|
+
# text string and then return ourselves
|
|
57
|
+
|
|
58
|
+
def set_text(text)
|
|
59
|
+
@text = text
|
|
60
|
+
self
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
class TkNode < Token
|
|
66
|
+
attr :node
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class TkId < Token
|
|
70
|
+
def initialize(line_no, char_no, name)
|
|
71
|
+
super(line_no, char_no)
|
|
72
|
+
@name = name
|
|
73
|
+
end
|
|
74
|
+
attr :name
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class TkKW < TkId
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class TkVal < Token
|
|
81
|
+
def initialize(line_no, char_no, value = nil)
|
|
82
|
+
super(line_no, char_no)
|
|
83
|
+
set_text(value)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class TkOp < Token
|
|
88
|
+
def name
|
|
89
|
+
self.class.op_name
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class TkOPASGN < TkOp
|
|
94
|
+
def initialize(line_no, char_no, op)
|
|
95
|
+
super(line_no, char_no)
|
|
96
|
+
op = TkReading2Token[op] unless Symbol === op
|
|
97
|
+
@op = op
|
|
98
|
+
end
|
|
99
|
+
attr :op
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
class TkUnknownChar < Token
|
|
103
|
+
def initialize(line_no, char_no, id)
|
|
104
|
+
super(line_no, char_no)
|
|
105
|
+
@name = char_no.chr
|
|
106
|
+
end
|
|
107
|
+
attr :name
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
class TkError < Token
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def set_token_position(line, char)
|
|
114
|
+
@prev_line_no = line
|
|
115
|
+
@prev_char_no = char
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def Token(token, value = nil)
|
|
119
|
+
tk = nil
|
|
120
|
+
case token
|
|
121
|
+
when String, Symbol
|
|
122
|
+
source = String === token ? TkReading2Token : TkSymbol2Token
|
|
123
|
+
raise TkReading2TokenNoKey, token if (tk = source[token]).nil?
|
|
124
|
+
tk = Token(tk[0], value)
|
|
125
|
+
else
|
|
126
|
+
tk = if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
|
|
127
|
+
token.new(@prev_line_no, @prev_char_no)
|
|
128
|
+
else
|
|
129
|
+
token.new(@prev_line_no, @prev_char_no, value)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
tk
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
TokenDefinitions = [
|
|
136
|
+
[:TkCLASS, TkKW, "class", EXPR_CLASS],
|
|
137
|
+
[:TkMODULE, TkKW, "module", EXPR_CLASS],
|
|
138
|
+
[:TkDEF, TkKW, "def", EXPR_FNAME],
|
|
139
|
+
[:TkUNDEF, TkKW, "undef", EXPR_FNAME],
|
|
140
|
+
[:TkBEGIN, TkKW, "begin", EXPR_BEG],
|
|
141
|
+
[:TkRESCUE, TkKW, "rescue", EXPR_MID],
|
|
142
|
+
[:TkENSURE, TkKW, "ensure", EXPR_BEG],
|
|
143
|
+
[:TkEND, TkKW, "end", EXPR_END],
|
|
144
|
+
[:TkIF, TkKW, "if", EXPR_BEG, :TkIF_MOD],
|
|
145
|
+
[:TkUNLESS, TkKW, "unless", EXPR_BEG, :TkUNLESS_MOD],
|
|
146
|
+
[:TkTHEN, TkKW, "then", EXPR_BEG],
|
|
147
|
+
[:TkELSIF, TkKW, "elsif", EXPR_BEG],
|
|
148
|
+
[:TkELSE, TkKW, "else", EXPR_BEG],
|
|
149
|
+
[:TkCASE, TkKW, "case", EXPR_BEG],
|
|
150
|
+
[:TkWHEN, TkKW, "when", EXPR_BEG],
|
|
151
|
+
[:TkWHILE, TkKW, "while", EXPR_BEG, :TkWHILE_MOD],
|
|
152
|
+
[:TkUNTIL, TkKW, "until", EXPR_BEG, :TkUNTIL_MOD],
|
|
153
|
+
[:TkFOR, TkKW, "for", EXPR_BEG],
|
|
154
|
+
[:TkBREAK, TkKW, "break", EXPR_END],
|
|
155
|
+
[:TkNEXT, TkKW, "next", EXPR_END],
|
|
156
|
+
[:TkREDO, TkKW, "redo", EXPR_END],
|
|
157
|
+
[:TkRETRY, TkKW, "retry", EXPR_END],
|
|
158
|
+
[:TkIN, TkKW, "in", EXPR_BEG],
|
|
159
|
+
[:TkDO, TkKW, "do", EXPR_BEG],
|
|
160
|
+
[:TkRETURN, TkKW, "return", EXPR_MID],
|
|
161
|
+
[:TkYIELD, TkKW, "yield", EXPR_END],
|
|
162
|
+
[:TkSUPER, TkKW, "super", EXPR_END],
|
|
163
|
+
[:TkSELF, TkKW, "self", EXPR_END],
|
|
164
|
+
[:TkNIL, TkKW, "nil", EXPR_END],
|
|
165
|
+
[:TkTRUE, TkKW, "true", EXPR_END],
|
|
166
|
+
[:TkFALSE, TkKW, "false", EXPR_END],
|
|
167
|
+
[:TkAND, TkKW, "and", EXPR_BEG],
|
|
168
|
+
[:TkOR, TkKW, "or", EXPR_BEG],
|
|
169
|
+
[:TkNOT, TkKW, "not", EXPR_BEG],
|
|
170
|
+
[:TkIF_MOD, TkKW],
|
|
171
|
+
[:TkUNLESS_MOD, TkKW],
|
|
172
|
+
[:TkWHILE_MOD, TkKW],
|
|
173
|
+
[:TkUNTIL_MOD, TkKW],
|
|
174
|
+
[:TkALIAS, TkKW, "alias", EXPR_FNAME],
|
|
175
|
+
[:TkDEFINED, TkKW, "defined?", EXPR_END],
|
|
176
|
+
[:TklBEGIN, TkKW, "BEGIN", EXPR_END],
|
|
177
|
+
[:TklEND, TkKW, "END", EXPR_END],
|
|
178
|
+
[:Tk__LINE__, TkKW, "__LINE__", EXPR_END],
|
|
179
|
+
[:Tk__FILE__, TkKW, "__FILE__", EXPR_END],
|
|
180
|
+
|
|
181
|
+
[:TkIDENTIFIER, TkId],
|
|
182
|
+
[:TkFID, TkId],
|
|
183
|
+
[:TkGVAR, TkId],
|
|
184
|
+
[:TkIVAR, TkId],
|
|
185
|
+
[:TkCONSTANT, TkId],
|
|
186
|
+
|
|
187
|
+
[:TkINTEGER, TkVal],
|
|
188
|
+
[:TkFLOAT, TkVal],
|
|
189
|
+
[:TkSTRING, TkVal],
|
|
190
|
+
[:TkXSTRING, TkVal],
|
|
191
|
+
[:TkREGEXP, TkVal],
|
|
192
|
+
[:TkCOMMENT, TkVal],
|
|
193
|
+
|
|
194
|
+
[:TkDSTRING, TkNode],
|
|
195
|
+
[:TkDXSTRING, TkNode],
|
|
196
|
+
[:TkDREGEXP, TkNode],
|
|
197
|
+
[:TkNTH_REF, TkId],
|
|
198
|
+
[:TkBACK_REF, TkId],
|
|
199
|
+
|
|
200
|
+
[:TkUPLUS, TkOp, "+@"],
|
|
201
|
+
[:TkUMINUS, TkOp, "-@"],
|
|
202
|
+
[:TkPOW, TkOp, "**"],
|
|
203
|
+
[:TkCMP, TkOp, "<=>"],
|
|
204
|
+
[:TkEQ, TkOp, "=="],
|
|
205
|
+
[:TkEQQ, TkOp, "==="],
|
|
206
|
+
[:TkNEQ, TkOp, "!="],
|
|
207
|
+
[:TkGEQ, TkOp, ">="],
|
|
208
|
+
[:TkLEQ, TkOp, "<="],
|
|
209
|
+
[:TkANDOP, TkOp, "&&"],
|
|
210
|
+
[:TkOROP, TkOp, "||"],
|
|
211
|
+
[:TkMATCH, TkOp, "=~"],
|
|
212
|
+
[:TkNMATCH, TkOp, "!~"],
|
|
213
|
+
[:TkDOT2, TkOp, ".."],
|
|
214
|
+
[:TkDOT3, TkOp, "..."],
|
|
215
|
+
[:TkAREF, TkOp, "[]"],
|
|
216
|
+
[:TkASET, TkOp, "[]="],
|
|
217
|
+
[:TkLSHFT, TkOp, "<<"],
|
|
218
|
+
[:TkRSHFT, TkOp, ">>"],
|
|
219
|
+
[:TkCOLON2, TkOp],
|
|
220
|
+
[:TkCOLON3, TkOp],
|
|
221
|
+
# [:OPASGN, TkOp], # +=, -= etc. #
|
|
222
|
+
[:TkASSOC, TkOp, "=>"],
|
|
223
|
+
[:TkQUESTION, TkOp, "?"], #?
|
|
224
|
+
[:TkCOLON, TkOp, ":"], #:
|
|
225
|
+
|
|
226
|
+
[:TkfLPAREN], # func( #
|
|
227
|
+
[:TkfLBRACK], # func[ #
|
|
228
|
+
[:TkfLBRACE], # func{ #
|
|
229
|
+
[:TkSTAR], # *arg
|
|
230
|
+
[:TkAMPER], # &arg #
|
|
231
|
+
[:TkSYMBOL, TkId], # :SYMBOL
|
|
232
|
+
[:TkSYMBEG, TkId],
|
|
233
|
+
[:TkGT, TkOp, ">"],
|
|
234
|
+
[:TkLT, TkOp, "<"],
|
|
235
|
+
[:TkPLUS, TkOp, "+"],
|
|
236
|
+
[:TkMINUS, TkOp, "-"],
|
|
237
|
+
[:TkMULT, TkOp, "*"],
|
|
238
|
+
[:TkDIV, TkOp, "/"],
|
|
239
|
+
[:TkMOD, TkOp, "%"],
|
|
240
|
+
[:TkBITOR, TkOp, "|"],
|
|
241
|
+
[:TkBITXOR, TkOp, "^"],
|
|
242
|
+
[:TkBITAND, TkOp, "&"],
|
|
243
|
+
[:TkBITNOT, TkOp, "~"],
|
|
244
|
+
[:TkNOTOP, TkOp, "!"],
|
|
245
|
+
|
|
246
|
+
[:TkBACKQUOTE, TkOp, "`"],
|
|
247
|
+
|
|
248
|
+
[:TkASSIGN, Token, "="],
|
|
249
|
+
[:TkDOT, Token, "."],
|
|
250
|
+
[:TkLPAREN, Token, "("], #(exp)
|
|
251
|
+
[:TkLBRACK, Token, "["], #[arry]
|
|
252
|
+
[:TkLBRACE, Token, "{"], #{hash}
|
|
253
|
+
[:TkRPAREN, Token, ")"],
|
|
254
|
+
[:TkRBRACK, Token, "]"],
|
|
255
|
+
[:TkRBRACE, Token, "}"],
|
|
256
|
+
[:TkCOMMA, Token, ","],
|
|
257
|
+
[:TkSEMICOLON, Token, ";"],
|
|
258
|
+
|
|
259
|
+
[:TkRD_COMMENT],
|
|
260
|
+
[:TkSPACE],
|
|
261
|
+
[:TkNL],
|
|
262
|
+
[:TkEND_OF_SCRIPT],
|
|
263
|
+
|
|
264
|
+
[:TkBACKSLASH, TkUnknownChar, "\\"],
|
|
265
|
+
[:TkAT, TkUnknownChar, "@"],
|
|
266
|
+
[:TkDOLLAR, TkUnknownChar, "\$"], #"
|
|
267
|
+
]
|
|
268
|
+
|
|
269
|
+
# {reading => token_class}
|
|
270
|
+
# {reading => [token_class, *opt]}
|
|
271
|
+
TkReading2Token = {}
|
|
272
|
+
TkSymbol2Token = {}
|
|
273
|
+
|
|
274
|
+
def self.def_token(token_n, super_token = Token, reading = nil, *opts)
|
|
275
|
+
token_n = token_n.id2name unless String === token_n
|
|
276
|
+
|
|
277
|
+
fail AlreadyDefinedToken, token_n if const_defined?(token_n)
|
|
278
|
+
|
|
279
|
+
token_c = Class.new super_token
|
|
280
|
+
const_set token_n, token_c
|
|
281
|
+
# token_c.inspect
|
|
282
|
+
|
|
283
|
+
if reading
|
|
284
|
+
if TkReading2Token[reading]
|
|
285
|
+
fail TkReading2TokenDuplicateError, token_n, reading
|
|
286
|
+
end
|
|
287
|
+
if opts.empty?
|
|
288
|
+
TkReading2Token[reading] = [token_c]
|
|
289
|
+
else
|
|
290
|
+
TkReading2Token[reading] = [token_c].concat(opts)
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
TkSymbol2Token[token_n.intern] = token_c
|
|
294
|
+
|
|
295
|
+
if token_c <= TkOp
|
|
296
|
+
token_c.class_eval %{
|
|
297
|
+
def self.op_name; "#{reading}"; end
|
|
298
|
+
}
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
for defs in TokenDefinitions
|
|
303
|
+
def_token(*defs)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
NEWLINE_TOKEN = TkNL.new(0,0)
|
|
307
|
+
NEWLINE_TOKEN.set_text("\n")
|
|
308
|
+
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
##
|
|
312
|
+
# Lexical analyzer for Ruby source
|
|
313
|
+
|
|
314
|
+
class RDoc::RubyLex
|
|
315
|
+
|
|
316
|
+
##
|
|
317
|
+
# Read an input stream character by character. We allow for unlimited
|
|
318
|
+
# ungetting of characters just read.
|
|
319
|
+
#
|
|
320
|
+
# We simplify the implementation greatly by reading the entire input
|
|
321
|
+
# into a buffer initially, and then simply traversing it using
|
|
322
|
+
# pointers.
|
|
323
|
+
#
|
|
324
|
+
# We also have to allow for the <i>here document diversion</i>. This
|
|
325
|
+
# little gem comes about when the lexer encounters a here
|
|
326
|
+
# document. At this point we effectively need to split the input
|
|
327
|
+
# stream into two parts: one to read the body of the here document,
|
|
328
|
+
# the other to read the rest of the input line where the here
|
|
329
|
+
# document was initially encountered. For example, we might have
|
|
330
|
+
#
|
|
331
|
+
# do_something(<<-A, <<-B)
|
|
332
|
+
# stuff
|
|
333
|
+
# for
|
|
334
|
+
# A
|
|
335
|
+
# stuff
|
|
336
|
+
# for
|
|
337
|
+
# B
|
|
338
|
+
#
|
|
339
|
+
# When the lexer encounters the <<A, it reads until the end of the
|
|
340
|
+
# line, and keeps it around for later. It then reads the body of the
|
|
341
|
+
# here document. Once complete, it needs to read the rest of the
|
|
342
|
+
# original line, but then skip the here document body.
|
|
343
|
+
#
|
|
344
|
+
|
|
345
|
+
class BufferedReader
|
|
346
|
+
|
|
347
|
+
attr_reader :line_num
|
|
348
|
+
|
|
349
|
+
def initialize(content, options)
|
|
350
|
+
@options = options
|
|
351
|
+
|
|
352
|
+
if /\t/ =~ content
|
|
353
|
+
tab_width = @options.tab_width
|
|
354
|
+
content = content.split(/\n/).map do |line|
|
|
355
|
+
1 while line.gsub!(/\t+/) { ' ' * (tab_width*$&.length - $`.length % tab_width)} && $~ #`
|
|
356
|
+
line
|
|
357
|
+
end .join("\n")
|
|
358
|
+
end
|
|
359
|
+
@content = content
|
|
360
|
+
@content << "\n" unless @content[-1,1] == "\n"
|
|
361
|
+
@size = @content.size
|
|
362
|
+
@offset = 0
|
|
363
|
+
@hwm = 0
|
|
364
|
+
@line_num = 1
|
|
365
|
+
@read_back_offset = 0
|
|
366
|
+
@last_newline = 0
|
|
367
|
+
@newline_pending = false
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def column
|
|
371
|
+
@offset - @last_newline
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def getc
|
|
375
|
+
return nil if @offset >= @size
|
|
376
|
+
ch = @content[@offset, 1]
|
|
377
|
+
|
|
378
|
+
@offset += 1
|
|
379
|
+
@hwm = @offset if @hwm < @offset
|
|
380
|
+
|
|
381
|
+
if @newline_pending
|
|
382
|
+
@line_num += 1
|
|
383
|
+
@last_newline = @offset - 1
|
|
384
|
+
@newline_pending = false
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
if ch == "\n"
|
|
388
|
+
@newline_pending = true
|
|
389
|
+
end
|
|
390
|
+
ch
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def getc_already_read
|
|
394
|
+
getc
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def ungetc(ch)
|
|
398
|
+
raise "unget past beginning of file" if @offset <= 0
|
|
399
|
+
@offset -= 1
|
|
400
|
+
if @content[@offset] == ?\n
|
|
401
|
+
@newline_pending = false
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def get_read
|
|
406
|
+
res = @content[@read_back_offset...@offset]
|
|
407
|
+
@read_back_offset = @offset
|
|
408
|
+
res
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def peek(at)
|
|
412
|
+
pos = @offset + at
|
|
413
|
+
if pos >= @size
|
|
414
|
+
nil
|
|
415
|
+
else
|
|
416
|
+
@content[pos, 1]
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
def peek_equal(str)
|
|
421
|
+
@content[@offset, str.length] == str
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def divert_read_from(reserve)
|
|
425
|
+
@content[@offset, 0] = reserve
|
|
426
|
+
@size = @content.size
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
# end of nested class BufferedReader
|
|
431
|
+
|
|
432
|
+
extend Exception2MessageMapper
|
|
433
|
+
def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
|
|
434
|
+
def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
|
|
435
|
+
def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
|
|
436
|
+
def_exception(:TkReading2TokenDuplicateError,
|
|
437
|
+
"key duplicate(token_n='%s', key='%s')")
|
|
438
|
+
def_exception(:SyntaxError, "%s")
|
|
439
|
+
|
|
440
|
+
include RDoc::RubyToken
|
|
441
|
+
include IRB
|
|
442
|
+
|
|
443
|
+
attr_reader :continue
|
|
444
|
+
attr_reader :lex_state
|
|
445
|
+
|
|
446
|
+
def self.debug?
|
|
447
|
+
false
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def initialize(content, options)
|
|
451
|
+
lex_init
|
|
452
|
+
|
|
453
|
+
@options = options
|
|
454
|
+
|
|
455
|
+
@reader = BufferedReader.new content, @options
|
|
456
|
+
|
|
457
|
+
@exp_line_no = @line_no = 1
|
|
458
|
+
@base_char_no = 0
|
|
459
|
+
@indent = 0
|
|
460
|
+
|
|
461
|
+
@ltype = nil
|
|
462
|
+
@quoted = nil
|
|
463
|
+
@lex_state = EXPR_BEG
|
|
464
|
+
@space_seen = false
|
|
465
|
+
|
|
466
|
+
@continue = false
|
|
467
|
+
@line = ""
|
|
468
|
+
|
|
469
|
+
@skip_space = false
|
|
470
|
+
@read_auto_clean_up = false
|
|
471
|
+
@exception_on_syntax_error = true
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
attr_accessor :skip_space
|
|
475
|
+
attr_accessor :read_auto_clean_up
|
|
476
|
+
attr_accessor :exception_on_syntax_error
|
|
477
|
+
attr_reader :indent
|
|
478
|
+
|
|
479
|
+
# io functions
|
|
480
|
+
def line_no
|
|
481
|
+
@reader.line_num
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def char_no
|
|
485
|
+
@reader.column
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def get_read
|
|
489
|
+
@reader.get_read
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def getc
|
|
493
|
+
@reader.getc
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
def getc_of_rests
|
|
497
|
+
@reader.getc_already_read
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
def gets
|
|
501
|
+
c = getc or return
|
|
502
|
+
l = ""
|
|
503
|
+
begin
|
|
504
|
+
l.concat c unless c == "\r"
|
|
505
|
+
break if c == "\n"
|
|
506
|
+
end while c = getc
|
|
507
|
+
l
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def ungetc(c = nil)
|
|
512
|
+
@reader.ungetc(c)
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
def peek_equal?(str)
|
|
516
|
+
@reader.peek_equal(str)
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
def peek(i = 0)
|
|
520
|
+
@reader.peek(i)
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def lex
|
|
524
|
+
until (TkNL === (tk = token) or TkEND_OF_SCRIPT === tk) and
|
|
525
|
+
not @continue or tk.nil?
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
line = get_read
|
|
529
|
+
|
|
530
|
+
if line == "" and TkEND_OF_SCRIPT === tk or tk.nil? then
|
|
531
|
+
nil
|
|
532
|
+
else
|
|
533
|
+
line
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
def token
|
|
538
|
+
set_token_position(line_no, char_no)
|
|
539
|
+
begin
|
|
540
|
+
begin
|
|
541
|
+
tk = @OP.match(self)
|
|
542
|
+
@space_seen = TkSPACE === tk
|
|
543
|
+
rescue SyntaxError => e
|
|
544
|
+
raise RDoc::Error, "syntax error: #{e.message}" if
|
|
545
|
+
@exception_on_syntax_error
|
|
546
|
+
|
|
547
|
+
tk = TkError.new(line_no, char_no)
|
|
548
|
+
end
|
|
549
|
+
end while @skip_space and TkSPACE === tk
|
|
550
|
+
if @read_auto_clean_up
|
|
551
|
+
get_read
|
|
552
|
+
end
|
|
553
|
+
# throw :eof unless tk
|
|
554
|
+
tk
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
ENINDENT_CLAUSE = [
|
|
558
|
+
"case", "class", "def", "do", "for", "if",
|
|
559
|
+
"module", "unless", "until", "while", "begin" #, "when"
|
|
560
|
+
]
|
|
561
|
+
DEINDENT_CLAUSE = ["end" #, "when"
|
|
562
|
+
]
|
|
563
|
+
|
|
564
|
+
PERCENT_LTYPE = {
|
|
565
|
+
"q" => "\'",
|
|
566
|
+
"Q" => "\"",
|
|
567
|
+
"x" => "\`",
|
|
568
|
+
"r" => "/",
|
|
569
|
+
"w" => "]"
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
PERCENT_PAREN = {
|
|
573
|
+
"{" => "}",
|
|
574
|
+
"[" => "]",
|
|
575
|
+
"<" => ">",
|
|
576
|
+
"(" => ")"
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
Ltype2Token = {
|
|
580
|
+
"\'" => TkSTRING,
|
|
581
|
+
"\"" => TkSTRING,
|
|
582
|
+
"\`" => TkXSTRING,
|
|
583
|
+
"/" => TkREGEXP,
|
|
584
|
+
"]" => TkDSTRING
|
|
585
|
+
}
|
|
586
|
+
Ltype2Token.default = TkSTRING
|
|
587
|
+
|
|
588
|
+
DLtype2Token = {
|
|
589
|
+
"\"" => TkDSTRING,
|
|
590
|
+
"\`" => TkDXSTRING,
|
|
591
|
+
"/" => TkDREGEXP,
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
def lex_init()
|
|
595
|
+
@OP = IRB::SLex.new
|
|
596
|
+
@OP.def_rules("\0", "\004", "\032") do |chars, io|
|
|
597
|
+
Token(TkEND_OF_SCRIPT).set_text(chars)
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
@OP.def_rules(" ", "\t", "\f", "\r", "\13") do |chars, io|
|
|
601
|
+
@space_seen = TRUE
|
|
602
|
+
while (ch = getc) =~ /[ \t\f\r\13]/
|
|
603
|
+
chars << ch
|
|
604
|
+
end
|
|
605
|
+
ungetc
|
|
606
|
+
Token(TkSPACE).set_text(chars)
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
@OP.def_rule("#") do
|
|
610
|
+
|op, io|
|
|
611
|
+
identify_comment
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
@OP.def_rule("=begin", proc{@prev_char_no == 0 && peek(0) =~ /\s/}) do
|
|
615
|
+
|op, io|
|
|
616
|
+
str = op
|
|
617
|
+
@ltype = "="
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
begin
|
|
621
|
+
line = ""
|
|
622
|
+
begin
|
|
623
|
+
ch = getc
|
|
624
|
+
line << ch
|
|
625
|
+
end until ch == "\n"
|
|
626
|
+
str << line
|
|
627
|
+
end until line =~ /^=end/
|
|
628
|
+
|
|
629
|
+
ungetc
|
|
630
|
+
|
|
631
|
+
@ltype = nil
|
|
632
|
+
|
|
633
|
+
if str =~ /\A=begin\s+rdoc/i
|
|
634
|
+
str.sub!(/\A=begin.*\n/, '')
|
|
635
|
+
str.sub!(/^=end.*/m, '')
|
|
636
|
+
Token(TkCOMMENT).set_text(str)
|
|
637
|
+
else
|
|
638
|
+
Token(TkRD_COMMENT)#.set_text(str)
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
@OP.def_rule("\n") do
|
|
643
|
+
print "\\n\n" if RDoc::RubyLex.debug?
|
|
644
|
+
case @lex_state
|
|
645
|
+
when EXPR_BEG, EXPR_FNAME, EXPR_DOT
|
|
646
|
+
@continue = TRUE
|
|
647
|
+
else
|
|
648
|
+
@continue = FALSE
|
|
649
|
+
@lex_state = EXPR_BEG
|
|
650
|
+
end
|
|
651
|
+
Token(TkNL).set_text("\n")
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
@OP.def_rules("*", "**",
|
|
655
|
+
"!", "!=", "!~",
|
|
656
|
+
"=", "==", "===",
|
|
657
|
+
"=~", "<=>",
|
|
658
|
+
"<", "<=",
|
|
659
|
+
">", ">=", ">>") do
|
|
660
|
+
|op, io|
|
|
661
|
+
@lex_state = EXPR_BEG
|
|
662
|
+
Token(op).set_text(op)
|
|
663
|
+
end
|
|
664
|
+
|
|
665
|
+
@OP.def_rules("<<") do
|
|
666
|
+
|op, io|
|
|
667
|
+
tk = nil
|
|
668
|
+
if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
|
|
669
|
+
(@lex_state != EXPR_ARG || @space_seen)
|
|
670
|
+
c = peek(0)
|
|
671
|
+
if /[-\w_\"\'\`]/ =~ c
|
|
672
|
+
tk = identify_here_document
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
if !tk
|
|
676
|
+
@lex_state = EXPR_BEG
|
|
677
|
+
tk = Token(op).set_text(op)
|
|
678
|
+
end
|
|
679
|
+
tk
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
@OP.def_rules("'", '"') do
|
|
683
|
+
|op, io|
|
|
684
|
+
identify_string(op)
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
@OP.def_rules("`") do
|
|
688
|
+
|op, io|
|
|
689
|
+
if @lex_state == EXPR_FNAME
|
|
690
|
+
Token(op).set_text(op)
|
|
691
|
+
else
|
|
692
|
+
identify_string(op)
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
|
|
696
|
+
@OP.def_rules('?') do
|
|
697
|
+
|op, io|
|
|
698
|
+
if @lex_state == EXPR_END
|
|
699
|
+
@lex_state = EXPR_BEG
|
|
700
|
+
Token(TkQUESTION).set_text(op)
|
|
701
|
+
else
|
|
702
|
+
ch = getc
|
|
703
|
+
if @lex_state == EXPR_ARG && ch !~ /\s/
|
|
704
|
+
ungetc
|
|
705
|
+
@lex_state = EXPR_BEG
|
|
706
|
+
Token(TkQUESTION).set_text(op)
|
|
707
|
+
else
|
|
708
|
+
str = op
|
|
709
|
+
str << ch
|
|
710
|
+
if (ch == '\\') #'
|
|
711
|
+
str << read_escape
|
|
712
|
+
end
|
|
713
|
+
@lex_state = EXPR_END
|
|
714
|
+
Token(TkINTEGER).set_text(str)
|
|
715
|
+
end
|
|
716
|
+
end
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
@OP.def_rules("&", "&&", "|", "||") do
|
|
720
|
+
|op, io|
|
|
721
|
+
@lex_state = EXPR_BEG
|
|
722
|
+
Token(op).set_text(op)
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
@OP.def_rules("+=", "-=", "*=", "**=",
|
|
726
|
+
"&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
|
|
727
|
+
|op, io|
|
|
728
|
+
@lex_state = EXPR_BEG
|
|
729
|
+
op =~ /^(.*)=$/
|
|
730
|
+
Token(TkOPASGN, $1).set_text(op)
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
@OP.def_rule("+@", proc{@lex_state == EXPR_FNAME}) do |op, io|
|
|
734
|
+
Token(TkUPLUS).set_text(op)
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
@OP.def_rule("-@", proc{@lex_state == EXPR_FNAME}) do |op, io|
|
|
738
|
+
Token(TkUMINUS).set_text(op)
|
|
739
|
+
end
|
|
740
|
+
|
|
741
|
+
@OP.def_rules("+", "-") do
|
|
742
|
+
|op, io|
|
|
743
|
+
catch(:RET) do
|
|
744
|
+
if @lex_state == EXPR_ARG
|
|
745
|
+
if @space_seen and peek(0) =~ /[0-9]/
|
|
746
|
+
throw :RET, identify_number(op)
|
|
747
|
+
else
|
|
748
|
+
@lex_state = EXPR_BEG
|
|
749
|
+
end
|
|
750
|
+
elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
|
|
751
|
+
throw :RET, identify_number(op)
|
|
752
|
+
else
|
|
753
|
+
@lex_state = EXPR_BEG
|
|
754
|
+
end
|
|
755
|
+
Token(op).set_text(op)
|
|
756
|
+
end
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
@OP.def_rule(".") do
|
|
760
|
+
@lex_state = EXPR_BEG
|
|
761
|
+
if peek(0) =~ /[0-9]/
|
|
762
|
+
ungetc
|
|
763
|
+
identify_number("")
|
|
764
|
+
else
|
|
765
|
+
# for obj.if
|
|
766
|
+
@lex_state = EXPR_DOT
|
|
767
|
+
Token(TkDOT).set_text(".")
|
|
768
|
+
end
|
|
769
|
+
end
|
|
770
|
+
|
|
771
|
+
@OP.def_rules("..", "...") do
|
|
772
|
+
|op, io|
|
|
773
|
+
@lex_state = EXPR_BEG
|
|
774
|
+
Token(op).set_text(op)
|
|
775
|
+
end
|
|
776
|
+
|
|
777
|
+
lex_int2
|
|
778
|
+
end
|
|
779
|
+
|
|
780
|
+
def lex_int2
|
|
781
|
+
@OP.def_rules("]", "}", ")") do
|
|
782
|
+
|op, io|
|
|
783
|
+
@lex_state = EXPR_END
|
|
784
|
+
@indent -= 1
|
|
785
|
+
Token(op).set_text(op)
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
@OP.def_rule(":") do
|
|
789
|
+
if @lex_state == EXPR_END || peek(0) =~ /\s/
|
|
790
|
+
@lex_state = EXPR_BEG
|
|
791
|
+
tk = Token(TkCOLON)
|
|
792
|
+
else
|
|
793
|
+
@lex_state = EXPR_FNAME
|
|
794
|
+
tk = Token(TkSYMBEG)
|
|
795
|
+
end
|
|
796
|
+
tk.set_text(":")
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
@OP.def_rule("::") do
|
|
800
|
+
if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen
|
|
801
|
+
@lex_state = EXPR_BEG
|
|
802
|
+
tk = Token(TkCOLON3)
|
|
803
|
+
else
|
|
804
|
+
@lex_state = EXPR_DOT
|
|
805
|
+
tk = Token(TkCOLON2)
|
|
806
|
+
end
|
|
807
|
+
tk.set_text("::")
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
@OP.def_rule("/") do
|
|
811
|
+
|op, io|
|
|
812
|
+
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
|
|
813
|
+
identify_string(op)
|
|
814
|
+
elsif peek(0) == '='
|
|
815
|
+
getc
|
|
816
|
+
@lex_state = EXPR_BEG
|
|
817
|
+
Token(TkOPASGN, :/).set_text("/=") #")
|
|
818
|
+
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
|
|
819
|
+
identify_string(op)
|
|
820
|
+
else
|
|
821
|
+
@lex_state = EXPR_BEG
|
|
822
|
+
Token("/").set_text(op)
|
|
823
|
+
end
|
|
824
|
+
end
|
|
825
|
+
|
|
826
|
+
@OP.def_rules("^") do
|
|
827
|
+
@lex_state = EXPR_BEG
|
|
828
|
+
Token("^").set_text("^")
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
@OP.def_rules(",", ";") do
|
|
832
|
+
|op, io|
|
|
833
|
+
@lex_state = EXPR_BEG
|
|
834
|
+
Token(op).set_text(op)
|
|
835
|
+
end
|
|
836
|
+
|
|
837
|
+
@OP.def_rule("~") do
|
|
838
|
+
@lex_state = EXPR_BEG
|
|
839
|
+
Token("~").set_text("~")
|
|
840
|
+
end
|
|
841
|
+
|
|
842
|
+
@OP.def_rule("~@", proc{@lex_state = EXPR_FNAME}) do
|
|
843
|
+
@lex_state = EXPR_BEG
|
|
844
|
+
Token("~").set_text("~@")
|
|
845
|
+
end
|
|
846
|
+
|
|
847
|
+
@OP.def_rule("(") do
|
|
848
|
+
@indent += 1
|
|
849
|
+
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
|
|
850
|
+
@lex_state = EXPR_BEG
|
|
851
|
+
tk = Token(TkfLPAREN)
|
|
852
|
+
else
|
|
853
|
+
@lex_state = EXPR_BEG
|
|
854
|
+
tk = Token(TkLPAREN)
|
|
855
|
+
end
|
|
856
|
+
tk.set_text("(")
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
@OP.def_rule("[]", proc{@lex_state == EXPR_FNAME}) do
|
|
860
|
+
Token("[]").set_text("[]")
|
|
861
|
+
end
|
|
862
|
+
|
|
863
|
+
@OP.def_rule("[]=", proc{@lex_state == EXPR_FNAME}) do
|
|
864
|
+
Token("[]=").set_text("[]=")
|
|
865
|
+
end
|
|
866
|
+
|
|
867
|
+
@OP.def_rule("[") do
|
|
868
|
+
@indent += 1
|
|
869
|
+
if @lex_state == EXPR_FNAME
|
|
870
|
+
t = Token(TkfLBRACK)
|
|
871
|
+
else
|
|
872
|
+
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
|
|
873
|
+
t = Token(TkLBRACK)
|
|
874
|
+
elsif @lex_state == EXPR_ARG && @space_seen
|
|
875
|
+
t = Token(TkLBRACK)
|
|
876
|
+
else
|
|
877
|
+
t = Token(TkfLBRACK)
|
|
878
|
+
end
|
|
879
|
+
@lex_state = EXPR_BEG
|
|
880
|
+
end
|
|
881
|
+
t.set_text("[")
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
@OP.def_rule("{") do
|
|
885
|
+
@indent += 1
|
|
886
|
+
if @lex_state != EXPR_END && @lex_state != EXPR_ARG
|
|
887
|
+
t = Token(TkLBRACE)
|
|
888
|
+
else
|
|
889
|
+
t = Token(TkfLBRACE)
|
|
890
|
+
end
|
|
891
|
+
@lex_state = EXPR_BEG
|
|
892
|
+
t.set_text("{")
|
|
893
|
+
end
|
|
894
|
+
|
|
895
|
+
@OP.def_rule('\\') do #'
|
|
896
|
+
if getc == "\n"
|
|
897
|
+
@space_seen = true
|
|
898
|
+
@continue = true
|
|
899
|
+
Token(TkSPACE).set_text("\\\n")
|
|
900
|
+
else
|
|
901
|
+
ungetc
|
|
902
|
+
Token("\\").set_text("\\") #"
|
|
903
|
+
end
|
|
904
|
+
end
|
|
905
|
+
|
|
906
|
+
@OP.def_rule('%') do
|
|
907
|
+
|op, io|
|
|
908
|
+
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
|
|
909
|
+
identify_quotation('%')
|
|
910
|
+
elsif peek(0) == '='
|
|
911
|
+
getc
|
|
912
|
+
Token(TkOPASGN, "%").set_text("%=")
|
|
913
|
+
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
|
|
914
|
+
identify_quotation('%')
|
|
915
|
+
else
|
|
916
|
+
@lex_state = EXPR_BEG
|
|
917
|
+
Token("%").set_text("%")
|
|
918
|
+
end
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
@OP.def_rule('$') do #'
|
|
922
|
+
identify_gvar
|
|
923
|
+
end
|
|
924
|
+
|
|
925
|
+
@OP.def_rule('@') do
|
|
926
|
+
if peek(0) =~ /[@\w_]/
|
|
927
|
+
ungetc
|
|
928
|
+
identify_identifier
|
|
929
|
+
else
|
|
930
|
+
Token("@").set_text("@")
|
|
931
|
+
end
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
@OP.def_rule("__END__", proc{@prev_char_no == 0 && peek(0) =~ /[\r\n]/}) do
|
|
935
|
+
throw :eof
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
@OP.def_rule("") do
|
|
939
|
+
|op, io|
|
|
940
|
+
printf "MATCH: start %s: %s\n", op, io.inspect if RDoc::RubyLex.debug?
|
|
941
|
+
if peek(0) =~ /[0-9]/
|
|
942
|
+
t = identify_number("")
|
|
943
|
+
elsif peek(0) =~ /[\w_]/
|
|
944
|
+
t = identify_identifier
|
|
945
|
+
end
|
|
946
|
+
printf "MATCH: end %s: %s\n", op, io.inspect if RDoc::RubyLex.debug?
|
|
947
|
+
t
|
|
948
|
+
end
|
|
949
|
+
end
|
|
950
|
+
|
|
951
|
+
def identify_gvar
|
|
952
|
+
@lex_state = EXPR_END
|
|
953
|
+
str = "$"
|
|
954
|
+
|
|
955
|
+
tk = case ch = getc
|
|
956
|
+
when /[~_*$?!@\/\\;,=:<>".]/ #"
|
|
957
|
+
str << ch
|
|
958
|
+
Token(TkGVAR, str)
|
|
959
|
+
|
|
960
|
+
when "-"
|
|
961
|
+
str << "-" << getc
|
|
962
|
+
Token(TkGVAR, str)
|
|
963
|
+
|
|
964
|
+
when "&", "`", "'", "+"
|
|
965
|
+
str << ch
|
|
966
|
+
Token(TkBACK_REF, str)
|
|
967
|
+
|
|
968
|
+
when /[1-9]/
|
|
969
|
+
str << ch
|
|
970
|
+
while (ch = getc) =~ /[0-9]/
|
|
971
|
+
str << ch
|
|
972
|
+
end
|
|
973
|
+
ungetc
|
|
974
|
+
Token(TkNTH_REF)
|
|
975
|
+
when /\w/
|
|
976
|
+
ungetc
|
|
977
|
+
ungetc
|
|
978
|
+
return identify_identifier
|
|
979
|
+
else
|
|
980
|
+
ungetc
|
|
981
|
+
Token("$")
|
|
982
|
+
end
|
|
983
|
+
tk.set_text(str)
|
|
984
|
+
end
|
|
985
|
+
|
|
986
|
+
def identify_identifier
|
|
987
|
+
token = ""
|
|
988
|
+
token.concat getc if peek(0) =~ /[$@]/
|
|
989
|
+
token.concat getc if peek(0) == "@"
|
|
990
|
+
|
|
991
|
+
while (ch = getc) =~ /\w|_/
|
|
992
|
+
print ":", ch, ":" if RDoc::RubyLex.debug?
|
|
993
|
+
token.concat ch
|
|
994
|
+
end
|
|
995
|
+
ungetc
|
|
996
|
+
|
|
997
|
+
if ch == "!" or ch == "?"
|
|
998
|
+
token.concat getc
|
|
999
|
+
end
|
|
1000
|
+
# fix token
|
|
1001
|
+
|
|
1002
|
+
# $stderr.puts "identifier - #{token}, state = #@lex_state"
|
|
1003
|
+
|
|
1004
|
+
case token
|
|
1005
|
+
when /^\$/
|
|
1006
|
+
return Token(TkGVAR, token).set_text(token)
|
|
1007
|
+
when /^\@/
|
|
1008
|
+
@lex_state = EXPR_END
|
|
1009
|
+
return Token(TkIVAR, token).set_text(token)
|
|
1010
|
+
end
|
|
1011
|
+
|
|
1012
|
+
if @lex_state != EXPR_DOT
|
|
1013
|
+
print token, "\n" if RDoc::RubyLex.debug?
|
|
1014
|
+
|
|
1015
|
+
token_c, *trans = TkReading2Token[token]
|
|
1016
|
+
if token_c
|
|
1017
|
+
# reserved word?
|
|
1018
|
+
|
|
1019
|
+
if (@lex_state != EXPR_BEG &&
|
|
1020
|
+
@lex_state != EXPR_FNAME &&
|
|
1021
|
+
trans[1])
|
|
1022
|
+
# modifiers
|
|
1023
|
+
token_c = TkSymbol2Token[trans[1]]
|
|
1024
|
+
@lex_state = trans[0]
|
|
1025
|
+
else
|
|
1026
|
+
if @lex_state != EXPR_FNAME
|
|
1027
|
+
if ENINDENT_CLAUSE.include?(token)
|
|
1028
|
+
@indent += 1
|
|
1029
|
+
elsif DEINDENT_CLAUSE.include?(token)
|
|
1030
|
+
@indent -= 1
|
|
1031
|
+
end
|
|
1032
|
+
@lex_state = trans[0]
|
|
1033
|
+
else
|
|
1034
|
+
@lex_state = EXPR_END
|
|
1035
|
+
end
|
|
1036
|
+
end
|
|
1037
|
+
return Token(token_c, token).set_text(token)
|
|
1038
|
+
end
|
|
1039
|
+
end
|
|
1040
|
+
|
|
1041
|
+
if @lex_state == EXPR_FNAME
|
|
1042
|
+
@lex_state = EXPR_END
|
|
1043
|
+
if peek(0) == '='
|
|
1044
|
+
token.concat getc
|
|
1045
|
+
end
|
|
1046
|
+
elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT
|
|
1047
|
+
@lex_state = EXPR_ARG
|
|
1048
|
+
else
|
|
1049
|
+
@lex_state = EXPR_END
|
|
1050
|
+
end
|
|
1051
|
+
|
|
1052
|
+
if token[0, 1] =~ /[A-Z]/
|
|
1053
|
+
return Token(TkCONSTANT, token).set_text(token)
|
|
1054
|
+
elsif token[token.size - 1, 1] =~ /[!?]/
|
|
1055
|
+
return Token(TkFID, token).set_text(token)
|
|
1056
|
+
else
|
|
1057
|
+
return Token(TkIDENTIFIER, token).set_text(token)
|
|
1058
|
+
end
|
|
1059
|
+
end
|
|
1060
|
+
|
|
1061
|
+
def identify_here_document
|
|
1062
|
+
ch = getc
|
|
1063
|
+
if ch == "-"
|
|
1064
|
+
ch = getc
|
|
1065
|
+
indent = true
|
|
1066
|
+
end
|
|
1067
|
+
if /['"`]/ =~ ch # '
|
|
1068
|
+
lt = ch
|
|
1069
|
+
quoted = ""
|
|
1070
|
+
while (c = getc) && c != lt
|
|
1071
|
+
quoted.concat c
|
|
1072
|
+
end
|
|
1073
|
+
else
|
|
1074
|
+
lt = '"'
|
|
1075
|
+
quoted = ch.dup
|
|
1076
|
+
while (c = getc) && c =~ /\w/
|
|
1077
|
+
quoted.concat c
|
|
1078
|
+
end
|
|
1079
|
+
ungetc
|
|
1080
|
+
end
|
|
1081
|
+
|
|
1082
|
+
ltback, @ltype = @ltype, lt
|
|
1083
|
+
reserve = ""
|
|
1084
|
+
|
|
1085
|
+
while ch = getc
|
|
1086
|
+
reserve << ch
|
|
1087
|
+
if ch == "\\" #"
|
|
1088
|
+
ch = getc
|
|
1089
|
+
reserve << ch
|
|
1090
|
+
elsif ch == "\n"
|
|
1091
|
+
break
|
|
1092
|
+
end
|
|
1093
|
+
end
|
|
1094
|
+
|
|
1095
|
+
str = ""
|
|
1096
|
+
while (l = gets)
|
|
1097
|
+
l.chomp!
|
|
1098
|
+
l.strip! if indent
|
|
1099
|
+
break if l == quoted
|
|
1100
|
+
str << l.chomp << "\n"
|
|
1101
|
+
end
|
|
1102
|
+
|
|
1103
|
+
@reader.divert_read_from(reserve)
|
|
1104
|
+
|
|
1105
|
+
@ltype = ltback
|
|
1106
|
+
@lex_state = EXPR_END
|
|
1107
|
+
Token(Ltype2Token[lt], str).set_text(str.dump)
|
|
1108
|
+
end
|
|
1109
|
+
|
|
1110
|
+
def identify_quotation(initial_char)
|
|
1111
|
+
ch = getc
|
|
1112
|
+
if lt = PERCENT_LTYPE[ch]
|
|
1113
|
+
initial_char += ch
|
|
1114
|
+
ch = getc
|
|
1115
|
+
elsif ch =~ /\W/
|
|
1116
|
+
lt = "\""
|
|
1117
|
+
else
|
|
1118
|
+
fail SyntaxError, "unknown type of %string ('#{ch}')"
|
|
1119
|
+
end
|
|
1120
|
+
# if ch !~ /\W/
|
|
1121
|
+
# ungetc
|
|
1122
|
+
# next
|
|
1123
|
+
# end
|
|
1124
|
+
#@ltype = lt
|
|
1125
|
+
@quoted = ch unless @quoted = PERCENT_PAREN[ch]
|
|
1126
|
+
identify_string(lt, @quoted, ch, initial_char)
|
|
1127
|
+
end
|
|
1128
|
+
|
|
1129
|
+
def identify_number(start)
|
|
1130
|
+
str = start.dup
|
|
1131
|
+
|
|
1132
|
+
if start == "+" or start == "-" or start == ""
|
|
1133
|
+
start = getc
|
|
1134
|
+
str << start
|
|
1135
|
+
end
|
|
1136
|
+
|
|
1137
|
+
@lex_state = EXPR_END
|
|
1138
|
+
|
|
1139
|
+
if start == "0"
|
|
1140
|
+
if peek(0) == "x"
|
|
1141
|
+
ch = getc
|
|
1142
|
+
str << ch
|
|
1143
|
+
match = /[0-9a-f_]/
|
|
1144
|
+
else
|
|
1145
|
+
match = /[0-7_]/
|
|
1146
|
+
end
|
|
1147
|
+
while ch = getc
|
|
1148
|
+
if ch !~ match
|
|
1149
|
+
ungetc
|
|
1150
|
+
break
|
|
1151
|
+
else
|
|
1152
|
+
str << ch
|
|
1153
|
+
end
|
|
1154
|
+
end
|
|
1155
|
+
return Token(TkINTEGER).set_text(str)
|
|
1156
|
+
end
|
|
1157
|
+
|
|
1158
|
+
type = TkINTEGER
|
|
1159
|
+
allow_point = TRUE
|
|
1160
|
+
allow_e = TRUE
|
|
1161
|
+
while ch = getc
|
|
1162
|
+
case ch
|
|
1163
|
+
when /[0-9_]/
|
|
1164
|
+
str << ch
|
|
1165
|
+
|
|
1166
|
+
when allow_point && "."
|
|
1167
|
+
type = TkFLOAT
|
|
1168
|
+
if peek(0) !~ /[0-9]/
|
|
1169
|
+
ungetc
|
|
1170
|
+
break
|
|
1171
|
+
end
|
|
1172
|
+
str << ch
|
|
1173
|
+
allow_point = false
|
|
1174
|
+
|
|
1175
|
+
when allow_e && "e", allow_e && "E"
|
|
1176
|
+
str << ch
|
|
1177
|
+
type = TkFLOAT
|
|
1178
|
+
if peek(0) =~ /[+-]/
|
|
1179
|
+
str << getc
|
|
1180
|
+
end
|
|
1181
|
+
allow_e = false
|
|
1182
|
+
allow_point = false
|
|
1183
|
+
else
|
|
1184
|
+
ungetc
|
|
1185
|
+
break
|
|
1186
|
+
end
|
|
1187
|
+
end
|
|
1188
|
+
Token(type).set_text(str)
|
|
1189
|
+
end
|
|
1190
|
+
|
|
1191
|
+
def identify_string(ltype, quoted = ltype, opener=nil, initial_char = nil)
|
|
1192
|
+
@ltype = ltype
|
|
1193
|
+
@quoted = quoted
|
|
1194
|
+
subtype = nil
|
|
1195
|
+
|
|
1196
|
+
str = ""
|
|
1197
|
+
str << initial_char if initial_char
|
|
1198
|
+
str << (opener||quoted)
|
|
1199
|
+
|
|
1200
|
+
nest = 0
|
|
1201
|
+
begin
|
|
1202
|
+
while ch = getc
|
|
1203
|
+
str << ch
|
|
1204
|
+
if @quoted == ch
|
|
1205
|
+
if nest == 0
|
|
1206
|
+
break
|
|
1207
|
+
else
|
|
1208
|
+
nest -= 1
|
|
1209
|
+
end
|
|
1210
|
+
elsif opener == ch
|
|
1211
|
+
nest += 1
|
|
1212
|
+
elsif @ltype != "'" && @ltype != "]" and ch == "#"
|
|
1213
|
+
ch = getc
|
|
1214
|
+
if ch == "{"
|
|
1215
|
+
subtype = true
|
|
1216
|
+
str << ch << skip_inner_expression
|
|
1217
|
+
else
|
|
1218
|
+
ungetc(ch)
|
|
1219
|
+
end
|
|
1220
|
+
elsif ch == '\\' #'
|
|
1221
|
+
str << read_escape
|
|
1222
|
+
end
|
|
1223
|
+
end
|
|
1224
|
+
if @ltype == "/"
|
|
1225
|
+
if peek(0) =~ /i|o|n|e|s/
|
|
1226
|
+
str << getc
|
|
1227
|
+
end
|
|
1228
|
+
end
|
|
1229
|
+
if subtype
|
|
1230
|
+
Token(DLtype2Token[ltype], str)
|
|
1231
|
+
else
|
|
1232
|
+
Token(Ltype2Token[ltype], str)
|
|
1233
|
+
end.set_text(str)
|
|
1234
|
+
ensure
|
|
1235
|
+
@ltype = nil
|
|
1236
|
+
@quoted = nil
|
|
1237
|
+
@lex_state = EXPR_END
|
|
1238
|
+
end
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
def skip_inner_expression
|
|
1242
|
+
res = ""
|
|
1243
|
+
nest = 0
|
|
1244
|
+
while (ch = getc)
|
|
1245
|
+
res << ch
|
|
1246
|
+
if ch == '}'
|
|
1247
|
+
break if nest.zero?
|
|
1248
|
+
nest -= 1
|
|
1249
|
+
elsif ch == '{'
|
|
1250
|
+
nest += 1
|
|
1251
|
+
end
|
|
1252
|
+
end
|
|
1253
|
+
res
|
|
1254
|
+
end
|
|
1255
|
+
|
|
1256
|
+
def identify_comment
|
|
1257
|
+
@ltype = "#"
|
|
1258
|
+
comment = "#"
|
|
1259
|
+
while ch = getc
|
|
1260
|
+
if ch == "\\"
|
|
1261
|
+
ch = getc
|
|
1262
|
+
if ch == "\n"
|
|
1263
|
+
ch = " "
|
|
1264
|
+
else
|
|
1265
|
+
comment << "\\"
|
|
1266
|
+
end
|
|
1267
|
+
else
|
|
1268
|
+
if ch == "\n"
|
|
1269
|
+
@ltype = nil
|
|
1270
|
+
ungetc
|
|
1271
|
+
break
|
|
1272
|
+
end
|
|
1273
|
+
end
|
|
1274
|
+
comment << ch
|
|
1275
|
+
end
|
|
1276
|
+
return Token(TkCOMMENT).set_text(comment)
|
|
1277
|
+
end
|
|
1278
|
+
|
|
1279
|
+
def read_escape
|
|
1280
|
+
res = ""
|
|
1281
|
+
case ch = getc
|
|
1282
|
+
when /[0-7]/
|
|
1283
|
+
ungetc ch
|
|
1284
|
+
3.times do
|
|
1285
|
+
case ch = getc
|
|
1286
|
+
when /[0-7]/
|
|
1287
|
+
when nil
|
|
1288
|
+
break
|
|
1289
|
+
else
|
|
1290
|
+
ungetc
|
|
1291
|
+
break
|
|
1292
|
+
end
|
|
1293
|
+
res << ch
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1296
|
+
when "x"
|
|
1297
|
+
res << ch
|
|
1298
|
+
2.times do
|
|
1299
|
+
case ch = getc
|
|
1300
|
+
when /[0-9a-fA-F]/
|
|
1301
|
+
when nil
|
|
1302
|
+
break
|
|
1303
|
+
else
|
|
1304
|
+
ungetc
|
|
1305
|
+
break
|
|
1306
|
+
end
|
|
1307
|
+
res << ch
|
|
1308
|
+
end
|
|
1309
|
+
|
|
1310
|
+
when "M"
|
|
1311
|
+
res << ch
|
|
1312
|
+
if (ch = getc) != '-'
|
|
1313
|
+
ungetc
|
|
1314
|
+
else
|
|
1315
|
+
res << ch
|
|
1316
|
+
if (ch = getc) == "\\" #"
|
|
1317
|
+
res << ch
|
|
1318
|
+
res << read_escape
|
|
1319
|
+
else
|
|
1320
|
+
res << ch
|
|
1321
|
+
end
|
|
1322
|
+
end
|
|
1323
|
+
|
|
1324
|
+
when "C", "c" #, "^"
|
|
1325
|
+
res << ch
|
|
1326
|
+
if ch == "C" and (ch = getc) != "-"
|
|
1327
|
+
ungetc
|
|
1328
|
+
else
|
|
1329
|
+
res << ch
|
|
1330
|
+
if (ch = getc) == "\\" #"
|
|
1331
|
+
res << ch
|
|
1332
|
+
res << read_escape
|
|
1333
|
+
else
|
|
1334
|
+
res << ch
|
|
1335
|
+
end
|
|
1336
|
+
end
|
|
1337
|
+
else
|
|
1338
|
+
res << ch
|
|
1339
|
+
end
|
|
1340
|
+
res
|
|
1341
|
+
end
|
|
1342
|
+
end
|
|
1343
|
+
|
|
1344
|
+
##
|
|
1345
|
+
# Extracts code elements from a source file returning a TopLevel object
|
|
1346
|
+
# containing the constituent file elements.
|
|
1347
|
+
#
|
|
1348
|
+
# This file is based on rtags
|
|
1349
|
+
#
|
|
1350
|
+
# RubyParser understands how to document:
|
|
1351
|
+
# * classes
|
|
1352
|
+
# * modules
|
|
1353
|
+
# * methods
|
|
1354
|
+
# * constants
|
|
1355
|
+
# * aliases
|
|
1356
|
+
# * private, public, protected
|
|
1357
|
+
# * private_class_function, public_class_function
|
|
1358
|
+
# * module_function
|
|
1359
|
+
# * attr, attr_reader, attr_writer, attr_accessor
|
|
1360
|
+
# * extra accessors given on the command line
|
|
1361
|
+
# * metaprogrammed methods
|
|
1362
|
+
# * require
|
|
1363
|
+
# * include
|
|
1364
|
+
#
|
|
1365
|
+
# == Method Arguments
|
|
1366
|
+
#
|
|
1367
|
+
#--
|
|
1368
|
+
# NOTE: I don't think this works, needs tests, remove the paragraph following
|
|
1369
|
+
# this block when known to work
|
|
1370
|
+
#
|
|
1371
|
+
# The parser extracts the arguments from the method definition. You can
|
|
1372
|
+
# override this with a custom argument definition using the :args: directive:
|
|
1373
|
+
#
|
|
1374
|
+
# ##
|
|
1375
|
+
# # This method tries over and over until it is tired
|
|
1376
|
+
#
|
|
1377
|
+
# def go_go_go(thing_to_try, tries = 10) # :args: thing_to_try
|
|
1378
|
+
# puts thing_to_try
|
|
1379
|
+
# go_go_go thing_to_try, tries - 1
|
|
1380
|
+
# end
|
|
1381
|
+
#
|
|
1382
|
+
# If you have a more-complex set of overrides you can use the :call-seq:
|
|
1383
|
+
# directive:
|
|
1384
|
+
#++
|
|
1385
|
+
#
|
|
1386
|
+
# The parser extracts the arguments from the method definition. You can
|
|
1387
|
+
# override this with a custom argument definition using the :call-seq:
|
|
1388
|
+
# directive:
|
|
1389
|
+
#
|
|
1390
|
+
# ##
|
|
1391
|
+
# # This method can be called with a range or an offset and length
|
|
1392
|
+
# #
|
|
1393
|
+
# # :call-seq:
|
|
1394
|
+
# # my_method(Range)
|
|
1395
|
+
# # my_method(offset, length)
|
|
1396
|
+
#
|
|
1397
|
+
# def my_method(*args)
|
|
1398
|
+
# end
|
|
1399
|
+
#
|
|
1400
|
+
# The parser extracts +yield+ expressions from method bodies to gather the
|
|
1401
|
+
# yielded argument names. If your method manually calls a block instead of
|
|
1402
|
+
# yielding or you want to override the discovered argument names use
|
|
1403
|
+
# the :yields: directive:
|
|
1404
|
+
#
|
|
1405
|
+
# ##
|
|
1406
|
+
# # My method is awesome
|
|
1407
|
+
#
|
|
1408
|
+
# def my_method(&block) # :yields: happy, times
|
|
1409
|
+
# block.call 1, 2
|
|
1410
|
+
# end
|
|
1411
|
+
#
|
|
1412
|
+
# == Metaprogrammed Methods
|
|
1413
|
+
#
|
|
1414
|
+
# To pick up a metaprogrammed method, the parser looks for a comment starting
|
|
1415
|
+
# with '##' before an identifier:
|
|
1416
|
+
#
|
|
1417
|
+
# ##
|
|
1418
|
+
# # This is a meta-programmed method!
|
|
1419
|
+
#
|
|
1420
|
+
# add_my_method :meta_method, :arg1, :arg2
|
|
1421
|
+
#
|
|
1422
|
+
# The parser looks at the token after the identifier to determine the name, in
|
|
1423
|
+
# this example, :meta_method. If a name cannot be found, a warning is printed
|
|
1424
|
+
# and 'unknown is used.
|
|
1425
|
+
#
|
|
1426
|
+
# You can force the name of a method using the :method: directive:
|
|
1427
|
+
#
|
|
1428
|
+
# ##
|
|
1429
|
+
# # :method: woo_hoo!
|
|
1430
|
+
#
|
|
1431
|
+
# By default, meta-methods are instance methods. To indicate that a method is
|
|
1432
|
+
# a singleton method instead use the :singleton-method: directive:
|
|
1433
|
+
#
|
|
1434
|
+
# ##
|
|
1435
|
+
# # :singleton-method:
|
|
1436
|
+
#
|
|
1437
|
+
# You can also use the :singleton-method: directive with a name:
|
|
1438
|
+
#
|
|
1439
|
+
# ##
|
|
1440
|
+
# # :singleton-method: woo_hoo!
|
|
1441
|
+
#
|
|
1442
|
+
# == Hidden methods
|
|
1443
|
+
#
|
|
1444
|
+
# You can provide documentation for methods that don't appear using
|
|
1445
|
+
# the :method: and :singleton-method: directives:
|
|
1446
|
+
#
|
|
1447
|
+
# ##
|
|
1448
|
+
# # :method: ghost_method
|
|
1449
|
+
# # There is a method here, but you can't see it!
|
|
1450
|
+
#
|
|
1451
|
+
# ##
|
|
1452
|
+
# # this is a comment for a regular method
|
|
1453
|
+
#
|
|
1454
|
+
# def regular_method() end
|
|
1455
|
+
#
|
|
1456
|
+
# Note that by default, the :method: directive will be ignored if there is a
|
|
1457
|
+
# standard rdocable item following it.
|
|
1458
|
+
|
|
1459
|
+
class RDoc::Parser::Ruby < RDoc::Parser
|
|
1460
|
+
|
|
1461
|
+
parse_files_matching(/\.rbw?$/)
|
|
1462
|
+
|
|
1463
|
+
include RDoc::RubyToken
|
|
1464
|
+
include RDoc::TokenStream
|
|
1465
|
+
|
|
1466
|
+
NORMAL = "::"
|
|
1467
|
+
SINGLE = "<<"
|
|
1468
|
+
|
|
1469
|
+
def initialize(top_level, file_name, content, options, stats)
|
|
1470
|
+
super
|
|
1471
|
+
|
|
1472
|
+
@size = 0
|
|
1473
|
+
@token_listeners = nil
|
|
1474
|
+
@scanner = RDoc::RubyLex.new content, @options
|
|
1475
|
+
@scanner.exception_on_syntax_error = false
|
|
1476
|
+
|
|
1477
|
+
reset
|
|
1478
|
+
end
|
|
1479
|
+
|
|
1480
|
+
def add_token_listener(obj)
|
|
1481
|
+
@token_listeners ||= []
|
|
1482
|
+
@token_listeners << obj
|
|
1483
|
+
end
|
|
1484
|
+
|
|
1485
|
+
##
|
|
1486
|
+
# Look for the first comment in a file that isn't a shebang line.
|
|
1487
|
+
|
|
1488
|
+
def collect_first_comment
|
|
1489
|
+
skip_tkspace
|
|
1490
|
+
res = ''
|
|
1491
|
+
first_line = true
|
|
1492
|
+
|
|
1493
|
+
tk = get_tk
|
|
1494
|
+
|
|
1495
|
+
while TkCOMMENT === tk
|
|
1496
|
+
if first_line and tk.text =~ /\A#!/ then
|
|
1497
|
+
skip_tkspace
|
|
1498
|
+
tk = get_tk
|
|
1499
|
+
elsif first_line and tk.text =~ /\A#\s*-\*-/ then
|
|
1500
|
+
first_line = false
|
|
1501
|
+
skip_tkspace
|
|
1502
|
+
tk = get_tk
|
|
1503
|
+
else
|
|
1504
|
+
first_line = false
|
|
1505
|
+
res << tk.text << "\n"
|
|
1506
|
+
tk = get_tk
|
|
1507
|
+
|
|
1508
|
+
if TkNL === tk then
|
|
1509
|
+
skip_tkspace false
|
|
1510
|
+
tk = get_tk
|
|
1511
|
+
end
|
|
1512
|
+
end
|
|
1513
|
+
end
|
|
1514
|
+
|
|
1515
|
+
unget_tk tk
|
|
1516
|
+
|
|
1517
|
+
res
|
|
1518
|
+
end
|
|
1519
|
+
|
|
1520
|
+
def error(msg)
|
|
1521
|
+
msg = make_message msg
|
|
1522
|
+
$stderr.puts msg
|
|
1523
|
+
exit(1)
|
|
1524
|
+
end
|
|
1525
|
+
|
|
1526
|
+
##
|
|
1527
|
+
# Look for a 'call-seq' in the comment, and override the normal parameter
|
|
1528
|
+
# stuff
|
|
1529
|
+
|
|
1530
|
+
def extract_call_seq(comment, meth)
|
|
1531
|
+
if comment.sub!(/:?call-seq:(.*?)^\s*\#?\s*$/m, '') then
|
|
1532
|
+
seq = $1
|
|
1533
|
+
seq.gsub!(/^\s*\#\s*/, '')
|
|
1534
|
+
meth.call_seq = seq
|
|
1535
|
+
end
|
|
1536
|
+
|
|
1537
|
+
meth
|
|
1538
|
+
end
|
|
1539
|
+
|
|
1540
|
+
def get_bool
|
|
1541
|
+
skip_tkspace
|
|
1542
|
+
tk = get_tk
|
|
1543
|
+
case tk
|
|
1544
|
+
when TkTRUE
|
|
1545
|
+
true
|
|
1546
|
+
when TkFALSE, TkNIL
|
|
1547
|
+
false
|
|
1548
|
+
else
|
|
1549
|
+
unget_tk tk
|
|
1550
|
+
true
|
|
1551
|
+
end
|
|
1552
|
+
end
|
|
1553
|
+
|
|
1554
|
+
##
|
|
1555
|
+
# Look for the name of a class of module (optionally with a leading :: or
|
|
1556
|
+
# with :: separated named) and return the ultimate name and container
|
|
1557
|
+
|
|
1558
|
+
def get_class_or_module(container)
|
|
1559
|
+
skip_tkspace
|
|
1560
|
+
name_t = get_tk
|
|
1561
|
+
|
|
1562
|
+
# class ::A -> A is in the top level
|
|
1563
|
+
if TkCOLON2 === name_t then
|
|
1564
|
+
name_t = get_tk
|
|
1565
|
+
container = @top_level
|
|
1566
|
+
end
|
|
1567
|
+
|
|
1568
|
+
skip_tkspace(false)
|
|
1569
|
+
|
|
1570
|
+
while TkCOLON2 === peek_tk do
|
|
1571
|
+
prev_container = container
|
|
1572
|
+
container = container.find_module_named(name_t.name)
|
|
1573
|
+
if !container
|
|
1574
|
+
# warn("Couldn't find module #{name_t.name}")
|
|
1575
|
+
container = prev_container.add_module RDoc::NormalModule, name_t.name
|
|
1576
|
+
end
|
|
1577
|
+
get_tk
|
|
1578
|
+
name_t = get_tk
|
|
1579
|
+
end
|
|
1580
|
+
skip_tkspace(false)
|
|
1581
|
+
return [container, name_t]
|
|
1582
|
+
end
|
|
1583
|
+
|
|
1584
|
+
##
|
|
1585
|
+
# Return a superclass, which can be either a constant of an expression
|
|
1586
|
+
|
|
1587
|
+
def get_class_specification
|
|
1588
|
+
tk = get_tk
|
|
1589
|
+
return "self" if TkSELF === tk
|
|
1590
|
+
|
|
1591
|
+
res = ""
|
|
1592
|
+
while TkCOLON2 === tk or TkCOLON3 === tk or TkCONSTANT === tk do
|
|
1593
|
+
res += tk.text
|
|
1594
|
+
tk = get_tk
|
|
1595
|
+
end
|
|
1596
|
+
|
|
1597
|
+
unget_tk(tk)
|
|
1598
|
+
skip_tkspace(false)
|
|
1599
|
+
|
|
1600
|
+
get_tkread # empty out read buffer
|
|
1601
|
+
|
|
1602
|
+
tk = get_tk
|
|
1603
|
+
|
|
1604
|
+
case tk
|
|
1605
|
+
when TkNL, TkCOMMENT, TkSEMICOLON then
|
|
1606
|
+
unget_tk(tk)
|
|
1607
|
+
return res
|
|
1608
|
+
end
|
|
1609
|
+
|
|
1610
|
+
res += parse_call_parameters(tk)
|
|
1611
|
+
res
|
|
1612
|
+
end
|
|
1613
|
+
|
|
1614
|
+
##
|
|
1615
|
+
# Parse a constant, which might be qualified by one or more class or module
|
|
1616
|
+
# names
|
|
1617
|
+
|
|
1618
|
+
def get_constant
|
|
1619
|
+
res = ""
|
|
1620
|
+
skip_tkspace(false)
|
|
1621
|
+
tk = get_tk
|
|
1622
|
+
|
|
1623
|
+
while TkCOLON2 === tk or TkCOLON3 === tk or TkCONSTANT === tk do
|
|
1624
|
+
res += tk.text
|
|
1625
|
+
tk = get_tk
|
|
1626
|
+
end
|
|
1627
|
+
|
|
1628
|
+
# if res.empty?
|
|
1629
|
+
# warn("Unexpected token #{tk} in constant")
|
|
1630
|
+
# end
|
|
1631
|
+
unget_tk(tk)
|
|
1632
|
+
res
|
|
1633
|
+
end
|
|
1634
|
+
|
|
1635
|
+
##
|
|
1636
|
+
# Get a constant that may be surrounded by parens
|
|
1637
|
+
|
|
1638
|
+
def get_constant_with_optional_parens
|
|
1639
|
+
skip_tkspace(false)
|
|
1640
|
+
nest = 0
|
|
1641
|
+
while TkLPAREN === (tk = peek_tk) or TkfLPAREN === tk do
|
|
1642
|
+
get_tk
|
|
1643
|
+
skip_tkspace(true)
|
|
1644
|
+
nest += 1
|
|
1645
|
+
end
|
|
1646
|
+
|
|
1647
|
+
name = get_constant
|
|
1648
|
+
|
|
1649
|
+
while nest > 0
|
|
1650
|
+
skip_tkspace(true)
|
|
1651
|
+
tk = get_tk
|
|
1652
|
+
nest -= 1 if TkRPAREN === tk
|
|
1653
|
+
end
|
|
1654
|
+
name
|
|
1655
|
+
end
|
|
1656
|
+
|
|
1657
|
+
def get_symbol_or_name
|
|
1658
|
+
tk = get_tk
|
|
1659
|
+
case tk
|
|
1660
|
+
when TkSYMBOL
|
|
1661
|
+
tk.text.sub(/^:/, '')
|
|
1662
|
+
when TkId, TkOp
|
|
1663
|
+
tk.name
|
|
1664
|
+
when TkSTRING
|
|
1665
|
+
tk.text
|
|
1666
|
+
else
|
|
1667
|
+
raise "Name or symbol expected (got #{tk})"
|
|
1668
|
+
end
|
|
1669
|
+
end
|
|
1670
|
+
|
|
1671
|
+
def get_tk
|
|
1672
|
+
tk = nil
|
|
1673
|
+
if @tokens.empty?
|
|
1674
|
+
tk = @scanner.token
|
|
1675
|
+
@read.push @scanner.get_read
|
|
1676
|
+
puts "get_tk1 => #{tk.inspect}" if $TOKEN_DEBUG
|
|
1677
|
+
else
|
|
1678
|
+
@read.push @unget_read.shift
|
|
1679
|
+
tk = @tokens.shift
|
|
1680
|
+
puts "get_tk2 => #{tk.inspect}" if $TOKEN_DEBUG
|
|
1681
|
+
end
|
|
1682
|
+
|
|
1683
|
+
if TkSYMBEG === tk then
|
|
1684
|
+
set_token_position(tk.line_no, tk.char_no)
|
|
1685
|
+
tk1 = get_tk
|
|
1686
|
+
if TkId === tk1 or TkOp === tk1 or TkSTRING === tk1 then
|
|
1687
|
+
if tk1.respond_to?(:name)
|
|
1688
|
+
tk = Token(TkSYMBOL).set_text(":" + tk1.name)
|
|
1689
|
+
else
|
|
1690
|
+
tk = Token(TkSYMBOL).set_text(":" + tk1.text)
|
|
1691
|
+
end
|
|
1692
|
+
# remove the identifier we just read (we're about to
|
|
1693
|
+
# replace it with a symbol)
|
|
1694
|
+
@token_listeners.each do |obj|
|
|
1695
|
+
obj.pop_token
|
|
1696
|
+
end if @token_listeners
|
|
1697
|
+
else
|
|
1698
|
+
warn("':' not followed by identifier or operator")
|
|
1699
|
+
tk = tk1
|
|
1700
|
+
end
|
|
1701
|
+
end
|
|
1702
|
+
|
|
1703
|
+
# inform any listeners of our shiny new token
|
|
1704
|
+
@token_listeners.each do |obj|
|
|
1705
|
+
obj.add_token(tk)
|
|
1706
|
+
end if @token_listeners
|
|
1707
|
+
|
|
1708
|
+
tk
|
|
1709
|
+
end
|
|
1710
|
+
|
|
1711
|
+
def get_tkread
|
|
1712
|
+
read = @read.join("")
|
|
1713
|
+
@read = []
|
|
1714
|
+
read
|
|
1715
|
+
end
|
|
1716
|
+
|
|
1717
|
+
##
|
|
1718
|
+
# Look for directives in a normal comment block:
|
|
1719
|
+
#
|
|
1720
|
+
# #-- - don't display comment from this point forward
|
|
1721
|
+
#
|
|
1722
|
+
# This routine modifies it's parameter
|
|
1723
|
+
|
|
1724
|
+
def look_for_directives_in(context, comment)
|
|
1725
|
+
preprocess = RDoc::Markup::PreProcess.new(@file_name,
|
|
1726
|
+
@options.rdoc_include)
|
|
1727
|
+
|
|
1728
|
+
preprocess.handle(comment) do |directive, param|
|
|
1729
|
+
case directive
|
|
1730
|
+
when 'enddoc' then
|
|
1731
|
+
throw :enddoc
|
|
1732
|
+
when 'main' then
|
|
1733
|
+
@options.main_page = param
|
|
1734
|
+
''
|
|
1735
|
+
when 'method', 'singleton-method' then
|
|
1736
|
+
false # ignore
|
|
1737
|
+
when 'section' then
|
|
1738
|
+
context.set_current_section(param, comment)
|
|
1739
|
+
comment.replace ''
|
|
1740
|
+
break
|
|
1741
|
+
when 'startdoc' then
|
|
1742
|
+
context.start_doc
|
|
1743
|
+
context.force_documentation = true
|
|
1744
|
+
''
|
|
1745
|
+
when 'stopdoc' then
|
|
1746
|
+
context.stop_doc
|
|
1747
|
+
''
|
|
1748
|
+
when 'title' then
|
|
1749
|
+
@options.title = param
|
|
1750
|
+
''
|
|
1751
|
+
else
|
|
1752
|
+
warn "Unrecognized directive '#{directive}'"
|
|
1753
|
+
false
|
|
1754
|
+
end
|
|
1755
|
+
end
|
|
1756
|
+
|
|
1757
|
+
remove_private_comments(comment)
|
|
1758
|
+
end
|
|
1759
|
+
|
|
1760
|
+
def make_message(msg)
|
|
1761
|
+
prefix = "\n" + @file_name + ":"
|
|
1762
|
+
if @scanner
|
|
1763
|
+
prefix << "#{@scanner.line_no}:#{@scanner.char_no}: "
|
|
1764
|
+
end
|
|
1765
|
+
return prefix + msg
|
|
1766
|
+
end
|
|
1767
|
+
|
|
1768
|
+
def parse_attr(context, single, tk, comment)
|
|
1769
|
+
args = parse_symbol_arg(1)
|
|
1770
|
+
if args.size > 0
|
|
1771
|
+
name = args[0]
|
|
1772
|
+
rw = "R"
|
|
1773
|
+
skip_tkspace(false)
|
|
1774
|
+
tk = get_tk
|
|
1775
|
+
if TkCOMMA === tk then
|
|
1776
|
+
rw = "RW" if get_bool
|
|
1777
|
+
else
|
|
1778
|
+
unget_tk tk
|
|
1779
|
+
end
|
|
1780
|
+
att = RDoc::Attr.new get_tkread, name, rw, comment
|
|
1781
|
+
read_documentation_modifiers att, RDoc::ATTR_MODIFIERS
|
|
1782
|
+
if att.document_self
|
|
1783
|
+
context.add_attribute(att)
|
|
1784
|
+
end
|
|
1785
|
+
else
|
|
1786
|
+
warn("'attr' ignored - looks like a variable")
|
|
1787
|
+
end
|
|
1788
|
+
end
|
|
1789
|
+
|
|
1790
|
+
def parse_attr_accessor(context, single, tk, comment)
|
|
1791
|
+
args = parse_symbol_arg
|
|
1792
|
+
read = get_tkread
|
|
1793
|
+
rw = "?"
|
|
1794
|
+
|
|
1795
|
+
# If nodoc is given, don't document any of them
|
|
1796
|
+
|
|
1797
|
+
tmp = RDoc::CodeObject.new
|
|
1798
|
+
read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS
|
|
1799
|
+
return unless tmp.document_self
|
|
1800
|
+
|
|
1801
|
+
case tk.name
|
|
1802
|
+
when "attr_reader" then rw = "R"
|
|
1803
|
+
when "attr_writer" then rw = "W"
|
|
1804
|
+
when "attr_accessor" then rw = "RW"
|
|
1805
|
+
else
|
|
1806
|
+
rw = @options.extra_accessor_flags[tk.name]
|
|
1807
|
+
rw = '?' if rw.nil?
|
|
1808
|
+
end
|
|
1809
|
+
|
|
1810
|
+
for name in args
|
|
1811
|
+
att = RDoc::Attr.new get_tkread, name, rw, comment
|
|
1812
|
+
context.add_attribute att
|
|
1813
|
+
end
|
|
1814
|
+
end
|
|
1815
|
+
|
|
1816
|
+
def parse_alias(context, single, tk, comment)
|
|
1817
|
+
skip_tkspace
|
|
1818
|
+
if TkLPAREN === peek_tk then
|
|
1819
|
+
get_tk
|
|
1820
|
+
skip_tkspace
|
|
1821
|
+
end
|
|
1822
|
+
new_name = get_symbol_or_name
|
|
1823
|
+
@scanner.instance_eval{@lex_state = EXPR_FNAME}
|
|
1824
|
+
skip_tkspace
|
|
1825
|
+
if TkCOMMA === peek_tk then
|
|
1826
|
+
get_tk
|
|
1827
|
+
skip_tkspace
|
|
1828
|
+
end
|
|
1829
|
+
old_name = get_symbol_or_name
|
|
1830
|
+
|
|
1831
|
+
al = RDoc::Alias.new get_tkread, old_name, new_name, comment
|
|
1832
|
+
read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
|
|
1833
|
+
if al.document_self
|
|
1834
|
+
context.add_alias(al)
|
|
1835
|
+
end
|
|
1836
|
+
end
|
|
1837
|
+
|
|
1838
|
+
def parse_call_parameters(tk)
|
|
1839
|
+
end_token = case tk
|
|
1840
|
+
when TkLPAREN, TkfLPAREN
|
|
1841
|
+
TkRPAREN
|
|
1842
|
+
when TkRPAREN
|
|
1843
|
+
return ""
|
|
1844
|
+
else
|
|
1845
|
+
TkNL
|
|
1846
|
+
end
|
|
1847
|
+
nest = 0
|
|
1848
|
+
|
|
1849
|
+
loop do
|
|
1850
|
+
case tk
|
|
1851
|
+
when TkSEMICOLON
|
|
1852
|
+
break
|
|
1853
|
+
when TkLPAREN, TkfLPAREN
|
|
1854
|
+
nest += 1
|
|
1855
|
+
when end_token
|
|
1856
|
+
if end_token == TkRPAREN
|
|
1857
|
+
nest -= 1
|
|
1858
|
+
break if @scanner.lex_state == EXPR_END and nest <= 0
|
|
1859
|
+
else
|
|
1860
|
+
break unless @scanner.continue
|
|
1861
|
+
end
|
|
1862
|
+
when TkCOMMENT
|
|
1863
|
+
unget_tk(tk)
|
|
1864
|
+
break
|
|
1865
|
+
end
|
|
1866
|
+
tk = get_tk
|
|
1867
|
+
end
|
|
1868
|
+
res = get_tkread.tr("\n", " ").strip
|
|
1869
|
+
res = "" if res == ";"
|
|
1870
|
+
res
|
|
1871
|
+
end
|
|
1872
|
+
|
|
1873
|
+
def parse_class(container, single, tk, comment)
|
|
1874
|
+
container, name_t = get_class_or_module(container)
|
|
1875
|
+
|
|
1876
|
+
case name_t
|
|
1877
|
+
when TkCONSTANT
|
|
1878
|
+
name = name_t.name
|
|
1879
|
+
superclass = "Object"
|
|
1880
|
+
|
|
1881
|
+
if TkLT === peek_tk then
|
|
1882
|
+
get_tk
|
|
1883
|
+
skip_tkspace(true)
|
|
1884
|
+
superclass = get_class_specification
|
|
1885
|
+
superclass = "<unknown>" if superclass.empty?
|
|
1886
|
+
end
|
|
1887
|
+
|
|
1888
|
+
cls_type = single == SINGLE ? RDoc::SingleClass : RDoc::NormalClass
|
|
1889
|
+
cls = container.add_class cls_type, name, superclass
|
|
1890
|
+
|
|
1891
|
+
@stats.add_class cls
|
|
1892
|
+
|
|
1893
|
+
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
|
|
1894
|
+
cls.record_location @top_level
|
|
1895
|
+
|
|
1896
|
+
parse_statements cls
|
|
1897
|
+
cls.comment = comment
|
|
1898
|
+
|
|
1899
|
+
when TkLSHFT
|
|
1900
|
+
case name = get_class_specification
|
|
1901
|
+
when "self", container.name
|
|
1902
|
+
parse_statements(container, SINGLE)
|
|
1903
|
+
else
|
|
1904
|
+
other = RDoc::TopLevel.find_class_named(name)
|
|
1905
|
+
unless other
|
|
1906
|
+
# other = @top_level.add_class(NormalClass, name, nil)
|
|
1907
|
+
# other.record_location(@top_level)
|
|
1908
|
+
# other.comment = comment
|
|
1909
|
+
other = RDoc::NormalClass.new "Dummy", nil
|
|
1910
|
+
end
|
|
1911
|
+
|
|
1912
|
+
@stats.add_class other
|
|
1913
|
+
|
|
1914
|
+
read_documentation_modifiers other, RDoc::CLASS_MODIFIERS
|
|
1915
|
+
parse_statements(other, SINGLE)
|
|
1916
|
+
end
|
|
1917
|
+
|
|
1918
|
+
else
|
|
1919
|
+
warn("Expected class name or '<<'. Got #{name_t.class}: #{name_t.text.inspect}")
|
|
1920
|
+
end
|
|
1921
|
+
end
|
|
1922
|
+
|
|
1923
|
+
def parse_constant(container, single, tk, comment)
|
|
1924
|
+
name = tk.name
|
|
1925
|
+
skip_tkspace(false)
|
|
1926
|
+
eq_tk = get_tk
|
|
1927
|
+
|
|
1928
|
+
unless TkASSIGN === eq_tk then
|
|
1929
|
+
unget_tk(eq_tk)
|
|
1930
|
+
return
|
|
1931
|
+
end
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
nest = 0
|
|
1935
|
+
get_tkread
|
|
1936
|
+
|
|
1937
|
+
tk = get_tk
|
|
1938
|
+
if TkGT === tk then
|
|
1939
|
+
unget_tk(tk)
|
|
1940
|
+
unget_tk(eq_tk)
|
|
1941
|
+
return
|
|
1942
|
+
end
|
|
1943
|
+
|
|
1944
|
+
loop do
|
|
1945
|
+
case tk
|
|
1946
|
+
when TkSEMICOLON
|
|
1947
|
+
break
|
|
1948
|
+
when TkLPAREN, TkfLPAREN, TkLBRACE, TkLBRACK, TkDO
|
|
1949
|
+
nest += 1
|
|
1950
|
+
when TkRPAREN, TkRBRACE, TkRBRACK, TkEND
|
|
1951
|
+
nest -= 1
|
|
1952
|
+
when TkCOMMENT
|
|
1953
|
+
if nest <= 0 && @scanner.lex_state == EXPR_END
|
|
1954
|
+
unget_tk(tk)
|
|
1955
|
+
break
|
|
1956
|
+
end
|
|
1957
|
+
when TkNL
|
|
1958
|
+
if (nest <= 0) && ((@scanner.lex_state == EXPR_END) || (!@scanner.continue))
|
|
1959
|
+
unget_tk(tk)
|
|
1960
|
+
break
|
|
1961
|
+
end
|
|
1962
|
+
end
|
|
1963
|
+
tk = get_tk
|
|
1964
|
+
end
|
|
1965
|
+
|
|
1966
|
+
res = get_tkread.tr("\n", " ").strip
|
|
1967
|
+
res = "" if res == ";"
|
|
1968
|
+
|
|
1969
|
+
con = RDoc::Constant.new name, res, comment
|
|
1970
|
+
read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS
|
|
1971
|
+
|
|
1972
|
+
if con.document_self
|
|
1973
|
+
container.add_constant(con)
|
|
1974
|
+
end
|
|
1975
|
+
end
|
|
1976
|
+
|
|
1977
|
+
def parse_comment(container, tk, comment)
|
|
1978
|
+
line_no = tk.line_no
|
|
1979
|
+
column = tk.char_no
|
|
1980
|
+
|
|
1981
|
+
singleton = !!comment.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3')
|
|
1982
|
+
|
|
1983
|
+
if comment.sub!(/^# +:?method: *(\S*).*?\n/i, '') then
|
|
1984
|
+
name = $1 unless $1.empty?
|
|
1985
|
+
else
|
|
1986
|
+
return nil
|
|
1987
|
+
end
|
|
1988
|
+
|
|
1989
|
+
meth = RDoc::GhostMethod.new get_tkread, name
|
|
1990
|
+
meth.singleton = singleton
|
|
1991
|
+
|
|
1992
|
+
@stats.add_method meth
|
|
1993
|
+
|
|
1994
|
+
meth.start_collecting_tokens
|
|
1995
|
+
indent = TkSPACE.new 1, 1
|
|
1996
|
+
indent.set_text " " * column
|
|
1997
|
+
|
|
1998
|
+
position_comment = TkCOMMENT.new(line_no, 1, "# File #{@top_level.file_absolute_name}, line #{line_no}")
|
|
1999
|
+
meth.add_tokens [position_comment, NEWLINE_TOKEN, indent]
|
|
2000
|
+
|
|
2001
|
+
meth.params = ''
|
|
2002
|
+
|
|
2003
|
+
extract_call_seq comment, meth
|
|
2004
|
+
|
|
2005
|
+
container.add_method meth if meth.document_self
|
|
2006
|
+
|
|
2007
|
+
meth.comment = comment
|
|
2008
|
+
end
|
|
2009
|
+
|
|
2010
|
+
def parse_include(context, comment)
|
|
2011
|
+
loop do
|
|
2012
|
+
skip_tkspace_comment
|
|
2013
|
+
|
|
2014
|
+
name = get_constant_with_optional_parens
|
|
2015
|
+
context.add_include RDoc::Include.new(name, comment) unless name.empty?
|
|
2016
|
+
|
|
2017
|
+
return unless TkCOMMA === peek_tk
|
|
2018
|
+
get_tk
|
|
2019
|
+
end
|
|
2020
|
+
end
|
|
2021
|
+
|
|
2022
|
+
##
|
|
2023
|
+
# Parses a meta-programmed method
|
|
2024
|
+
|
|
2025
|
+
def parse_meta_method(container, single, tk, comment)
|
|
2026
|
+
line_no = tk.line_no
|
|
2027
|
+
column = tk.char_no
|
|
2028
|
+
|
|
2029
|
+
start_collecting_tokens
|
|
2030
|
+
add_token tk
|
|
2031
|
+
add_token_listener self
|
|
2032
|
+
|
|
2033
|
+
skip_tkspace false
|
|
2034
|
+
|
|
2035
|
+
singleton = !!comment.sub!(/(^# +:?)(singleton-)(method:)/, '\1\3')
|
|
2036
|
+
|
|
2037
|
+
if comment.sub!(/^# +:?method: *(\S*).*?\n/i, '') then
|
|
2038
|
+
name = $1 unless $1.empty?
|
|
2039
|
+
end
|
|
2040
|
+
|
|
2041
|
+
if name.nil? then
|
|
2042
|
+
name_t = get_tk
|
|
2043
|
+
case name_t
|
|
2044
|
+
when TkSYMBOL then
|
|
2045
|
+
name = name_t.text[1..-1]
|
|
2046
|
+
when TkSTRING then
|
|
2047
|
+
name = name_t.text[1..-2]
|
|
2048
|
+
else
|
|
2049
|
+
warn "#{container.top_level.file_relative_name}:#{name_t.line_no} unknown name token #{name_t.inspect} for meta-method"
|
|
2050
|
+
name = 'unknown'
|
|
2051
|
+
end
|
|
2052
|
+
end
|
|
2053
|
+
|
|
2054
|
+
meth = RDoc::MetaMethod.new get_tkread, name
|
|
2055
|
+
meth.singleton = singleton
|
|
2056
|
+
|
|
2057
|
+
@stats.add_method meth
|
|
2058
|
+
|
|
2059
|
+
remove_token_listener self
|
|
2060
|
+
|
|
2061
|
+
meth.start_collecting_tokens
|
|
2062
|
+
indent = TkSPACE.new 1, 1
|
|
2063
|
+
indent.set_text " " * column
|
|
2064
|
+
|
|
2065
|
+
position_comment = TkCOMMENT.new(line_no, 1, "# File #{@top_level.file_absolute_name}, line #{line_no}")
|
|
2066
|
+
meth.add_tokens [position_comment, NEWLINE_TOKEN, indent]
|
|
2067
|
+
meth.add_tokens @token_stream
|
|
2068
|
+
|
|
2069
|
+
add_token_listener meth
|
|
2070
|
+
|
|
2071
|
+
meth.params = ''
|
|
2072
|
+
|
|
2073
|
+
extract_call_seq comment, meth
|
|
2074
|
+
|
|
2075
|
+
container.add_method meth if meth.document_self
|
|
2076
|
+
|
|
2077
|
+
last_tk = tk
|
|
2078
|
+
|
|
2079
|
+
while tk = get_tk do
|
|
2080
|
+
case tk
|
|
2081
|
+
when TkSEMICOLON then
|
|
2082
|
+
break
|
|
2083
|
+
when TkNL then
|
|
2084
|
+
break unless last_tk and TkCOMMA === last_tk
|
|
2085
|
+
when TkSPACE then
|
|
2086
|
+
# expression continues
|
|
2087
|
+
else
|
|
2088
|
+
last_tk = tk
|
|
2089
|
+
end
|
|
2090
|
+
end
|
|
2091
|
+
|
|
2092
|
+
remove_token_listener meth
|
|
2093
|
+
|
|
2094
|
+
meth.comment = comment
|
|
2095
|
+
end
|
|
2096
|
+
|
|
2097
|
+
##
|
|
2098
|
+
# Parses a method
|
|
2099
|
+
|
|
2100
|
+
def parse_method(container, single, tk, comment)
|
|
2101
|
+
line_no = tk.line_no
|
|
2102
|
+
column = tk.char_no
|
|
2103
|
+
|
|
2104
|
+
start_collecting_tokens
|
|
2105
|
+
add_token(tk)
|
|
2106
|
+
add_token_listener(self)
|
|
2107
|
+
|
|
2108
|
+
@scanner.instance_eval do @lex_state = EXPR_FNAME end
|
|
2109
|
+
|
|
2110
|
+
skip_tkspace(false)
|
|
2111
|
+
name_t = get_tk
|
|
2112
|
+
back_tk = skip_tkspace
|
|
2113
|
+
meth = nil
|
|
2114
|
+
added_container = false
|
|
2115
|
+
|
|
2116
|
+
dot = get_tk
|
|
2117
|
+
if TkDOT === dot or TkCOLON2 === dot then
|
|
2118
|
+
@scanner.instance_eval do @lex_state = EXPR_FNAME end
|
|
2119
|
+
skip_tkspace
|
|
2120
|
+
name_t2 = get_tk
|
|
2121
|
+
|
|
2122
|
+
case name_t
|
|
2123
|
+
when TkSELF then
|
|
2124
|
+
name = name_t2.name
|
|
2125
|
+
when TkCONSTANT then
|
|
2126
|
+
name = name_t2.name
|
|
2127
|
+
prev_container = container
|
|
2128
|
+
container = container.find_module_named(name_t.name)
|
|
2129
|
+
unless container then
|
|
2130
|
+
added_container = true
|
|
2131
|
+
obj = name_t.name.split("::").inject(Object) do |state, item|
|
|
2132
|
+
state.const_get(item)
|
|
2133
|
+
end rescue nil
|
|
2134
|
+
|
|
2135
|
+
type = obj.class == Class ? RDoc::NormalClass : RDoc::NormalModule
|
|
2136
|
+
|
|
2137
|
+
unless [Class, Module].include?(obj.class) then
|
|
2138
|
+
warn("Couldn't find #{name_t.name}. Assuming it's a module")
|
|
2139
|
+
end
|
|
2140
|
+
|
|
2141
|
+
if type == RDoc::NormalClass then
|
|
2142
|
+
container = prev_container.add_class(type, name_t.name, obj.superclass.name)
|
|
2143
|
+
else
|
|
2144
|
+
container = prev_container.add_module(type, name_t.name)
|
|
2145
|
+
end
|
|
2146
|
+
|
|
2147
|
+
container.record_location @top_level
|
|
2148
|
+
end
|
|
2149
|
+
else
|
|
2150
|
+
# warn("Unexpected token '#{name_t2.inspect}'")
|
|
2151
|
+
# break
|
|
2152
|
+
skip_method(container)
|
|
2153
|
+
return
|
|
2154
|
+
end
|
|
2155
|
+
|
|
2156
|
+
meth = RDoc::AnyMethod.new(get_tkread, name)
|
|
2157
|
+
meth.singleton = true
|
|
2158
|
+
else
|
|
2159
|
+
unget_tk dot
|
|
2160
|
+
back_tk.reverse_each do |token|
|
|
2161
|
+
unget_tk token
|
|
2162
|
+
end
|
|
2163
|
+
name = name_t.name
|
|
2164
|
+
|
|
2165
|
+
meth = RDoc::AnyMethod.new get_tkread, name
|
|
2166
|
+
meth.singleton = (single == SINGLE)
|
|
2167
|
+
end
|
|
2168
|
+
|
|
2169
|
+
@stats.add_method meth
|
|
2170
|
+
|
|
2171
|
+
remove_token_listener self
|
|
2172
|
+
|
|
2173
|
+
meth.start_collecting_tokens
|
|
2174
|
+
indent = TkSPACE.new 1, 1
|
|
2175
|
+
indent.set_text " " * column
|
|
2176
|
+
|
|
2177
|
+
token = TkCOMMENT.new(line_no, 1, "# File #{@top_level.file_absolute_name}, line #{line_no}")
|
|
2178
|
+
meth.add_tokens [token, NEWLINE_TOKEN, indent]
|
|
2179
|
+
meth.add_tokens @token_stream
|
|
2180
|
+
|
|
2181
|
+
add_token_listener meth
|
|
2182
|
+
|
|
2183
|
+
@scanner.instance_eval do @continue = false end
|
|
2184
|
+
parse_method_parameters meth
|
|
2185
|
+
|
|
2186
|
+
if meth.document_self then
|
|
2187
|
+
container.add_method meth
|
|
2188
|
+
elsif added_container then
|
|
2189
|
+
container.document_self = false
|
|
2190
|
+
end
|
|
2191
|
+
|
|
2192
|
+
# Having now read the method parameters and documentation modifiers, we
|
|
2193
|
+
# now know whether we have to rename #initialize to ::new
|
|
2194
|
+
|
|
2195
|
+
if name == "initialize" && !meth.singleton then
|
|
2196
|
+
if meth.dont_rename_initialize then
|
|
2197
|
+
meth.visibility = :protected
|
|
2198
|
+
else
|
|
2199
|
+
meth.singleton = true
|
|
2200
|
+
meth.name = "new"
|
|
2201
|
+
meth.visibility = :public
|
|
2202
|
+
end
|
|
2203
|
+
end
|
|
2204
|
+
|
|
2205
|
+
parse_statements(container, single, meth)
|
|
2206
|
+
|
|
2207
|
+
remove_token_listener(meth)
|
|
2208
|
+
|
|
2209
|
+
extract_call_seq comment, meth
|
|
2210
|
+
|
|
2211
|
+
meth.comment = comment
|
|
2212
|
+
end
|
|
2213
|
+
|
|
2214
|
+
def parse_method_or_yield_parameters(method = nil,
|
|
2215
|
+
modifiers = RDoc::METHOD_MODIFIERS)
|
|
2216
|
+
skip_tkspace(false)
|
|
2217
|
+
tk = get_tk
|
|
2218
|
+
|
|
2219
|
+
# Little hack going on here. In the statement
|
|
2220
|
+
# f = 2*(1+yield)
|
|
2221
|
+
# We see the RPAREN as the next token, so we need
|
|
2222
|
+
# to exit early. This still won't catch all cases
|
|
2223
|
+
# (such as "a = yield + 1"
|
|
2224
|
+
end_token = case tk
|
|
2225
|
+
when TkLPAREN, TkfLPAREN
|
|
2226
|
+
TkRPAREN
|
|
2227
|
+
when TkRPAREN
|
|
2228
|
+
return ""
|
|
2229
|
+
else
|
|
2230
|
+
TkNL
|
|
2231
|
+
end
|
|
2232
|
+
nest = 0
|
|
2233
|
+
|
|
2234
|
+
loop do
|
|
2235
|
+
case tk
|
|
2236
|
+
when TkSEMICOLON
|
|
2237
|
+
break
|
|
2238
|
+
when TkLBRACE
|
|
2239
|
+
nest += 1
|
|
2240
|
+
when TkRBRACE
|
|
2241
|
+
# we might have a.each {|i| yield i }
|
|
2242
|
+
unget_tk(tk) if nest.zero?
|
|
2243
|
+
nest -= 1
|
|
2244
|
+
break if nest <= 0
|
|
2245
|
+
when TkLPAREN, TkfLPAREN
|
|
2246
|
+
nest += 1
|
|
2247
|
+
when end_token
|
|
2248
|
+
if end_token == TkRPAREN
|
|
2249
|
+
nest -= 1
|
|
2250
|
+
break if @scanner.lex_state == EXPR_END and nest <= 0
|
|
2251
|
+
else
|
|
2252
|
+
break unless @scanner.continue
|
|
2253
|
+
end
|
|
2254
|
+
when method && method.block_params.nil? && TkCOMMENT
|
|
2255
|
+
unget_tk(tk)
|
|
2256
|
+
read_documentation_modifiers(method, modifiers)
|
|
2257
|
+
end
|
|
2258
|
+
tk = get_tk
|
|
2259
|
+
end
|
|
2260
|
+
res = get_tkread.tr("\n", " ").strip
|
|
2261
|
+
res = "" if res == ";"
|
|
2262
|
+
res
|
|
2263
|
+
end
|
|
2264
|
+
|
|
2265
|
+
##
|
|
2266
|
+
# Capture the method's parameters. Along the way, look for a comment
|
|
2267
|
+
# containing:
|
|
2268
|
+
#
|
|
2269
|
+
# # yields: ....
|
|
2270
|
+
#
|
|
2271
|
+
# and add this as the block_params for the method
|
|
2272
|
+
|
|
2273
|
+
def parse_method_parameters(method)
|
|
2274
|
+
res = parse_method_or_yield_parameters(method)
|
|
2275
|
+
res = "(" + res + ")" unless res[0] == ?(
|
|
2276
|
+
method.params = res unless method.params
|
|
2277
|
+
if method.block_params.nil?
|
|
2278
|
+
skip_tkspace(false)
|
|
2279
|
+
read_documentation_modifiers method, RDoc::METHOD_MODIFIERS
|
|
2280
|
+
end
|
|
2281
|
+
end
|
|
2282
|
+
|
|
2283
|
+
def parse_module(container, single, tk, comment)
|
|
2284
|
+
container, name_t = get_class_or_module(container)
|
|
2285
|
+
|
|
2286
|
+
name = name_t.name
|
|
2287
|
+
|
|
2288
|
+
mod = container.add_module RDoc::NormalModule, name
|
|
2289
|
+
mod.record_location @top_level
|
|
2290
|
+
|
|
2291
|
+
@stats.add_module mod
|
|
2292
|
+
|
|
2293
|
+
read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
|
|
2294
|
+
parse_statements(mod)
|
|
2295
|
+
mod.comment = comment
|
|
2296
|
+
end
|
|
2297
|
+
|
|
2298
|
+
def parse_require(context, comment)
|
|
2299
|
+
skip_tkspace_comment
|
|
2300
|
+
tk = get_tk
|
|
2301
|
+
if TkLPAREN === tk then
|
|
2302
|
+
skip_tkspace_comment
|
|
2303
|
+
tk = get_tk
|
|
2304
|
+
end
|
|
2305
|
+
|
|
2306
|
+
name = nil
|
|
2307
|
+
case tk
|
|
2308
|
+
when TkSTRING
|
|
2309
|
+
name = tk.text
|
|
2310
|
+
# when TkCONSTANT, TkIDENTIFIER, TkIVAR, TkGVAR
|
|
2311
|
+
# name = tk.name
|
|
2312
|
+
when TkDSTRING
|
|
2313
|
+
warn "Skipping require of dynamic string: #{tk.text}"
|
|
2314
|
+
# else
|
|
2315
|
+
# warn "'require' used as variable"
|
|
2316
|
+
end
|
|
2317
|
+
if name
|
|
2318
|
+
context.add_require RDoc::Require.new(name, comment)
|
|
2319
|
+
else
|
|
2320
|
+
unget_tk(tk)
|
|
2321
|
+
end
|
|
2322
|
+
end
|
|
2323
|
+
|
|
2324
|
+
def parse_statements(container, single = NORMAL, current_method = nil,
|
|
2325
|
+
comment = '')
|
|
2326
|
+
nest = 1
|
|
2327
|
+
save_visibility = container.visibility
|
|
2328
|
+
|
|
2329
|
+
non_comment_seen = true
|
|
2330
|
+
|
|
2331
|
+
while tk = get_tk do
|
|
2332
|
+
keep_comment = false
|
|
2333
|
+
|
|
2334
|
+
non_comment_seen = true unless TkCOMMENT === tk
|
|
2335
|
+
|
|
2336
|
+
case tk
|
|
2337
|
+
when TkNL then
|
|
2338
|
+
skip_tkspace true # Skip blanks and newlines
|
|
2339
|
+
tk = get_tk
|
|
2340
|
+
|
|
2341
|
+
if TkCOMMENT === tk then
|
|
2342
|
+
if non_comment_seen then
|
|
2343
|
+
# Look for RDoc in a comment about to be thrown away
|
|
2344
|
+
parse_comment container, tk, comment unless comment.empty?
|
|
2345
|
+
|
|
2346
|
+
comment = ''
|
|
2347
|
+
non_comment_seen = false
|
|
2348
|
+
end
|
|
2349
|
+
|
|
2350
|
+
while TkCOMMENT === tk do
|
|
2351
|
+
comment << tk.text << "\n"
|
|
2352
|
+
tk = get_tk # this is the newline
|
|
2353
|
+
skip_tkspace(false) # leading spaces
|
|
2354
|
+
tk = get_tk
|
|
2355
|
+
end
|
|
2356
|
+
|
|
2357
|
+
unless comment.empty? then
|
|
2358
|
+
look_for_directives_in container, comment
|
|
2359
|
+
|
|
2360
|
+
if container.done_documenting then
|
|
2361
|
+
container.ongoing_visibility = save_visibility
|
|
2362
|
+
end
|
|
2363
|
+
end
|
|
2364
|
+
|
|
2365
|
+
keep_comment = true
|
|
2366
|
+
else
|
|
2367
|
+
non_comment_seen = true
|
|
2368
|
+
end
|
|
2369
|
+
|
|
2370
|
+
unget_tk tk
|
|
2371
|
+
keep_comment = true
|
|
2372
|
+
|
|
2373
|
+
when TkCLASS then
|
|
2374
|
+
if container.document_children then
|
|
2375
|
+
parse_class container, single, tk, comment
|
|
2376
|
+
else
|
|
2377
|
+
nest += 1
|
|
2378
|
+
end
|
|
2379
|
+
|
|
2380
|
+
when TkMODULE then
|
|
2381
|
+
if container.document_children then
|
|
2382
|
+
parse_module container, single, tk, comment
|
|
2383
|
+
else
|
|
2384
|
+
nest += 1
|
|
2385
|
+
end
|
|
2386
|
+
|
|
2387
|
+
when TkDEF then
|
|
2388
|
+
if container.document_self then
|
|
2389
|
+
parse_method container, single, tk, comment
|
|
2390
|
+
else
|
|
2391
|
+
nest += 1
|
|
2392
|
+
end
|
|
2393
|
+
|
|
2394
|
+
when TkCONSTANT then
|
|
2395
|
+
if container.document_self then
|
|
2396
|
+
parse_constant container, single, tk, comment
|
|
2397
|
+
end
|
|
2398
|
+
|
|
2399
|
+
when TkALIAS then
|
|
2400
|
+
if container.document_self then
|
|
2401
|
+
parse_alias container, single, tk, comment
|
|
2402
|
+
end
|
|
2403
|
+
|
|
2404
|
+
when TkYIELD then
|
|
2405
|
+
if current_method.nil? then
|
|
2406
|
+
warn "Warning: yield outside of method" if container.document_self
|
|
2407
|
+
else
|
|
2408
|
+
parse_yield container, single, tk, current_method
|
|
2409
|
+
end
|
|
2410
|
+
|
|
2411
|
+
# Until and While can have a 'do', which shouldn't increase the nesting.
|
|
2412
|
+
# We can't solve the general case, but we can handle most occurrences by
|
|
2413
|
+
# ignoring a do at the end of a line.
|
|
2414
|
+
|
|
2415
|
+
when TkUNTIL, TkWHILE then
|
|
2416
|
+
nest += 1
|
|
2417
|
+
skip_optional_do_after_expression
|
|
2418
|
+
|
|
2419
|
+
# 'for' is trickier
|
|
2420
|
+
when TkFOR then
|
|
2421
|
+
nest += 1
|
|
2422
|
+
skip_for_variable
|
|
2423
|
+
skip_optional_do_after_expression
|
|
2424
|
+
|
|
2425
|
+
when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN then
|
|
2426
|
+
nest += 1
|
|
2427
|
+
|
|
2428
|
+
when TkIDENTIFIER then
|
|
2429
|
+
if nest == 1 and current_method.nil? then
|
|
2430
|
+
case tk.name
|
|
2431
|
+
when 'private', 'protected', 'public', 'private_class_method',
|
|
2432
|
+
'public_class_method', 'module_function' then
|
|
2433
|
+
parse_visibility container, single, tk
|
|
2434
|
+
keep_comment = true
|
|
2435
|
+
when 'attr' then
|
|
2436
|
+
parse_attr container, single, tk, comment
|
|
2437
|
+
when /^attr_(reader|writer|accessor)$/, @options.extra_accessors then
|
|
2438
|
+
parse_attr_accessor container, single, tk, comment
|
|
2439
|
+
when 'alias_method' then
|
|
2440
|
+
if container.document_self then
|
|
2441
|
+
parse_alias container, single, tk, comment
|
|
2442
|
+
end
|
|
2443
|
+
else
|
|
2444
|
+
if container.document_self and comment =~ /\A#\#$/ then
|
|
2445
|
+
parse_meta_method container, single, tk, comment
|
|
2446
|
+
end
|
|
2447
|
+
end
|
|
2448
|
+
end
|
|
2449
|
+
|
|
2450
|
+
case tk.name
|
|
2451
|
+
when "require" then
|
|
2452
|
+
parse_require container, comment
|
|
2453
|
+
when "include" then
|
|
2454
|
+
parse_include container, comment
|
|
2455
|
+
end
|
|
2456
|
+
|
|
2457
|
+
when TkEND then
|
|
2458
|
+
nest -= 1
|
|
2459
|
+
if nest == 0 then
|
|
2460
|
+
read_documentation_modifiers container, RDoc::CLASS_MODIFIERS
|
|
2461
|
+
container.ongoing_visibility = save_visibility
|
|
2462
|
+
return
|
|
2463
|
+
end
|
|
2464
|
+
|
|
2465
|
+
end
|
|
2466
|
+
|
|
2467
|
+
comment = '' unless keep_comment
|
|
2468
|
+
|
|
2469
|
+
begin
|
|
2470
|
+
get_tkread
|
|
2471
|
+
skip_tkspace(false)
|
|
2472
|
+
end while peek_tk == TkNL
|
|
2473
|
+
end
|
|
2474
|
+
end
|
|
2475
|
+
|
|
2476
|
+
def parse_symbol_arg(no = nil)
|
|
2477
|
+
args = []
|
|
2478
|
+
skip_tkspace_comment
|
|
2479
|
+
case tk = get_tk
|
|
2480
|
+
when TkLPAREN
|
|
2481
|
+
loop do
|
|
2482
|
+
skip_tkspace_comment
|
|
2483
|
+
if tk1 = parse_symbol_in_arg
|
|
2484
|
+
args.push tk1
|
|
2485
|
+
break if no and args.size >= no
|
|
2486
|
+
end
|
|
2487
|
+
|
|
2488
|
+
skip_tkspace_comment
|
|
2489
|
+
case tk2 = get_tk
|
|
2490
|
+
when TkRPAREN
|
|
2491
|
+
break
|
|
2492
|
+
when TkCOMMA
|
|
2493
|
+
else
|
|
2494
|
+
warn("unexpected token: '#{tk2.inspect}'") if $DEBUG_RDOC
|
|
2495
|
+
break
|
|
2496
|
+
end
|
|
2497
|
+
end
|
|
2498
|
+
else
|
|
2499
|
+
unget_tk tk
|
|
2500
|
+
if tk = parse_symbol_in_arg
|
|
2501
|
+
args.push tk
|
|
2502
|
+
return args if no and args.size >= no
|
|
2503
|
+
end
|
|
2504
|
+
|
|
2505
|
+
loop do
|
|
2506
|
+
skip_tkspace(false)
|
|
2507
|
+
|
|
2508
|
+
tk1 = get_tk
|
|
2509
|
+
unless TkCOMMA === tk1 then
|
|
2510
|
+
unget_tk tk1
|
|
2511
|
+
break
|
|
2512
|
+
end
|
|
2513
|
+
|
|
2514
|
+
skip_tkspace_comment
|
|
2515
|
+
if tk = parse_symbol_in_arg
|
|
2516
|
+
args.push tk
|
|
2517
|
+
break if no and args.size >= no
|
|
2518
|
+
end
|
|
2519
|
+
end
|
|
2520
|
+
end
|
|
2521
|
+
args
|
|
2522
|
+
end
|
|
2523
|
+
|
|
2524
|
+
def parse_symbol_in_arg
|
|
2525
|
+
case tk = get_tk
|
|
2526
|
+
when TkSYMBOL
|
|
2527
|
+
tk.text.sub(/^:/, '')
|
|
2528
|
+
when TkSTRING
|
|
2529
|
+
eval @read[-1]
|
|
2530
|
+
else
|
|
2531
|
+
warn("Expected symbol or string, got #{tk.inspect}") if $DEBUG_RDOC
|
|
2532
|
+
nil
|
|
2533
|
+
end
|
|
2534
|
+
end
|
|
2535
|
+
|
|
2536
|
+
def parse_toplevel_statements(container)
|
|
2537
|
+
comment = collect_first_comment
|
|
2538
|
+
look_for_directives_in(container, comment)
|
|
2539
|
+
container.comment = comment unless comment.empty?
|
|
2540
|
+
parse_statements container, NORMAL, nil, comment
|
|
2541
|
+
end
|
|
2542
|
+
|
|
2543
|
+
def parse_visibility(container, single, tk)
|
|
2544
|
+
singleton = (single == SINGLE)
|
|
2545
|
+
|
|
2546
|
+
vis_type = tk.name
|
|
2547
|
+
|
|
2548
|
+
vis = case vis_type
|
|
2549
|
+
when 'private' then :private
|
|
2550
|
+
when 'protected' then :protected
|
|
2551
|
+
when 'public' then :public
|
|
2552
|
+
when 'private_class_method' then
|
|
2553
|
+
singleton = true
|
|
2554
|
+
:private
|
|
2555
|
+
when 'public_class_method' then
|
|
2556
|
+
singleton = true
|
|
2557
|
+
:public
|
|
2558
|
+
when 'module_function' then
|
|
2559
|
+
singleton = true
|
|
2560
|
+
:public
|
|
2561
|
+
else
|
|
2562
|
+
raise "Invalid visibility: #{tk.name}"
|
|
2563
|
+
end
|
|
2564
|
+
|
|
2565
|
+
skip_tkspace_comment false
|
|
2566
|
+
|
|
2567
|
+
case peek_tk
|
|
2568
|
+
# Ryan Davis suggested the extension to ignore modifiers, because he
|
|
2569
|
+
# often writes
|
|
2570
|
+
#
|
|
2571
|
+
# protected unless $TESTING
|
|
2572
|
+
#
|
|
2573
|
+
when TkNL, TkUNLESS_MOD, TkIF_MOD, TkSEMICOLON then
|
|
2574
|
+
container.ongoing_visibility = vis
|
|
2575
|
+
else
|
|
2576
|
+
if vis_type == 'module_function' then
|
|
2577
|
+
args = parse_symbol_arg
|
|
2578
|
+
container.set_visibility_for args, :private, false
|
|
2579
|
+
|
|
2580
|
+
module_functions = []
|
|
2581
|
+
|
|
2582
|
+
container.methods_matching args do |m|
|
|
2583
|
+
s_m = m.dup
|
|
2584
|
+
s_m.singleton = true if RDoc::AnyMethod === s_m
|
|
2585
|
+
s_m.visibility = :public
|
|
2586
|
+
module_functions << s_m
|
|
2587
|
+
end
|
|
2588
|
+
|
|
2589
|
+
module_functions.each do |s_m|
|
|
2590
|
+
case s_m
|
|
2591
|
+
when RDoc::AnyMethod then
|
|
2592
|
+
container.add_method s_m
|
|
2593
|
+
when RDoc::Attr then
|
|
2594
|
+
container.add_attribute s_m
|
|
2595
|
+
end
|
|
2596
|
+
end
|
|
2597
|
+
else
|
|
2598
|
+
args = parse_symbol_arg
|
|
2599
|
+
container.set_visibility_for args, vis, singleton
|
|
2600
|
+
end
|
|
2601
|
+
end
|
|
2602
|
+
end
|
|
2603
|
+
|
|
2604
|
+
def parse_yield_parameters
|
|
2605
|
+
parse_method_or_yield_parameters
|
|
2606
|
+
end
|
|
2607
|
+
|
|
2608
|
+
def parse_yield(context, single, tk, method)
|
|
2609
|
+
if method.block_params.nil?
|
|
2610
|
+
get_tkread
|
|
2611
|
+
@scanner.instance_eval{@continue = false}
|
|
2612
|
+
method.block_params = parse_yield_parameters
|
|
2613
|
+
end
|
|
2614
|
+
end
|
|
2615
|
+
|
|
2616
|
+
def peek_read
|
|
2617
|
+
@read.join('')
|
|
2618
|
+
end
|
|
2619
|
+
|
|
2620
|
+
##
|
|
2621
|
+
# Peek at the next token, but don't remove it from the stream
|
|
2622
|
+
|
|
2623
|
+
def peek_tk
|
|
2624
|
+
unget_tk(tk = get_tk)
|
|
2625
|
+
tk
|
|
2626
|
+
end
|
|
2627
|
+
|
|
2628
|
+
##
|
|
2629
|
+
# Directives are modifier comments that can appear after class, module, or
|
|
2630
|
+
# method names. For example:
|
|
2631
|
+
#
|
|
2632
|
+
# def fred # :yields: a, b
|
|
2633
|
+
#
|
|
2634
|
+
# or:
|
|
2635
|
+
#
|
|
2636
|
+
# class MyClass # :nodoc:
|
|
2637
|
+
#
|
|
2638
|
+
# We return the directive name and any parameters as a two element array
|
|
2639
|
+
|
|
2640
|
+
def read_directive(allowed)
|
|
2641
|
+
tk = get_tk
|
|
2642
|
+
result = nil
|
|
2643
|
+
if TkCOMMENT === tk
|
|
2644
|
+
if tk.text =~ /\s*:?(\w+):\s*(.*)/
|
|
2645
|
+
directive = $1.downcase
|
|
2646
|
+
if allowed.include?(directive)
|
|
2647
|
+
result = [directive, $2]
|
|
2648
|
+
end
|
|
2649
|
+
end
|
|
2650
|
+
else
|
|
2651
|
+
unget_tk(tk)
|
|
2652
|
+
end
|
|
2653
|
+
result
|
|
2654
|
+
end
|
|
2655
|
+
|
|
2656
|
+
def read_documentation_modifiers(context, allow)
|
|
2657
|
+
dir = read_directive(allow)
|
|
2658
|
+
|
|
2659
|
+
case dir[0]
|
|
2660
|
+
when "notnew", "not_new", "not-new" then
|
|
2661
|
+
context.dont_rename_initialize = true
|
|
2662
|
+
|
|
2663
|
+
when "nodoc" then
|
|
2664
|
+
context.document_self = false
|
|
2665
|
+
if dir[1].downcase == "all"
|
|
2666
|
+
context.document_children = false
|
|
2667
|
+
end
|
|
2668
|
+
|
|
2669
|
+
when "doc" then
|
|
2670
|
+
context.document_self = true
|
|
2671
|
+
context.force_documentation = true
|
|
2672
|
+
|
|
2673
|
+
when "yield", "yields" then
|
|
2674
|
+
unless context.params.nil?
|
|
2675
|
+
context.params.sub!(/(,|)\s*&\w+/,'') # remove parameter &proc
|
|
2676
|
+
end
|
|
2677
|
+
|
|
2678
|
+
context.block_params = dir[1]
|
|
2679
|
+
|
|
2680
|
+
when "arg", "args" then
|
|
2681
|
+
context.params = dir[1]
|
|
2682
|
+
end if dir
|
|
2683
|
+
end
|
|
2684
|
+
|
|
2685
|
+
def remove_private_comments(comment)
|
|
2686
|
+
comment.gsub!(/^#--\n.*?^#\+\+/m, '')
|
|
2687
|
+
comment.sub!(/^#--\n.*/m, '')
|
|
2688
|
+
end
|
|
2689
|
+
|
|
2690
|
+
def remove_token_listener(obj)
|
|
2691
|
+
@token_listeners.delete(obj)
|
|
2692
|
+
end
|
|
2693
|
+
|
|
2694
|
+
def reset
|
|
2695
|
+
@tokens = []
|
|
2696
|
+
@unget_read = []
|
|
2697
|
+
@read = []
|
|
2698
|
+
end
|
|
2699
|
+
|
|
2700
|
+
def scan
|
|
2701
|
+
reset
|
|
2702
|
+
|
|
2703
|
+
catch(:eof) do
|
|
2704
|
+
catch(:enddoc) do
|
|
2705
|
+
begin
|
|
2706
|
+
parse_toplevel_statements(@top_level)
|
|
2707
|
+
rescue Exception => e
|
|
2708
|
+
$stderr.puts <<-EOF
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
RDoc failure in #{@file_name} at or around line #{@scanner.line_no} column
|
|
2712
|
+
#{@scanner.char_no}
|
|
2713
|
+
|
|
2714
|
+
Before reporting this, could you check that the file you're documenting
|
|
2715
|
+
compiles cleanly--RDoc is not a full Ruby parser, and gets confused easily if
|
|
2716
|
+
fed invalid programs.
|
|
2717
|
+
|
|
2718
|
+
The internal error was:
|
|
2719
|
+
|
|
2720
|
+
EOF
|
|
2721
|
+
|
|
2722
|
+
e.set_backtrace(e.backtrace[0,4])
|
|
2723
|
+
raise
|
|
2724
|
+
end
|
|
2725
|
+
end
|
|
2726
|
+
end
|
|
2727
|
+
|
|
2728
|
+
@top_level
|
|
2729
|
+
end
|
|
2730
|
+
|
|
2731
|
+
##
|
|
2732
|
+
# while, until, and for have an optional do
|
|
2733
|
+
|
|
2734
|
+
def skip_optional_do_after_expression
|
|
2735
|
+
skip_tkspace(false)
|
|
2736
|
+
tk = get_tk
|
|
2737
|
+
case tk
|
|
2738
|
+
when TkLPAREN, TkfLPAREN
|
|
2739
|
+
end_token = TkRPAREN
|
|
2740
|
+
else
|
|
2741
|
+
end_token = TkNL
|
|
2742
|
+
end
|
|
2743
|
+
|
|
2744
|
+
nest = 0
|
|
2745
|
+
@scanner.instance_eval{@continue = false}
|
|
2746
|
+
|
|
2747
|
+
loop do
|
|
2748
|
+
case tk
|
|
2749
|
+
when TkSEMICOLON
|
|
2750
|
+
break
|
|
2751
|
+
when TkLPAREN, TkfLPAREN
|
|
2752
|
+
nest += 1
|
|
2753
|
+
when TkDO
|
|
2754
|
+
break if nest.zero?
|
|
2755
|
+
when end_token
|
|
2756
|
+
if end_token == TkRPAREN
|
|
2757
|
+
nest -= 1
|
|
2758
|
+
break if @scanner.lex_state == EXPR_END and nest.zero?
|
|
2759
|
+
else
|
|
2760
|
+
break unless @scanner.continue
|
|
2761
|
+
end
|
|
2762
|
+
end
|
|
2763
|
+
tk = get_tk
|
|
2764
|
+
end
|
|
2765
|
+
skip_tkspace(false)
|
|
2766
|
+
|
|
2767
|
+
get_tk if TkDO === peek_tk
|
|
2768
|
+
end
|
|
2769
|
+
|
|
2770
|
+
##
|
|
2771
|
+
# skip the var [in] part of a 'for' statement
|
|
2772
|
+
|
|
2773
|
+
def skip_for_variable
|
|
2774
|
+
skip_tkspace(false)
|
|
2775
|
+
tk = get_tk
|
|
2776
|
+
skip_tkspace(false)
|
|
2777
|
+
tk = get_tk
|
|
2778
|
+
unget_tk(tk) unless TkIN === tk
|
|
2779
|
+
end
|
|
2780
|
+
|
|
2781
|
+
def skip_method(container)
|
|
2782
|
+
meth = RDoc::AnyMethod.new "", "anon"
|
|
2783
|
+
parse_method_parameters(meth)
|
|
2784
|
+
parse_statements(container, false, meth)
|
|
2785
|
+
end
|
|
2786
|
+
|
|
2787
|
+
##
|
|
2788
|
+
# Skip spaces
|
|
2789
|
+
|
|
2790
|
+
def skip_tkspace(skip_nl = true)
|
|
2791
|
+
tokens = []
|
|
2792
|
+
|
|
2793
|
+
while TkSPACE === (tk = get_tk) or (skip_nl and TkNL === tk) do
|
|
2794
|
+
tokens.push tk
|
|
2795
|
+
end
|
|
2796
|
+
|
|
2797
|
+
unget_tk(tk)
|
|
2798
|
+
tokens
|
|
2799
|
+
end
|
|
2800
|
+
|
|
2801
|
+
##
|
|
2802
|
+
# Skip spaces until a comment is found
|
|
2803
|
+
|
|
2804
|
+
def skip_tkspace_comment(skip_nl = true)
|
|
2805
|
+
loop do
|
|
2806
|
+
skip_tkspace(skip_nl)
|
|
2807
|
+
return unless TkCOMMENT === peek_tk
|
|
2808
|
+
get_tk
|
|
2809
|
+
end
|
|
2810
|
+
end
|
|
2811
|
+
|
|
2812
|
+
def unget_tk(tk)
|
|
2813
|
+
@tokens.unshift tk
|
|
2814
|
+
@unget_read.unshift @read.pop
|
|
2815
|
+
|
|
2816
|
+
# Remove this token from any listeners
|
|
2817
|
+
@token_listeners.each do |obj|
|
|
2818
|
+
obj.pop_token
|
|
2819
|
+
end if @token_listeners
|
|
2820
|
+
end
|
|
2821
|
+
|
|
2822
|
+
def warn(msg)
|
|
2823
|
+
return if @options.quiet
|
|
2824
|
+
msg = make_message msg
|
|
2825
|
+
$stderr.puts msg
|
|
2826
|
+
end
|
|
2827
|
+
|
|
2828
|
+
end
|
|
2829
|
+
|