diff options
author | Yukihiro Matsumoto <[email protected]> | 1996-12-24 15:20:58 +0900 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2019-08-17 22:09:32 +0900 |
commit | 554b989ba1623b9f6a0b76f00824c83a23fbcbc1 (patch) | |
tree | 71f06227fe259bebaa5ca4bf05cc398184bced68 /parse.y | |
parent | fca49a8a69a0f6bb4feae74c6cd0e93d7fac8b36 (diff) |
version 0.99.4-961224v0_99_4_961224
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.99.4-961224.tar.gz
Tue Dec 24 15:20:58 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961224
* configure.in: charがunsignedかどうかもチェック
* regex.c (SIGN_EXTEND_CHAR): __CHAR_UNSIGNED__にも対応
* pack.c (pack_unpack): 明示的にsigned charを指定.
Mon Dec 23 14:41:23 1996 Yukihiro Matsumoto <[email protected]>
* ruby.c (load_file): 標準入力からのスクリプトで一時ファイルを使わ
ないように
* object.c (f_integer): `0x', `0'などでbaseを解釈するように.
Fri Dec 20 01:44:39 1996 Yukihiro Matsumoto <[email protected]>
* Makefile.in (flock.o): flockに対応
Thu Dec 19 20:13:32 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961219
Wed Dec 18 00:06:48 1996 Yukihiro Matsumoto <[email protected]>
* glob.c (glob_filename): strrchrがマクロの場合に対応
* configure.in: <sys/select.h>をチェック
* ext/kconv/kconv.c: 1.62ベースに
* ext/kconv/kconv.c: Kconvモジュール
* string.c (str_substr): lenが元の文字列より長い時に対応
* parse.y (iterator): 「$bar do .. end」などは許さないように
* parse.y (iterator): FID(foo!,foo?)をdo形式のイテレータにできる.
* missing/flock.c (flock): lockf()を使って代替
* file.c (file_flock): flockを実装
Tue Dec 17 12:13:38 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961217
Fri Dec 13 02:05:03 1996 Yukihiro Matsumoto <[email protected]>
* configure.in: RUBYLIBのカレントを後回し(@mix/awk offline)
* dln.c: AIXに対応した?(@mix/awk offline)
* eval.c (thread_schedule): critical sectionでも明示的なコンテキス
トスイッチは起きないとまずい
* re.c (reg_search): matchに失敗した時に$~をnilに.
* re.c (reg_search): 毎回matchを生成するように
Thu Dec 12 17:03:30 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (flo_to_s): 2.0.to_s -> 2.0に
* eval.c (thread_save_context): $_, $~をthread毎に保存
* eval.c (thread_kill): main threadではexit(0)
* string.c (str_split_method): 間違った結果を返していた
Thu Dec 12 15:32:48 1996 WATANABE Hirofumi <[email protected]>
* dir.c: CYGWIN32対応
* ext/socket/socket.c: CYGWIN32対応
* io.c: CYGWIN32対応
Thu Dec 12 14:43:51 1996 Jun Kuroda <[email protected]>
* lib/tk.rb: wish4.2も探索候補に含める
* config.guess: JCC対応
Thu Dec 12 00:41:17 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961212
* parse.y (parse_string): """..."""はやはり無くすことにした
* parse.y (parse_regx): %r|...|でterminatorを \ でエスケープできる
ように
* signal.c (posix_signal): sigactionを使うsignal
* configure.in: posix signal/bsd signalの検出
Wed Dec 11 17:47:35 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): critical sectionではコンテキストスイッ
チが起きないように
* lib/thread.rb: SharedMutexクラス
* lib/jcode.rb: String#scanを使うように
Tue Dec 10 12:21:28 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961210
* string.c (str_split_method): 正規表現に()を含む時にバグ
* lib/jcode.rb: ちょっとましになった
* string.c (tr_setup_table): 置換文字が短すぎる(2文字)のときのバグ
Mon Dec 9 11:38:04 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_scan): 文字列のマッチを行う.イテレータとしても動
作する
* regex.c (re_copy_registers): allocatedが初期化されていなかった
* re.c (match_to_s): $~の文字列化
* re.c (match_to_a): $~を配列化できるように
* re.c (match_getter): レジスタが初期化されていなかった
Thu Dec 5 11:06:10 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_split_method): マッチしなかった括弧は空文字列を
pushするべきではない
* string.c (str_succ): アルファベットを含まない文字に対応
Wed Dec 4 10:48:09 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961204
* io.c (io_binmode): DJGPPでのbinmode対応
* sprintf.c (f_sprintf): intの範囲の数値は直接sprintfで変換する
* sprintf.c (f_sprintf): "%02s"に頼らない
* re.c (reg_search): indexでSEGV
Tue Dec 3 10:09:36 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961203
* ext/extmk.rb.in (install): INSTALL_DATAからINSTALLに変更
* dln.c: hpux対応
* string.c (str_aset_method): 負の値を含む範囲でも例外を起こさない
* array.c (ary_replace): 負の値を含む範囲でも例外を起こさない
* array.c (beg_len): beg==endの時,長さ0に
Mon Dec 2 14:07:12 1996 Yukihiro Matsumoto <[email protected]>
* configure.in: HP shl対応
* string.c (str_upto): beg > endの時無限ループに落ちるのを止めた
* range.c (range_each): String#uptoが再定義された場合に対応
* string.c (str_split_method): "ABC".split(/(B)/)が誤動作
Sat Nov 30 01:43:52 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): undefでSEGV
Fri Nov 29 12:17:59 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): %Q#..#などに対応.しか
し,区切り文字が演算子で行末にある場合には対応できなかった.
* re.c (reg_raise): 例外でもスラッシュをエスケープ
* re.c (reg_inspect): スラッシュをエスケープ
* parse.y (parse_string): `%[QqXxRr](.)..\1'なる文字列形式(テスト
採用)
* parse.y (parse_qstring): '''...'''の形式
* ext/dbm/dbm.c (Init_dbm): 述語key?,value?の追加
* ext/dbm/dbm.c (Init_dbm): includes->include?
* hash.c (Init_Hash): 述語key?,value?,include?の追加
* eval.c (rb_eval): else節が実行されない(うーん)
* string.c (str_sub_iter_s): イテレータブロック内でマッチが行われ
ると位置がずれる(時に無限ループに落ちる)
* string.c (str_resize): lenが0の時sizeの調整が行われなかった
Thu Nov 28 00:59:54 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961128
* parse.y (parse_string): 3-quote styleの文字列(例:"""abc"d"e""")
* configure.in (EXTSTATIC): extを静的にリンクする時にはrubyはdllを
使うように
* io.c (Init_IO): getsの引数が間違っていた
* string.c (str_each_line): RSを明示的に指定できるように
Wed Nov 27 12:37:46 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961127
* eval.c (rb_eval): iver defined? でselfを指定するのを忘れた
* io.c: gets等でRSを明示的に指定できるように
* ext/extmk.rb.in (install): static linkに失敗
Tue Nov 26 10:33:04 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961126
* string.c (str_sub_s): 置換後の文字列長さが間違っていた
Mon Nov 25 09:11:22 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (fix_rshift): 32以上の右シフトで0を返すように(Cの
rshiftは(x>>(y%32))を返していた).
* string.c (str_gsub): 置換が行われない場合があった
* string.c (str_resize): 本当に必要な時だけrealloc
Thu Nov 21 04:13:21 1996 Yukihiro Matsumoto <[email protected]>
* configure.in (EXTSTATIC): --with-static-linked-extで全てのモジュー
ルを静的リンクするように
* pack.c (pack_unpack): 行末の改行がない時にもチェックサムをスキッ
プするように
Wed Nov 20 96 21:42:51 1996 Yasuo OHBA <[email protected]>
* configure.in: freebsd対応
Wed Nov 20 10:24:24 1996 Yukihiro Matsumoto <[email protected]>
* ext/extmk.rb.in (install): 通常リンク用のLDFLAGSとダイナミックリ
ンク用のDLDFALGSを分離
* ext/extmk.rb.in (install): コンパイルの成功したものを静的リンク
のリストに追加する
* eval.c (f_missing): オブジェクトの文字列表現が長すぎる時バッファ
を書き潰していた
* process.c (proc_exec_v): forkした後例外を発生させてはいけない
Tue Nov 19 13:28:15 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961119
* eval.c (mod_method_defined): Module#method_defined? の追加
* parse.y (call_args): 引数が唯一のコマンドコールである時のバグ(戻
り値が展開されてしまう)
Mon Nov 18 13:28:18 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_sub): 失敗した時にnilを返していた
* string.c (str_split_method): 検索開始位置が移動してなかった
* ext/socket/socket.c (sock_s_getservbyaname): まだ間違っていた
* version 0.99.3-961118
* string.c (str_sub_s): 元の文字列を置換するのを止めた
* pack.c (encodes): 領域外をアクセスしていた
Fri Nov 15 17:10:35 1996 Yukihiro Matsumoto <[email protected]>
* bignum.c (big_divmod): Bignumが引数の場合の対応忘れ
* sample/ruby-mode.el (ruby-expr-beg): word?形式への対応が不完全
Wed Nov 13 15:42:40 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_tr_s_bang): tr_sでtrが行われていなかった
* eval.c (rb_eval): autoloadクラスのチェック
* string.c (f_sub): subがsub!と同じ動作になっていた
* eval.c (thread_sleep): stopとsleepの分離
Mon Nov 11 13:53:19 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961111
* numeric.c (fix_step): to, stepが整数以外の場合に対応
* eval.c (rb_call): dynamic varがdynamic scopingになっていた(これ
はまずい)
* string.c (str_chop_bang): 長さ0の文字列のchopで,領域外のアクセ
スが発生していた.
* parse.y (yyerror): 割り当てた領域外をアクセスしていた
Fri Nov 8 11:54:46 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_yield): scopeをheapにコピー
Thu Nov 7 09:56:53 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (num_coerce): とりあえず両辺をFloatに変換することに
Wed Nov 6 10:45:13 1996 Yasuo OHBA <[email protected]>
* lib/parsearg.rb: 第2引数を変更.
Tue Nov 5 14:21:09 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961105
Sat Nov 2 01:11:40 1996 Yukihiro Matsumoto <[email protected]>
* bignum.c (big_pow): typo (dy -> dx)
* bignum.c (big_divmod): 知らない型はfloatに変換してみる
* numeric.c (fix_lshift): 境界条件のバグ(負になっていた)
* bignum.c (big_pow): 無駄なfloatへの変換をなくした
* math.c (math_atan2): typo(x -> y)
Fri Nov 1 15:30:59 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (sock_gethostname): gethostnameがない時には
unameを使ってホスト名を得る
* ext/etc/etc.c (etc_getlogin): getloginがNULLを返しても環境変数を
調べるように
* object.c (krn_clone): オブジェクトのフラグもコピー
* hash.c (rb_cmp): ハッシュの比較を`=='でなく`eql?'に変更
* math.c (Need_Float): Float()を使って変換する
* compar.c (cmp_gt): 以前の右辺を返す仕様の名残が残っていた
Thu Oct 31 12:55:51 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961031
* numeric.c (Init_Numeric): typo
* eval.c (error_print): 長すぎるtrace backを途中省略する
* regex.c (re_compile_pattern): 全角のrangeに対応
Wed Oct 30 03:03:18 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961030
* io.c (f_ungetc): 関数を追加
* eval.c (dyna_var_asgn): return値忘れ
Tue Oct 29 10:05:28 1996 Yukihiro Matsumoto <[email protected]>
* string.c (f_split): 関数splitを追加
* eval.c (rb_call): ネストした外側のクラス/モジュールの定数を参照
できるように
Mon Oct 28 09:51:03 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_sub): offsetが文字の末尾にある時のチェック
* regex.c (re_match): 割り当てるレジスタの数が1多かった
* io.c (io_gets): $/ = ""の動作をperlに合わせる(awkとはちょっと違
うらしい)
* io.c (io_gets): $/ = nilの時少し高速化
* string.c (str_split_method): 括弧がnullにマッチした時にも無視し
ないように
* string.c (str_split_method): 括弧にマッチした分はlimitの数に含め
ないように.
* numeric.c (num_coerce_bin): coerceの定義を変更,2要素の配列
[x,y]を返すように
* sample/ruby-mode.el (ruby-calculate-indent): "do |aa|"の対応を改
善した.
Sat Oct 26 01:43:51 1996 Yukihiro Matsumoto <[email protected]>
* ext/marshal/marshal.c (w_object): ビルトインクラスのサブクラスを
正しく復旧できるように
* ext/marshal/marshal.c (w_object): ユーザ定義dumpの優先
* numeric.c (flo_coerce): Float()を使って定義
* numeric.c (Init_Numeric): Numericのnewのundefはまずい
* ext/marshal/marshal.c (w_symbol): シンボルの内容(文字列)は一度し
かファイルに書き出さない.
* sample/ruby-mode.el (ruby-parse-region): if/while修飾子に対応し
なくなっていた
* bignum.c (Init_Bignum): Bignum.newを除く
* eval.c (rb_eval): 引数評価後にファイル名と行番号を再設定
* numeric.c (flo_div): typo
* sample/ruby-mode.el (ruby-parse-region): def /, def `に対応
Fri Oct 25 09:26:29 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-calculate-indent): "do |aa|"に対応
* array.c (ary_aset): indexがfixnumの場合ちょっと高速化
* eval.c (thread_fd_writable): 書き込み前のselectチェック
* array.c (ary_assoc): 無限ループに落ちた
* eval.c (thread_wait_for): selectがエラー終了した時,linux以外で
の動作が正しくなかった.
Thu Oct 24 08:26:48 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (backtrace): `$@'を文字列から配列に変更した.
* eval.c (eval): eval中の例外発生位置を保存する
* bignum.c (bigsub): オペランドの大小比較の失敗
* re.c (reg_search): 直接参照がない時にも`$~'がセットされるように
Wed Oct 23 10:40:10 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961023
* ext/marshal/marshal.c (r_bytes): mallocをやめ,allocaを使う
* sample/ruby-mode.el (ruby-calculate-indent): 括弧の対応を変更.
()内ではインデントをレベルを合わせるように
Tue Oct 22 12:59:11 1996 Yukihiro Matsumoto <[email protected]>
* hash.c (hash_s_new): sizeを指定できるように
* ext/marshal/marshal.c (w_object): dumpする深さ制限を指定できるよ
うに
* array.c (ary_s_new): sizeを指定した時の初期化忘れ
* object.c (f_float): big2dblの宣言忘れ.
* bignum.c (bigsub): 大きさの近いBignum同士の演算で結果が負になる
場合に間違いがあった.
* array.c (ary_aset): 置換先と置換元が同じ長さの時内容を
shift(memmove)しないように.
* ext/marshal/marshal.c (marshal_dump): ファイルフォーマットにバー
ジョンを埋め込むように
* ext/marshal/marshal.c (tmpnam): linux-aout-dln用に定義
Mon Oct 21 08:40:20 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (sock_s_gethostbyname): hostent構造体の情報
を返す
(sock_s_gethostbyaddr): IPアドレスからhostent構造体を得る
(sock_s_getservbyaname): getservbyname(3)
Fri Oct 18 10:37:36 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-indent-to): 移動先カラムが負になるバグ
* eval.c (compile): evalで元ソースの行番号でエラーを表示する
Thu Oct 17 09:52:28 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (eval): evalで文法エラーがあった時にSEGV
* lib/safe.rb: Restricted.evalの中だけ制限を加える.
* eval.c (error_print): バックトレースの出力.callerで例外発生位置
を調整した時に問題が出る(そんなことをしなければ良いのだが…)
* eval.c (make_backtrace): バックトレースの生成
Wed Oct 16 12:56:22 1996 Yukihiro Matsumoto <[email protected]>
* ruby-man-0.99.2-jp/index.html: 日本語版ドキュメントの完成(長かった…)
* re.c (reg_regcomp): $=がnilの時の処理
* string.c (f_chop): $_に対するchop
Tue Oct 15 11:04:23 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961015
Mon Oct 14 18:22:38 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): BOW対応.selectが-1を返した時にバグ(実
はdo .. whileがcontinueで先頭にジャンプすると思い込んでいた.条
件の直前だったのね ^^);;;;;
* sample/ruby-mode.el (ruby-mode-syntax-table): ?のsyntaxが"/"では
まずいらしい
* hash.c (rb_hash): name conflict
Fri Oct 11 00:23:05 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961011
* ext/marshal/marshal.c (w_object): 結局動いていなかった循環オブジェ
クト対応を外した.
* hash.c (rb_hash): Fixnumと文字列の高速化
* ext/marshal/marshal.c (w_object): 無駄なデータの削除(フォーマッ
トの非互換性)
* io.c (io_readline): 戻り値の不備
* ext/marshal/marshal.c (marshal_dumps): MSDOS対応
* ruby.c (load_file): MSDOS対応
Wed Oct 9 17:46:27 1996 Yukihiro Matsumoto <[email protected]>
* ext/extmk.rb.in (install): 無駄なコピーを避ける
* string.c (str_sub_method): マッチがなかった時のString#subの値が
違っていた.
* eval.c (obj_extend): extendした時にobject_extendedを呼ぶように
Tue Oct 8 00:55:38 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_alloc): 割当の平均化
* eval.c (thread_schedule): joinのバグを修正
* eval.c (thread_wait_for): selectへの割込みなどに対応
* eval.c (thread_select): linuxのselectの挙動に対応(timeoutが変化
する)
Mon Oct 7 09:47:19 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961007
* eval.c (PUSH_BLOCK): the_classの保存を忘れていた.
* ext/dbm/dbm.c (fdbm_store): sizeの保存する場所が間違っていた
* ext/socket/socket.c (s_accept): thread対応していなかった
Sat Oct 5 01:32:27 1996 Yukihiro Matsumoto <[email protected]>
* io.c (io_readchar): EOFで例外を発生させる
Fri Oct 4 11:59:54 1996 Yukihiro Matsumoto <[email protected]>
* ext/marshal/marshal.c (w_object): HashとObjectの復旧に必要なハッ
シュテーブルが渡されていなかった.
* variable.c (rb_path2class): ユーザ定義クラスの復旧に失敗していた
* variable.c (rb_path2class): クラスが存在しない時のエラーをFatal
からNameErrorへ.
* range.c (range_s_new): first,lastが両方Numericの時エラーになって
いた.
* range.c: start->first, end->last
Wed Oct 2 02:02:46 1996 Yukihiro Matsumoto <[email protected]>
* file.c: DJGPPでchmod,chownを使えるように(ってDOSにchownがあるのか?)
* class.c (rb_singleton_class): ビルトインクラスもextendしたり特異
メソッドを追加したりできるように
* variable.c (rb_set_class_path): ユーザ定義のトップレベルクラスに
pathを設定しない
* eval.c (eval): 例外がRuntimeErrorに化けていた
* eval.c (eval): eval中の例外の表現の改善
* eval.c (eval): eval_with_bindingとの一本化
* eval.c (rb_eval): クラス/モジュール定義の中から定義中のクラス/モ
ジュールが参照できるように
Tue Oct 1 01:40:09 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961001
* parse.y: cur_crefが2度宣言されていた
* signal.c (trap): SIGSEGV,SIGBUSのない機種に対応
* io.c (Init_IO): 引数タイプの指定間違い
Mon Sep 30 15:28:00 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960930
* config.guess,config.sub: $host_osが正しく設定されない
* eval.c (rb_eval): yieldで正しくないselfが設定されていた
* eval.c (ruby_run): toplevelの例外処理のバグ
Mon Sep 30 09:13:26 1996 WATANABE Hirofumi <[email protected]>
* djgpp対応
Sat Sep 28 02:45:10 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960928
* sample/ruby-mode.el (ruby-beginning-of-block): ブロックの先頭に
移動(正しくインデントしていないと動作しない)
(ruby-end-of-block): 同上
* eval.c (class_s_new): Class#newがイテレータとして呼ばれた時は
initializeもイテレータとして呼ばれるように
* signal.c (sigsegv): SEGVでbacktraceを表示するように
Fri Sep 27 09:51:07 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960927
* eval.c (error_print): 引数のないraiseでメッセージが正しく表示さ
れるように.
* eval.c (rb_longjmp): mesgがnilの時RuntimeErrorを生成する.
* eval.c (f_raise): 引数がない時に対応
* eval.c (thread_mark): stack上にないデータのアドレス変換を行って
いた.
* eval.c (Init_Thread): 割込みの間隔が1秒と長すぎた.
Thu Sep 26 16:02:45 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): 一度ペンディングになるとフラグがクリア
されていなかった.
* process.c (rb_proc_exec): system/execの引数が空文字列であった場
合,例外を発生すべきだった.
* config.sub/config.guess: 新しいものに置き換え
Thu Sep 26 15:41:35 1996 WATANABE Hirofumi <[email protected]>
* io.c (next_argv): -i.bakをBOWとDOSに対応.
Thu Sep 26 01:31:43 1996 Yukihiro Matsumoto <[email protected]>
* io.c (io_sysread): EOFで例外
* io.c (f_readline): EOFで例外を発生するように.getsは互換性のため
nilを返すままにする
* eval.c (proc_call): lambdaからのreturnでIN_BLOCKフラグが立ったま
まだった
* eval.c (PUSH_BLOCK2): threadに対応するためBlockを一度stackにコピー
Wed Sep 25 11:54:11 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (method_call): Const::method()形式を使えるようにしてみた.
引数括弧は省略できない.
* sample/test.rb: Process.killの存在を確かめてからテストを行う
* eval.c (eval_with_binding): 第2引数としてbinding(またはlambda)を
与えるとその環境でevalを実行するようにした
* eval.c (f_binding): 現在のbindingを返す関数
* eval.c: block構造体にthe_classを保存するメンバを追加
* process.c (Init_process): kill,wait,waitpidをProcessに移動
Tue Sep 24 02:44:43 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el: いろいろ問題が多いので以前の高速化は破棄.
別のアプローチを使った.
* lib/tk.rb (Tk.pack): 複数のウィンドウを受け付けるpack
Sat Sep 21 11:08:09 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (exprs): 空文も受け付けるように文法を変更.今までは改行
の連続だけが許されていた.
Fri Sep 20 11:39:18 1996 Yukihiro Matsumoto <[email protected]>
* Failの大半を名前つき例外に変更.
* re.c (Init_Regexp): 名前つき例外を導入.
* eval.c (f_missing): Objectはinspectしない.
* object.c (inspect_i): Object#inspectでloopに対応.
* regex.c (re_search): /^$/が""にマッチしなかった.
Thu Sep 19 19:25:12 1996 Yukihiro Matsumoto <[email protected]>
* regex.c (re_search): /^$/が非空行にマッチしていた.
Tue Sep 17 10:28:11 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960917
Mon Sep 16 10:47:56 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-calculate-indent): 演算子継続の場合の
文字列の判定のバグ
* sample/ruby-mode.el (ruby-calculate-indent): elseなどの次の行の
インデント計算を正しく.
Sat Sep 14 08:37:19 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960914
Fri Sep 13 08:06:03 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (tcpaddr): port番号にntohsをつけ忘れ
* dln.c (link_undef): テーブルの種類が間違っていた.
* bignum.c (bigadd): 引き算が発生する時に計算違いが起きていた.
* parse.y (iter_do_block): do..endでもdynamic variableを.
* bignum.c (big_pow): より正確な計算を(整数同士ではfloatに変換しな
い).
Thu Sep 12 13:11:55 1996 Yukihiro Matsumoto <[email protected]>
* variable.c (rb_set_class_path): Stringクラスが初期化される前に
Stringを作っていた.組込みクラスにはpathはいらない
* parse.y (yylex): 0.1が0になっていた
* parse.y (yylex): 行番号の不整合
* gc.c (oblist_live_obj): 今「生きている」全部のオブジェクトを返す
イテレータ.そのクラス(またはサブクラス)の全部のインスタンスを返
すeach_object_ofも定義した.
* class.c (rb_define_class_id): 無駄なクラスを割り当てていた.結果
として未初期化のクラスオブジェクトが存在していた.
Wed Sep 11 00:56:23 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (yylex): octalの定数の検出をより正確に(090はエラーとか).
* bignum.c (big_minus): yがxより大きい場合にエラー.
* parse.y (yylex): エラー行番号の表示をより正確に
* sample/ruby-mode.el (ruby-expr-beg): 変数名が1文字の時誤動作して
いた.
* sample/ruby-mode.el (ruby-calculate-indent): ?/でループに落ちい
たバグを修正.
* enum.c (enum_min,enum_max): sortのようにイテレータとしても動作す
るように.
* enum.c (enum_find_all): typo
Tue Sep 10 12:07:12 1996 Yukihiro Matsumoto <[email protected]>
* node.h (nd_line): NODEのlineをflagsに押し込めてオブジェクトサイ
ズを小さくした.制限:32bit intのマシンの場合,ファイルの行数が
32767を越えると正常に表示されない.
* st.c: hashとcompareの関数メンバを構造体にパック,クラス的な使い
方を行う.1 tableあたり4 byteの節約.
Mon Sep 9 16:35:54 1996 Yukihiro Matsumoto <[email protected]>
* file.c (file_truncate): 提供されない時には特別な例外を発生するよ
うに.
* eval.c (Init_Proc): 不適切な位置のlocal-jumpを例外に.
Sat Sep 7 17:06:15 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (proc_call): まだスコープがスタック上にある時には局所脱出
を有効にする.これで,procを生成してcallすることは,スコープを脱
出しない限り,yieldと同じ意味を持つことになる.
Fri Sep 6 13:30:59 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-indent-to): インデントが変わらない時に
はバッファを変更しない.
(ruby-calculate-indent): まず文字列の内部か判断してから,前の行
からパーズを行う.defunが大きくなった時の高速化.
(ruby-in-string-p): 文字列の内部かどうかを判断する関数(以前の
parseから分離)
(ruby-parse-region): 文字列に対する処理をはずす.
(ruby-beginning-of-block): ブロックの先頭に
(ruby-end-of-block): ブロックの末尾に(遅い…)
Thu Sep 5 14:23:07 1996 Yukihiro Matsumoto <[email protected]>
* file.c (file_s_split): [dirname,basename]にsplitする.
* eval.c (rb_eval): evalの中でも定数の値が正しくなるように.これで
定数に関しては静的なスコープが保証されるようになった.
* st.c (rehash): ハッシュ拡大の系数を2から1.79に.割算がより良い値
を返すように.
Thu Sep 5 00:32:07 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (class_superclass) クラスのスーパークラスを返すメソッド.
Wed Sep 4 16:54:56 1996 Yukihiro Matsumoto <[email protected]>
* random.c (f_rand): Bignumやlongの範囲を越えるFloatに対する乱数も
発生できるように.
* struct.c (struct_alloc): Fatalではなく例外を発生させるように(通
常の使用で発生しうる).
* struct.c (struct_s_members): Structの特異メソッドではなく,生成
されたStructクラスの特異メソッドにした.
* st.c (st_init_table): ruby専用にパラメタを固定にした(サイ
ズが減った)
Mon Sep 2 11:37:59 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_shift): capaがあまりにも大きい時には領域をREALLOC
(ary_pop): 同上
* string.c (str_inspect): multibyte character 対応にミス.
(str_inspect): unsigned charにしないと符号展開されてしまう
* parse.y (primary): `::'をprimaryに移動 Foo::Bar.Bazがエラーにな
らないように.
* parse.y (primary): オペレータ形式の特異メソッドが定義できない
* random.c (f_rand): maxが0の時に対応
* io.c (io_printf): 関数を定義していたがインタプリタに登録していな
かった.
* file.c (file_s_basename): 第2引数が無い時にエラー.
Thu Aug 29 10:49:40 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (expr): イテレータの新形式に「method do .. end」形式を採
用した.もちろん昔の形式も有効.
* sample/ruby-mode.el (ruby-calculate-indent): endの数の方が多い場
合にもエラーを起こさないように.
Wed Aug 28 09:41:36 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (upto,downto,step,times): 対象がfixnumの範囲を越えても
動作するように.
Mon Aug 26 10:04:37 1996 Yukihiro Matsumoto <[email protected]>
* missing/setenv.c (envix): typo(missing `== 0' for memcmp)
* dir.c (dir_foreach): foreach(dir open -> read loop -> closeまで)
* io.c (io_foreach): foreach(file open -> read loop -> closeまで)
* Fatalのうち捕捉可能ないくつかを例外に.
Sat Aug 24 23:56:37 1996 Yukihiro Matsumoto <[email protected]>
* bignum.c (bigdivmod): FIX2INT -> INT2FIX 大間違い
Fri Aug 23 18:13:03 1996 Yukihiro Matsumoto <[email protected]>
* regex.c (re_free_registers): allocateしていない時には当然 free
してはいけない.
Thu Aug 22 01:20:35 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_create): 外側から強制終了させられたthreadは
cleanupする必要が無い.
Wed Aug 21 09:57:28 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_create): threadを終了させた大域脱出の情報を
main_threadに渡すように.
* parse.y (call_args): 最終引数に括弧を省略したメソッド呼出しを置
けるように(例: print foo bar, baz == print(foo(bar,baz)))
Tue Aug 20 13:37:16 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (masign): 多重代入とrest引数の動作を合わせて空の配列を代
入するように.
* parse.y (arg): defined?の強度をもうちょっと強く
* eval.c (error_print): -wで例外名も表示するように
* eval.c (rb_eval): 新構文に対応
(handle_rescue): 捕捉する例外を kind_of? で同定
* parse.y (primary): rescueの構文を変更(同定引数の追加,複数rescue)
* Fail()のかなりを適当な例外を使うように
* eval.c (thread_interrupt): Interrupt(今はnon-local jump)は
main-threadに送られるように.
* eval.c (rb_longjmp): $! の内容を文字列から例外クラスに変更
(rb_raise): rb_fail から名称変更
(rb_interrupt): 例外化
(rb_exit): 例外化
* error.c (Init_Exception): 例外クラスの新設(文字列のサブクラス)
Mon Aug 19 19:40:52 1996 Yukihiro Matsumoto <[email protected]>
* signal.c (trap): 古いハンドラを返すように.
Wed Aug 14 00:07:18 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_trap_eval): ハンドラのためにthreadをforkすることを止
めた.
* eval.c (thread_mark): thread毎の $!, $@ をマークし忘れ
* ext/dbm/dbm.c (fdbm_delete): イテレータとして呼ばれた場合,要素
が無ければブロックを評価する.
* hash.c (hash_delete): イテレータとして呼ばれた場合,要素が無けれ
ばブロックを評価する.
* array.c (ary_delete): イテレータとして呼ばれた場合,要素が無けれ
ばブロックを評価する.
* eval.c (rb_interrupt): SIGINTのデフォルトをexitから特別な大域脱
出に.やはり割り込まれた位置の表示が無いのは寂しいので.
Tue Aug 13 01:34:00 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_exit): sub-thread内でのexitもstatusを保存するように
(thread_create): 自thread内のexitに対応
* signal.c (sighandle): SIGINTのデフォルトハンドラはexitするように
(以前は例外を発生していた).
* 例外の一部をFatalに.
* string.c (str_aset): 文字列の置換の対象が部分文字列でなかった時,
例外を発生させないように
* eval.c (proc_call): Procの中からbreak/nextは通し,他のものは通さ
ないように
Mon Aug 12 14:15:09 1996 Yukihiro Matsumoto <[email protected]>
* object.c (krn_type): 文字列を返す
* eval.c (thread_create): sub-thread内でのexitに対応
* numeric.c (fix_type): 文字列を返す
* io.c (f_p): デバッグ用データ表示メソッド
* eval.c (f_missing): nil/TRUE/FALSEを特別扱い
* string.c (str_inspect): 長い文字列を短縮表示.inspectの働きを
human readable stringの生成に統一(re-generatable string は正式に
無くなった).
Sat Aug 10 16:54:21 1996 Yukihiro Matsumoto <[email protected]>
* object.c (Init_Object): kernel/nil/false/trueのクラス名を変更(小
文字に),rubyスクリプトからアクセスできないように.
* eval.c (rb_eval): CONSTANTのアクセス先を単純化.crefを使わない.
* eval.c (f_eval): 特異メソッド内でも定数の値が正しくなるように
Fri Aug 9 12:23:17 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_concat): append -> concat Stringに合わせた
* parse.y (yylex): `$;'が使えなかった.
* array.c (ary_push_method): 複数引数を受け付けるように.
(ary_unshift): 複数引数を受け付けるように.
* io.c (io_popen): IO.popenでcommand pipeが開けるように.
* object.c (Init_Object): KernelとNilをruby scriptからアクセスでき
ないように.
Thu Aug 8 01:21:47 1996 Yukihiro Matsumoto <[email protected]>
* object.c (f_integer): 整数への変換関数
(f_float): 実数への変換関数
(f_string): 文字列への変換関数
(f_array): 配列への変換関数
* bignum.c (big_to_i): FIXNUMの範囲でない時はBignumのまま返すよう
に変更.
Wed Aug 7 09:28:38 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.1-960807
* parse.y (mlhs): 「*foo = 1,2,3」タイプの多重代入も可能に.
* object.c (Init_Object): クラスTrue/Falseをruby scriptからアクセ
スできないように.
* object.c (nil_inspect): inspect表現は"nil"に
* io.c (io_print): nilのprintをnilに.
* object.c (nil_to_s): nilの文字列表現を""に.
Tue Aug 6 01:12:32 1996 Yukihiro Matsumoto <[email protected]>
* dir.c (dir_s_open): file descripterが足りない時にはgcしてからも
う一度openしてみる.
* io.c (rb_fopen): すべてのfopen()についてfile descripterが足りな
い時にはgcしてからもう一度openしてみる.
* ext/socket/socket.c (Init_socket): 定数の追加.
* sample/ruby-mode.el (ruby-indent-to): インデント後のカーソル位置
の調整を正しく.
* gc.c (gc): 割込みチェックを行わない(Cコードの中で安心して
malloc()が使えなくなるので).
* st.c (call_hash_func): signalとthreadによる割込みに対応.
* sig.h (DEFER_INTS): 割込み禁止区間の指定
* eval.c (f_require): threadによるrequireの競合に対応(最初の
requireが終了するまで他のthreadは待つ).
* bignum.c (str2inum): 0x80000000の値が負になっていた
* sprintf.c (f_sprintf): 文字列末尾,行末の単独の`%'に対応
* bignum.c (big_cmp): 比較の結果が逆になる時があった.
Mon Aug 5 10:58:13 1996 Yukihiro Matsumoto <[email protected]>
* process.c (proc_exec_v): 例外のメッセージを分かりやすく.
* ext/dbm/dbm.c (fdbm_store): nilを格納すると要素の削除になる
* ext/dbm/dbm.c: サイズをキャッシュ.
Sat Aug 3 01:52:52 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_fail): `fail'が引数無しで呼ばれた時だけ以前の`$@'を保
存するように.
* eval.c (f_fail): frameの調整
Fri Aug 2 11:26:21 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (bsock_setopt): valとしてTRUE/FALSE/Fixnumも
受け付けるように.
* ext/socket/socket.c (Init_socket): SO_REUSEADDR等の定数の追加
* ext/md5/md5init.c: md5モジュール(初の複数ファイルからなるモジュー
ルでもある)
* ruby.h (Make_Data_Struct): Data: objectのinstance変数に格納 ->
Data型のObjectに(Dir,Time,Proc,Thread,DBM)
Thu Aug 1 11:38:44 1996 Yukihiro Matsumoto <[email protected]>
* ext/dbm/dbm.c (fdbm_store): valueが文字で無い時に対応
Wed Jul 31 10:53:42 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (open_inet): htonsが必要であった
(tcpaddr): ntohlで変換した
* process.c (rb_proc_exec): execvp -> execv
Tue Jul 30 17:48:33 1996 Yukihiro Matsumoto <[email protected]>
* eval.c: `$?'をthread localに
* Makefile.in (install): install時にstripを行う
* configure.in: install時のstripの検出
* configure.in: NEXTSTEP対応
* version 0.99.1-960730
Tue Jul 30 16:40:35 1996 SHIROYAMA Takayuki <[email protected]>
* dln.c (dln_load): NeXT dln(mach-o)対応.configureは未対応
Tue Jul 30 09:46:51 1996 Yukihiro Matsumoto <[email protected]>
* process.c (f_system): 複数引数もとれるように
* process.c (f_exec): 複数引数もとれるように
* array.c (ary_append): 配列(またはEnum)の要素を破壊的に追加
* array.c (ary_plus): Enumはその要素を追加
* file.c (file_s_open): File.openを追加
* struct.c (struct_new): FIX2INTを忘れていた
* file.c (Init_File): exists? -> exist?
* object.c (obj_is_kind_of): is_kind_of? -> kind_of?, is_a?
* object.c (obj_is_instance_of): is_instance_of? -> instance_of?
Mon Jul 29 16:40:02 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (parse_regx): 式展開を行った場合,casefoldの設定ができて
いなかった.
* object.c (true_type): TRUE/FALSEにtypeを実装.
* parse.y (read_escape): 3文字以内のoctalに対応(\0とか)
Fri Jul 26 00:31:45 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_reverse_bang): in-placeで配列を反転させる
(ary_sort_bang): in-placeでsortする
(ary_sort): sortした配列を返すように
(ary_delete_at): 指定した位置の要素を削除する
* eval.c (rb_call): stack深さチェックを毎回は行わないように
* error.c (Warning): 実行中のwarningが表示されていなかった
* eval.c (compile): 例外発生を分離.
* eval.c (f_eval): 変数rb_in_evalを正しく管理するように
* ext/dbm/dbm.c (fdbm_store): 格納するkeyを文字列に変換
* eval.c (rb_call): 無限再帰のチェックを大域脱出を行うC methodにも
対応させた.threadのstack深さチェックルーチンを流用.
* parse.y (yylex): 第1引数のunary -/+の判定が間違っていた.
* parse.y (yylex): unary +で数字を余計に読んでいた(ex. +5 -> 55)
Thu Jul 25 12:15:04 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (yylex): 曖昧でない引数に対して警告を出していた.
* eval.c (iterator_p): 引数で呼んでも正しい結果を返すように.
* parse.y: break/next/redo/retryのメソッド化.
* sample/ruby-mode.el (ruby-calculate-indent): nestのチェックミス
* sample/ruby-mode.el (ruby-parse-region): 予約語のチェックを強化
* parse.y (primary): unless/untilの復活
Tue Jul 23 18:50:10 1996 Yukihiro Matsumoto <[email protected]>
* array.c (Array#empty?), Hash.c (Hash#empty?), ext/dbm/dbm.c (DBM#empty?):
空の判定述語
* eval.c (f_unless): ifの逆をするイテレータ
* eval.c (f_until): whileの逆をするイテレータ
* parse.y: notの優先順位をand/orより高く
* parse.y (expr): `!'を引数括弧を省略したcallでも有効に
Mon Jul 22 10:15:38 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960722
* array.c (ary_print_on): OFSのNILチェックが不完全
* ruby.c (load_file): 標準入力からのスクリプトが空の時に対応.
* ruby.c (proc_options): -wでは引数無しの時には標準入力からスクリ
プトをとる(-vではたんに終了する).
* array.c (ary_compact): nilの要素を取り除くメソッド
* array.c (ary_nitems): nilでない要素を数えるメソッド
Sun Jul 20 00:51:53 1996 Yukihiro Matsumoto <[email protected]>
* ruby.c (proc_options): -w optionを追加
* parse.y: {}が閉じていない時には展開しない文字列を
Fri Jul 19 16:16:05 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960719
* lib/find.rb: 石塚版(pruneの拡張付き)
* file.c (test_l): lstatで調べないとね.
* eval.c (f_throw): 第2引数を省略可能に.
* parse.y (str_extend): {}のネストに対応
Thu Jul 18 18:25:46 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960718
* parse.y (str_extend): 文字列中の式展開に \" ' ` / を含む事ができ
るように.
Tue Jul 16 15:55:31 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): 正規表現内のエスケープ
に対応
* version 0.99-960716
Fri Jul 12 10:06:19 1996 Yukihiro Matsumoto <[email protected]>
* io.c (f_select): 引数のclose check.
* ruby.c (load_file): #!行の引数チェックを第1引数に限定(実をいうと
DOS改行対策)
Wed Jul 10 17:18:35 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960710
* time.c (time_s_timegm/time_s_timelocal): 時間を生成するメソッド
Mon Jun 17 15:59:20 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960617
* parse.y (yyerror): エラー表示の簡略化.
Wed Jun 12 14:11:01 1996 Yukihiro Matsumoto <[email protected]>
* signal.c (rb_trap_exit): trap 0はthreadを生成せずに処理する.
Fri Jun 7 10:17:01 1996 Yukihiro Matsumoto <[email protected]>
* array.c/hash.c (indexes): 配列1引数のパターンを無くした.配列の
場合は`*ary'を使ってもらおう.
* eval.c (thread_wait_threads): main_threadが終了する前に他の
threadを待つ(強制的には終了させない).
(ruby_run): 他のthreadを待っている間にシグナルが来たら,全thread
を強制終了させる.
* eval.c (rb_fail): メソッド名を`$!'に埋め込む.
* eval.c (thread_create): main_threadのコンテクストがセーブされな
い場合があった.
* process.c (f_sleep): 時間を指定せず,threadがひとつしかない状況
にも対応.
* eval.c (thread_create): create後,fnを呼び出す前にcontext switch
が起きると違うcontextでfnが実行されてしまうバグ.
Mon Jun 3 08:03:17 1996 Yukihiro Matsumoto <[email protected]>
* struct.c (struct_s_def): メンバの指定を文字列,シンボル(FIXNUM)
双方で可能にした.
* ext/etc/etc.c (Init_etc): 構造体オブジェクトをGCから保護した.
* error.c (rb_sys_fail): nil/FALSEを引数として受け付けるように.
Thu May 30 16:19:08 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_select): EINTRに対応.
Wed May 29 11:04:51 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (f_catch): catch/throwを実装した.
Tue May 28 13:30:52 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960528
* eval.c (thread_cleanup): main threadが終了すると他のthreadも終了
することの明確化.
* signal.c (trap): SIGINTのデフォルトの設定ミス(本当にSIG_DFLでは
まずかった).rubyではちゃんとハンドルしないと.
* eval.c (thread_interrupt): SIGINTはmain_threadに例外を発生させる
ように.
Mon May 27 15:13:31 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_status): threadの状態を返すメソッド.threadの終了
を待たない.
* eval.c (thread_value): 一種のpromiseを実装するためのメソッド.
* eval.c (thread_join): 待っているthreadが例外を起こした時には,
joinがその例外を発生するように.
* eval.c (thread_create): threadでの例外をpropagateしないように.
Fri May 24 10:47:53 1996 Yukihiro Matsumoto <[email protected]>
* enum.c (Init_Enumerable): `size' as alias to the `length'
* eval.c (thread_save_context): `$@', `$!'をスレッド毎にセーブ.
* eval.c (superclass): エラー表示をより親切に.
Thu May 23 10:38:41 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960523
* eval.c (superclass): エラー時にスーパークラス名を(分かれば)表示
するように.
Wed May 22 19:48:42 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (superclass): スーパークラスの指定子を`:'から`<'に変更.
Tue May 21 09:27:59 1996 Yukihiro Matsumoto <[email protected]>
* lib/thread.rb: threadをサポートするクラス(Mutex, Queue).
Mon May 20 09:39:49 1996 Yukihiro Matsumoto <[email protected]>
* time.c (time_cmp): 浮動小数点数も扱えるように.
(time_minus): Time - Timeが浮動小数点数を返すように.
Fri May 17 15:40:10 1996 Yukihiro Matsumoto <[email protected]>
* process.c (rb_proc_exec): Thread対応時にexecの直前に
ITIMER_VIRTUALをリセットする.
Tue May 14 02:12:44 1996 Yukihiro Matsumoto <[email protected]>
* signal.c (sighandle): SIGINTに対してデフォルトで例外を発生させる
のをやめ,status 130でexitするようにした.
* eval.c (thread_schedule): Threadのバグはほとんどとれたようだ.
Fri May 10 11:21:08 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): ユーザレベルThread機能.効率はともかく
移植性はある.今後,thread間の通信機能を実装する予定.
Thu May 2 21:22:31 1996 Yukihiro Matsumoto <[email protected]>
* time.c (time_timeval): struct timevalを直接返すように(static変数
を使わない).
Wed May 1 17:27:32 1996 Yukihiro Matsumoto <[email protected]>
* process.c (f_sleep): 整数以外のtimeを指定できるように.
Thu Apr 25 08:19:15 1996 Yukihiro Matsumoto <[email protected]>
* file.c (file_s_dirname): ファイル名が"/"を含まない時,"."を返す
ように(GNU dirnameの仕様).
* file.c (file_s_basename): まだnilと0を混同しているソースが残って
いた.
* parse.y (exprs): エラーリカバリを追加.
Wed Apr 24 15:51:05 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_chop_bang): CRLFの場合2 bytesをchop!するように.
* ext/socket/socket.c (tcp_svr_s_open): まだnilと0を混同しているソー
スが残っていた.
Tue Apr 23 18:14:25 1996 Yukihiro Matsumoto <[email protected]>
* pack.c (pack_pack): "A/a"のバグ.余計なpaddingが入っていた.
Thu Apr 18 13:02:11 1996 Yukihiro Matsumoto <[email protected]>
* configure.in: アーキテクチャ依存部を別ディレクトリにインストール
するように.
* parse.y (yyerror): エラー発生時にエラー行とその位置を表示するよ
うに.
Wed Apr 17 14:22:42 1996 Yukihiro Matsumoto <[email protected]>
* defines.h: SAFE_SIGHANDLEを無くし,危険な選択はできないように.
* io.c (io_ungetc): 新機能.
* ruby.c (load_file): ファイルからの読み込み方式が変わったのに対応.
* parse.y (compile_file): ファイルからの入力を一度全部読み込むのを
止めて,getsを使うことにした.
Wed Apr 10 17:40:11 1996 Yukihiro Matsumoto <[email protected]>
* version 0.98
Tue Apr 9 09:54:30 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (iter_block): イテレータブロックの指定をメソッド呼び出し
に限定.文法の明確化.
* eval.c (rb_eval): 条件式の正規表現の比較をinline化.
* eval.c (rb_eval): defined? の 定義情報(種別)を文字列で返す.
* node.h: NODE_BEGIN -> NODE_RESCUE, NODE_ENSUREに分離.
* eval.c (rb_eval): option -n/-pのトップレベルループのinline展開.
* parse.y (cond0): 条件式中の文字列は比較の対象としない
Wed Mar 27 12:33:54 1996 Tairo Nomura <[email protected]>
* defines.h: NeXT対応
Wed Mar 27 10:02:44 1996 Yukihiro Matsumoto <[email protected]>
* parse.y: 予約語の変更 continue -> next
Mon Mar 25 07:34:37 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (parse_regx): o(once)オプションを追加.
Fri Mar 22 14:25:35 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97d
* eval.c (dyna_var_defined): 動的ローカル変数の定義チェック用ルー
チン.
* parse.y (gettable): eval()の中での動的ローカル変数(既に値を持っ
ているもの)の検出に失敗していた.
Tue Mar 19 10:46:47 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97c
* re.c (reg_s_new): compile時にsegmentation fault.
* parse.y (str_extend): いつもevalするように.
Wed Mar 13 11:00:42 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (str_extend): 文字列中の式展開の不備を無くした.
* parse.y: 下手なエラーリカバリを外した.
Tue Mar 12 12:30:20 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rescue): 間違ってensureでも例外を捕捉していた.
Wed Mar 6 12:11:03 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (var_extend): 変数展開"#{}"で,任意の式を書けるようにし
た,これで「変数」展開では無くなっちゃったなあ.
* regex.c (init_syntax_once): `_'をwordに追加.
* regex.c (re_compile_pattern): `\w',`\W'の判定をsyntax tableを使
うように.
Tue Feb 27 10:15:32 1996 Yukihiro Matsumoto <[email protected]>
* object.c (obj_inspect): 表示するインスタンス変数が無い時には,
to_sを使う.
* configure.in: dlnの検出を自動的に.
Mon Feb 26 19:55:33 1996 Yukihiro Matsumoto <[email protected]>
* ruby.c (readin): read(2)で一度にファイルが読み込めない場合に対応.
Sat Feb 24 14:47:18 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97b
Fri Feb 23 11:26:02 1996 Yukihiro Matsumoto <[email protected]>
* class.c (rb_define_module): C言語で定義されたモジュールのPATHの
設定忘れ.文字列化でcore dump.
* eval.c (mod_include): 戻り値をnilに.
* version 0.97a
Thu Feb 22 21:03:42 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_times): 「配列*文字列」がjoinと同じ働きをするように.
Wed Feb 21 11:18:09 1996 Yukihiro Matsumoto <[email protected]>
* configure.in : fileCountをcache.
* configure.in : LinuxでELF環境を自動的に検出できるよう.
Tue Feb 20 11:18:09 1996 Mitsuhide Satou <[email protected]>
* FreeBSD dynamic link対応.
Fri Feb 16 08:50:01 1996 Yukihiro Matsumoto <[email protected]>
* object.c (obj_inspect): インスタンス変数を持たないオブジェクトも
正しく表示されるように.
Wed Feb 14 16:56:44 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): 条件式の`2..2'など左辺成立直後に右辺が成立する
パターンにバグ.
Tue Feb 13 18:22:22 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97
Fri Feb 9 21:32:55 1996 Yukihiro Matsumoto <[email protected]>
* lib/tkscrollbox.rb: スクロールでtclの設定を行い,ruby<->wishの不
要な通信を無くした.
Wed Feb 7 10:26:52 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_aref): indexをunsigned intでとっていた.
* string.c (str_aref): 範囲外のindexに対してnilを返す.
* parse.y (special_local_set): `$_'が宣言無しに使われた場合に対応.
関数をvariable.cから移動.
* string.c (str_sub): 置換開始位置が間違っていた.
Tue Feb 6 16:17:31 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): コメントの読み飛ばしの
バグ.
Fri Feb 2 18:35:28 1996 Yukihiro Matsumoto <[email protected]>
* variable.c (lastline_get): `$_'を`$~'と同じようにSCOPEローカルな
変数にした.
Thu Feb 1 14:14:07 1996 Yukihiro Matsumoto <[email protected]>
* file.c: statのcacheをやめた.
Wed Jan 31 07:13:08 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (proc_s_new): procの中でyieldを呼ばれた時にcore dumpして
いた.とりあえず例外を発生させる.
* variable.c (rb_class2path): singleton classに対応.
* ext/etc/etc.c (Init_etc): struct_defineのターミネータがnilだった
(0でなければならない).
* ext/marshal/marshal.c: TRUE/FALSEを吐き出せるように.
* eval.c (rb_get_method_body): キャッシュのalias対応,いままでは
aliasはキャッシュに入っていなかった.
Tue Jan 30 09:55:13 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): NODE_BLOCK - tail recursive(というほどでもない
が).
* io.c (io_pipe): pipe(2)を実装した.
* eval.c (rb_eval): Qselfをなくした.thread対応への第一歩.先は遠
いが….
* eval.c (proc_call): procの中でのreturnはprocの終了を意味するよう
に.ただし,procからのyieldの中でのreturnは例外を発生する.
Wed Jan 24 11:33:48 1996 Yukihiro Matsumoto <[email protected]>
* version 0.96a
* dir.c (dir_each): `$_'の値を変更するのをやめた.
* io.c (f_readlines): nilとFALSEの分離のあおりで無限ループに落ちて
いた.
* ruby.c (ruby_options): $0の設定ミス.
Tue Jan 23 15:28:21 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): ``は文字列を引数とするメソッド(`)呼び出しのシ
ンタックスシュガーであるとした.
* ruby.c (addpath): `-I'オプションでディレクトリが「前に」追加され
るように変更.
Fri Jan 19 11:23:12 1996 Yukihiro Matsumoto <[email protected]>
* dln.c (load_1): N_INDR対応(出来たような気がする).
Thu Jan 18 18:14:20 1996 Yukihiro Matsumoto <[email protected]>
* ruby.texi: FALSEとnilの分離を反映した.
Tue Jan 16 17:39:23 1996 Yukihiro Matsumoto <[email protected]>
* version 0.96 - とりあえずnilとFALSEを区別する版
Wed Jan 10 15:31:48 1996 Yukihiro Matsumoto <[email protected]>
* re.c (reg_match): マッチしなかった時の戻り値はFALSE.
* object.c (rb_equal): `0 == nil'がTRUEになるバグ.
Tue Jan 9 00:44:58 1996 Yukihiro Matsumoto <[email protected]>
* nilとFALSEが分離可能に変更.
* nilとFALSEと0の区別を厳密に.
* struct.c (struct_new): 引数を0で終る必要が無くなった.
* object.c (inspect_i): オブジェクトのチェックのバグ(Fixnumでcore
dumpしていた).
* range.c (range_to_s): Rangeの表示を改善.
* object.c (true_inspect): TRUEの表示を`TRUE'に.
Mon Jan 8 15:02:33 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (fix_mul): divide by zero errorが発生した(オーバーフロー
検出のバグ)
* texinfo.texをパッケージに含めた.
Sun Dec 31 00:08:49 1995 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): `::'では,そのクラスで定義された定数を参照する
ように変更.
* string.c (Init_String): eachをeach_lineに戻した.
Thu Dec 28 12:31:55 1995 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): caseの演算子を`=~'から`==='に.
* variable.c (rb_const_set): クラス定数の再定義を許す(同じクラスで
は不可).警告は出す.
Wed Dec 27 13:27:52 1995 Yukihiro Matsumoto <[email protected]>
* version 0.95c
* ext/tkutil/tkutil.c: wishがあってもなくても一応コンパイルだけは
するように.
* lib/tk.rb: 環境変数PATHから{wish|wish4.0}を探すように.
Tue Dec 26 01:03:42 1995 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): 正規表現の検出強化.
* numeric.c (fix_mul): 乗算のオーバーフロー検出アルゴリズムのバグ.
* ext/extmk.rb.in: ./install-shを使う場合のPATHを調整.
* Makefile.in (install): lib/*.rbを一つずつインストール.
* io.c (io_each_line): イテレータの戻り値をnilで統一.
Fri Dec 22 10:34:32 1995 Yukihiro Matsumoto <[email protected]>
* version 0.95b
* variable.c (f_untrace_var): 第2引数を指定すると特定のtraceを削除
できるように.
* variable.c (f_trace_var): 第2引数がnilの時,traceを削除する.
* lib/tk.rb (file_readable/file_writable): 第2引数をnilにすること
によるevent handlerの削除.
* parse.y (variable): ドキュメントに`__FILE__'と`__LINE__'が残って
いた.`caller(0)'で代用したはずだったのに.
* eval.c (f_eval): $!のリセット.
* error.c (err_sprintf): 勝手に"\n"を付加するのを止めた.
* parse.y (f_arglist): 引数リスト直後のif/whileの読み間違い.
lex_stateの値が設定されていなかった.
Co-authored-by: Jun Kuroda <[email protected]>
Co-authored-by: Mitsuhide Satou <[email protected]>
Co-authored-by: SHIROYAMA Takayuki <[email protected]>
Co-authored-by: Tairo Nomura <[email protected]>
Co-authored-by: WATANABE Hirofumi <[email protected]>
Co-authored-by: Yasuo OHBA <[email protected]>
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 1586 |
1 files changed, 975 insertions, 611 deletions
@@ -6,7 +6,7 @@ $Date: 1995/01/12 08:54:50 $ created at: Fri May 28 18:02:42 JST 1993 - Copyright (C) 1993-1995 Yukihiro Matsumoto + Copyright (C) 1993-1996 Yukihiro Matsumoto ************************************************/ @@ -26,11 +26,11 @@ #define ID_SCOPE_SHIFT 3 #define ID_SCOPE_MASK 0x07 -#define ID_LOCAL 0x00 -#define ID_INSTANCE 0x01 -#define ID_GLOBAL 0x02 -#define ID_ATTRSET 0x03 -#define ID_CONST 0x04 +#define ID_LOCAL 0x01 +#define ID_INSTANCE 0x02 +#define ID_GLOBAL 0x03 +#define ID_ATTRSET 0x04 +#define ID_CONST 0x05 #define is_id_nonop(id) ((id)>LAST_TOKEN) #define is_local_id(id) (is_id_nonop(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL) @@ -50,6 +50,7 @@ char *sourcefile; /* current source file */ int sourceline; /* current line no. */ static int yylex(); +static int yyerror(); static enum lex_state { EXPR_BEG, /* ignore newline, +/- is a sign. */ @@ -65,6 +66,7 @@ static ID cur_mid = 0; static int value_expr(); static NODE *cond(); +static NODE *logop(); static NODE *block_append(); static NODE *list_append(); @@ -90,12 +92,12 @@ static struct RVarmap *dyna_push(); static void dyna_pop(); static int dyna_in_block(); -VALUE dyna_var_ref(); -#define dyna_id(id) dyna_var_ref(id) +VALUE dyna_var_asgn(); +VALUE dyna_var_defined(); -#define cref_push() NEW_CREF(0) +#define cref_push() NEW_CREF() static void cref_pop(); -static NODE *cref_list; +static NODE *cur_cref; static void top_local_init(); static void top_local_setup(); @@ -118,46 +120,45 @@ static void top_local_setup(); ENSURE END IF + UNLESS THEN ELSIF ELSE CASE WHEN WHILE + UNTIL FOR IN - REDO - BREAK - CONTINUE + DO RETURN - FAIL YIELD SUPER - RETRY SELF NIL AND OR NOT - _FILE_ - _LINE_ IF_MOD + UNLESS_MOD WHILE_MOD + UNTIL_MOD ALIAS DEFINED %token <id> IDENTIFIER FID GVAR IVAR CONSTANT %token <val> INTEGER FLOAT STRING XSTRING REGEXP -%token <node> STRING2 XSTRING2 DREGEXP NTH_REF BACK_REF +%token <node> DSTRING DXSTRING DREGEXP NTH_REF BACK_REF %type <node> singleton %type <val> literal numeric -%type <node> compexpr exprs expr arg primary var_ref -%type <node> if_tail opt_else case_body cases rescue ensure -%type <node> call_args call_args0 args args2 opt_args +%type <node> compexpr exprs expr arg primary command_call method_call +%type <node> if_tail opt_else case_body cases rescue ensure iterator +%type <node> call_args call_args0 args args2 opt_args var_ref %type <node> superclass f_arglist f_args f_optarg f_opt %type <node> array assoc_list assocs assoc undef_list -%type <node> mlhs mlhs_head mlhs_tail lhs iter_var opt_iter_var backref +%type <node> iter_var opt_iter_var iter_block iter_do_block +%type <node> mlhs mlhs_head mlhs_tail lhs backref %type <id> variable symbol operation %type <id> cname fname op rest_arg %type <num> f_arg @@ -166,6 +167,7 @@ static void top_local_setup(); %token POW /* ** */ %token CMP /* <=> */ %token EQ /* == */ +%token EQQ /* === */ %token NEQ /* != <> */ %token GEQ /* >= */ %token LEQ /* <= */ @@ -187,14 +189,15 @@ static void top_local_setup(); * precedence table */ -%left IF_MOD WHILE_MOD -%right NOT +%left IF_MOD UNLESS_MOD WHILE_MOD UNTIL_MOD %left OR AND +%right NOT +%nonassoc DEFINED %right '=' OP_ASGN %nonassoc DOT2 DOT3 %left OROP %left ANDOP -%nonassoc CMP EQ NEQ MATCH NMATCH +%nonassoc CMP EQ EQQ NEQ MATCH NMATCH %left '>' GEQ '<' LEQ %left '|' '^' %left '&' @@ -203,7 +206,6 @@ static void top_local_setup(); %left '*' '/' '%' %right '!' '~' UPLUS UMINUS %right POW -%left COLON2 %token LAST_TOKEN @@ -211,32 +213,29 @@ static void top_local_setup(); program : { lex_state = EXPR_BEG; top_local_init(); + NEW_CREF0(); /* initialize constant c-ref */ } compexpr { eval_tree = block_append(eval_tree, $2); top_local_setup(); + cur_cref = 0; } -compexpr : exprs opt_term +compexpr : exprs opt_terms exprs : /* none */ { - $$ = Qnil; + $$ = 0; } | expr - | exprs term expr + | exprs terms expr { $$ = block_append($1, $3); } - | exprs error - { - lex_state = EXPR_BEG; - } - expr + | error expr { - yyerrok; - $$ = block_append($1, $4); + $$ = $2; } expr : mlhs '=' args2 @@ -253,41 +252,18 @@ expr : mlhs '=' args2 { value_expr($2); if (!cur_mid && !in_single) - Error("return appeared outside of method"); + yyerror("return appeared outside of method"); $$ = NEW_RET($2); } - | FAIL args2 - { - value_expr($2); - $$ = NEW_FAIL($2); - } | YIELD args2 { value_expr($2); $$ = NEW_YIELD($2); } - | DEFINED {in_defined = 1;} arg - { - in_defined = 0; - $$ = NEW_DEFINED($3); - } - | operation call_args0 - { - $$ = NEW_FCALL($1, $2); - } - | primary '.' operation call_args0 - { - value_expr($1); - $$ = NEW_CALL($1, $3, $4); - } - | SUPER call_args0 - { - if (!cur_mid && !in_single && !in_defined) - Error("super called outside of method"); - $$ = NEW_SUPER($2); - } - | UNDEF undef_list + | command_call + | iterator iter_do_block { + $2->nd_iter = $1; $$ = $2; } | ALIAS fname {lex_state = EXPR_FNAME;} fname @@ -297,38 +273,76 @@ expr : mlhs '=' args2 | expr IF_MOD expr { value_expr($3); - $$ = NEW_IF(cond($3), $1, Qnil); + $$ = NEW_IF(cond($3), $1, 0); + } + | expr UNLESS_MOD expr + { + value_expr($3); + $$ = NEW_UNLESS(cond($3), $1, 0); } | expr WHILE_MOD expr { value_expr($3); if (nd_type($1) == NODE_BEGIN) { - $$ = NEW_WHILE2(cond($3), $1); + $$ = NEW_WHILE(cond($3), $1->nd_body, 0); } else { - $$ = NEW_WHILE(cond($3), $1); + $$ = NEW_WHILE(cond($3), $1, 1); + } + } + | expr UNTIL_MOD expr + { + value_expr($3); + if (nd_type($1) == NODE_BEGIN) { + $$ = NEW_UNTIL(cond($3), $1->nd_body, 0); + } + else { + $$ = NEW_UNTIL(cond($3), $1, 1); } } | expr AND expr { - value_expr($1); - $$ = NEW_AND(cond($1), cond($3)); + $$ = logop(NODE_AND, $1, $3); } | expr OR expr { - value_expr($1); - $$ = NEW_OR(cond($1), cond($3)); + $$ = logop(NODE_OR, $1, $3); } | NOT expr { value_expr($2); $$ = NEW_NOT(cond($2)); } + | '!' command_call + { + value_expr($2); + $$ = NEW_NOT(cond($2)); + } | arg +command_call : operation call_args0 + { + $$ = NEW_FCALL($1, $2); + } + | primary '.' operation call_args0 + { + value_expr($1); + $$ = NEW_CALL($1, $3, $4); + } + | SUPER call_args0 + { + if (!cur_mid && !in_single && !in_defined) + yyerror("super called outside of method"); + $$ = NEW_SUPER($2); + } + | UNDEF undef_list + { + $$ = $2; + } + mlhs : mlhs_head { - $$ = NEW_MASGN(NEW_LIST($1), Qnil); + $$ = NEW_MASGN(NEW_LIST($1), 0); } | mlhs_head STAR lhs { @@ -336,51 +350,55 @@ mlhs : mlhs_head } | mlhs_head mlhs_tail { - $$ = NEW_MASGN(list_concat(NEW_LIST($1),$2),Qnil); + $$ = NEW_MASGN(list_concat(NEW_LIST($1),$2), 0); } - | mlhs_head mlhs_tail comma STAR lhs + | mlhs_head mlhs_tail ',' STAR lhs { $$ = NEW_MASGN(list_concat(NEW_LIST($1),$2),$5); } + | STAR lhs + { + $$ = NEW_MASGN(0, $2); + } -mlhs_head : lhs comma +mlhs_head : lhs ',' mlhs_tail : lhs { $$ = NEW_LIST($1); } - | mlhs_tail comma lhs + | mlhs_tail ',' lhs { $$ = list_append($1, $3); } lhs : variable { - $$ = asignable($1, Qnil); + $$ = asignable($1, 0); } - | primary '[' opt_args opt_nl rbracket + | primary '[' opt_args opt_nl ']' { - $$ = aryset($1, $3, Qnil); + $$ = aryset($1, $3, 0); } | primary '.' IDENTIFIER { - $$ = attrset($1, $3, Qnil); + $$ = attrset($1, $3, 0); } | backref { backref_error($1); - $$ = Qnil; + $$ = 0; } cname : IDENTIFIER { - Error("class/module name must be CONSTANT"); + yyerror("class/module name must be CONSTANT"); } | CONSTANT fname : IDENTIFIER - | FID | CONSTANT + | FID | op { lex_state = EXPR_END; @@ -391,9 +409,9 @@ undef_list : fname { $$ = NEW_UNDEF($1); } - | undef_list ',' fname + | undef_list ',' {lex_state = EXPR_FNAME;} fname { - $$ = block_append($1, NEW_UNDEF($3)); + $$ = block_append($1, NEW_UNDEF($4)); } op : DOT2 { $$ = DOT2; } @@ -402,6 +420,7 @@ op : DOT2 { $$ = DOT2; } | '&' { $$ = '&'; } | CMP { $$ = CMP; } | EQ { $$ = EQ; } + | EQQ { $$ = EQQ; } | MATCH { $$ = MATCH; } | '>' { $$ = '>'; } | GEQ { $$ = GEQ; } @@ -421,13 +440,14 @@ op : DOT2 { $$ = DOT2; } | UMINUS { $$ = UPLUS; } | AREF { $$ = AREF; } | ASET { $$ = ASET; } + | '`' { $$ = '`'; } arg : variable '=' arg { value_expr($3); $$ = asignable($1, $3); } - | primary '[' opt_args opt_nl rbracket '=' arg + | primary '[' opt_args opt_nl ']' '=' arg { $$ = aryset($1, $3, $7); } @@ -439,29 +459,16 @@ arg : variable '=' arg { value_expr($3); backref_error($1); - $$ = Qnil; + $$ = 0; } | variable OP_ASGN arg { - NODE *val; - value_expr($3); - if (is_local_id($1)) { - if (local_id($1)) val = NEW_LVAR($1); - else val = NEW_DVAR($1); - } - else if (is_global_id($1)) { - val = NEW_GVAR($1); - } - else if (is_instance_id($1)) { - val = NEW_IVAR($1); - } - else { - val = NEW_CVAR($1); - } - $$ = asignable($1, call_op(val, $2, 1, $3)); + if (is_local_id($1)&&!local_id($1)&&dyna_in_block()) + dyna_var_asgn($1, TRUE); + $$ = asignable($1, call_op(gettable($1), $2, 1, $3)); } - | primary '[' opt_args opt_nl rbracket OP_ASGN arg + | primary '[' opt_args opt_nl ']' OP_ASGN arg { NODE *args = NEW_LIST($7); @@ -470,12 +477,12 @@ arg : variable '=' arg } | primary '.' IDENTIFIER OP_ASGN arg { - $$ = NEW_OP_ASGN2($1, $4, $5); + $$ = NEW_OP_ASGN2($1, $3, $4, $5); } | backref OP_ASGN arg { backref_error($1); - $$ = Qnil; + $$ = 0; } | arg DOT2 arg { @@ -553,6 +560,10 @@ arg : variable '=' arg { $$ = call_op($1, EQ, 1, $3); } + | arg EQQ arg + { + $$ = call_op($1, EQQ, 1, $3); + } | arg NEQ arg { $$ = NEW_NOT(call_op($1, EQ, 1, $3)); @@ -582,19 +593,18 @@ arg : variable '=' arg { $$ = call_op($1, RSHFT, 1, $3); } - | arg COLON2 cname - { - $$ = NEW_COLON2($1, $3); - } | arg ANDOP arg { - value_expr($1); - $$ = NEW_AND(cond($1), cond($3)); + $$ = logop(NODE_AND, $1, $3); } | arg OROP arg { - value_expr($1); - $$ = NEW_OR(cond($1), cond($3)); + $$ = logop(NODE_OR, $1, $3); + } + | DEFINED {in_defined = 1;} arg + { + in_defined = 0; + $$ = NEW_DEFINED($3); } | primary { @@ -603,25 +613,34 @@ arg : variable '=' arg call_args : /* none */ { - $$ = Qnil; + $$ = 0; } | call_args0 opt_nl call_args0 : args + | command_call + { + value_expr($1); + $$ = NEW_LIST($1); + } | assocs { $$ = NEW_LIST(NEW_HASH($1)); } - | args comma assocs + | args ',' command_call + { + $$ = list_append($1, $3); + } + | args ',' assocs { $$ = list_append($1, NEW_HASH($3)); } - | args comma assocs comma STAR arg + | args ',' assocs ',' STAR arg { $$ = list_append($1, NEW_HASH($3)); $$ = call_op($$, '+', 1, $6); } - | args comma STAR arg + | args ',' STAR arg { $$ = call_op($1, '+', 1, $4); } @@ -632,7 +651,7 @@ call_args0 : args opt_args : /* none */ { - $$ = Qnil; + $$ = 0; } | args @@ -641,7 +660,7 @@ args : arg value_expr($1); $$ = NEW_LIST($1); } - | args comma arg + | args ',' arg { value_expr($3); $$ = list_append($1, $3); @@ -649,7 +668,7 @@ args : arg args2 : args { - if ($1 && $1->nd_next == Qnil) { + if ($1 && $1->nd_next == 0) { $$ = $1->nd_head; } else { @@ -659,7 +678,7 @@ args2 : args array : /* none */ { - $$ = Qnil; + $$ = 0; } | args trailer @@ -667,85 +686,57 @@ primary : literal { $$ = NEW_LIT($1); } + | primary COLON2 cname + { + $$ = NEW_COLON2($1, $3); + } | STRING { $$ = NEW_STR($1); } - | STRING2 + | DSTRING | XSTRING { $$ = NEW_XSTR($1); } - | XSTRING2 + | DXSTRING | DREGEXP | var_ref | backref - | SUPER '(' call_args rparen + | SUPER '(' call_args ')' { if (!cur_mid && !in_single && !in_defined) - Error("super called outside of method"); + yyerror("super called outside of method"); $$ = NEW_SUPER($3); } | SUPER { if (!cur_mid && !in_single && !in_defined) - Error("super called outside of method"); + yyerror("super called outside of method"); $$ = NEW_ZSUPER(); } - | primary '[' opt_args opt_nl rbracket + | primary '[' opt_args opt_nl ']' { value_expr($1); $$ = NEW_CALL($1, AREF, $3); } - | LBRACK array rbracket + | LBRACK array ']' { - if ($2 == Qnil) + if ($2 == 0) $$ = NEW_ZARRAY(); /* zero length array*/ else { $$ = $2; } } - | LBRACE assoc_list rbrace + | LBRACE assoc_list '}' { $$ = NEW_HASH($2); } - | REDO - { - $$ = NEW_REDO(); - } - | BREAK - { - $$ = NEW_BREAK(); - } - | CONTINUE - { - $$ = NEW_CONT(); - } - | RETRY - { - $$ = NEW_RETRY(); - } | RETURN { if (!cur_mid && !in_single) - Error("return appeared outside of method"); - $$ = NEW_RET(Qnil); - } - | FAIL '(' args2 ')' - { - if (nd_type($3) == NODE_ARRAY) { - Error("wrong number of argument to fail(0 or 1)"); - } - value_expr($3); - $$ = NEW_FAIL($3); - } - | FAIL '(' ')' - { - $$ = NEW_FAIL(Qnil); - } - | FAIL - { - $$ = NEW_FAIL(Qnil); + yyerror("return appeared outside of method"); + $$ = NEW_RET(0); } | YIELD '(' args2 ')' { @@ -754,48 +745,31 @@ primary : literal } | YIELD '(' ')' { - $$ = NEW_YIELD(Qnil); + $$ = NEW_YIELD(0); } | YIELD { - $$ = NEW_YIELD(Qnil); - } - | DEFINED '(' {in_defined = 1;} arg ')' + $$ = NEW_YIELD(0); + } + | DEFINED '(' {in_defined = 1;} expr ')' { in_defined = 0; $$ = NEW_DEFINED($4); } - | primary '{' - { - $<vars>$ = dyna_push(); - } - opt_iter_var - compexpr rbrace - { - if (nd_type($1) == NODE_LVAR - || nd_type($1) == NODE_CVAR) { - $1 = NEW_FCALL($1->nd_vid, Qnil); - } - $$ = NEW_ITER($4, $1, $5); - dyna_pop($<vars>3); - } | FID { - $$ = NEW_FCALL($1, Qnil); - } - | operation '(' call_args rparen - { - $$ = NEW_FCALL($1, $3); + $$ = NEW_FCALL($1, 0); } - | primary '.' operation '(' call_args rparen + | operation iter_block { - value_expr($1); - $$ = NEW_CALL($1, $3, $5); + $2->nd_iter = NEW_FCALL($1, 0); + $$ = $2; } - | primary '.' operation + | method_call + | method_call iter_block { - value_expr($1); - $$ = NEW_CALL($1, $3, Qnil); + $2->nd_iter = $1; + $$ = $2; } | IF expr then compexpr @@ -805,10 +779,23 @@ primary : literal value_expr($2); $$ = NEW_IF(cond($2), $4, $5); } + | UNLESS expr then + compexpr + opt_else + END + { + value_expr($2); + $$ = NEW_UNLESS(cond($2), $4, $5); + } | WHILE expr term compexpr END { value_expr($2); - $$ = NEW_WHILE(cond($2), $4); + $$ = NEW_WHILE(cond($2), $4, 1); + } + | UNTIL expr term compexpr END + { + value_expr($2); + $$ = NEW_UNTIL(cond($2), $4, 1); } | CASE compexpr case_body @@ -828,16 +815,22 @@ primary : literal ensure END { - $$ = NEW_BEGIN($2, $3, $4); + if (!$3 && !$4) + $$ = NEW_BEGIN($2); + else { + if ($3) $2 = NEW_RESCUE($2, $3); + if ($4) $2 = NEW_ENSURE($2, $4); + $$ = $2; + } } - | LPAREN exprs opt_nl rparen + | LPAREN compexpr ')' { $$ = $2; } | CLASS cname superclass { if (cur_mid || in_single) - Error("class definition in method body"); + yyerror("class definition in method body"); class_nest++; cref_push(); @@ -854,7 +847,7 @@ primary : literal | MODULE cname { if (cur_mid || in_single) - Error("module definition in method body"); + yyerror("module definition in method body"); class_nest++; cref_push(); local_push(); @@ -870,7 +863,7 @@ primary : literal | DEF fname { if (cur_mid || in_single) - Error("nested method definition"); + yyerror("nested method definition"); cur_mid = $2; local_push(); } @@ -882,7 +875,7 @@ primary : literal local_pop(); cur_mid = 0; } - | DEF singleton '.' fname + | DEF singleton '.' {lex_state = EXPR_FNAME;} fname { value_expr($2); in_single++; @@ -893,7 +886,7 @@ primary : literal compexpr END { - $$ = NEW_DEFS($2, $4, $6, $7); + $$ = NEW_DEFS($2, $5, $7, $8); local_pop(); in_single--; } @@ -913,7 +906,7 @@ if_tail : opt_else opt_else : /* none */ { - $$ = Qnil; + $$ = 0; } | ELSE compexpr { @@ -925,21 +918,79 @@ iter_var : lhs opt_iter_var : /* node */ { - $$ = Qnil; + $$ = 0; } | '|' /* none */ '|' { - $$ = Qnil; + $$ = 0; } | OROP { - $$ = Qnil; + $$ = 0; } | '|' iter_var '|' { $$ = $2; } +iter_do_block : DO + { + $<vars>$ = dyna_push(); + } + opt_iter_var + compexpr + END + { + $$ = NEW_ITER($3, 0, $4); + dyna_pop($<vars>2); + } + +iter_block : '{' + { + $<vars>$ = dyna_push(); + } + opt_iter_var + compexpr '}' + { + $$ = NEW_ITER($3, 0, $4); + dyna_pop($<vars>2); + } + +iterator : IDENTIFIER + { + $$ = NEW_FCALL($1, 0); + } + | CONSTANT + { + $$ = NEW_FCALL($1, 0); + } + | FID + { + $$ = NEW_FCALL($1, 0); + } + | method_call + | command_call + +method_call : operation '(' call_args ')' + { + $$ = NEW_FCALL($1, $3); + } + | primary '.' operation '(' call_args ')' + { + value_expr($1); + $$ = NEW_CALL($1, $3, $5); + } + | primary '.' operation + { + value_expr($1); + $$ = NEW_CALL($1, $3, 0); + } + | primary COLON2 operation '(' call_args ')' + { + value_expr($1); + $$ = NEW_CALL($1, $3, $5); + } + case_body : WHEN args then compexpr cases @@ -950,21 +1001,19 @@ case_body : WHEN args then cases : opt_else | case_body -rescue : /* none */ +rescue : RESCUE opt_args term compexpr + rescue { - $$ = Qnil; + $$ = NEW_RESBODY($2, $4, $5); } - | RESCUE compexpr + | /* none */ { - if ($2 == Qnil) - $$ = (NODE*)1; - else - $$ = $2; + $$ = 0; } ensure : /* none */ { - $$ = Qnil; + $$ = 0; } | ENSURE compexpr { @@ -972,9 +1021,9 @@ ensure : /* none */ } literal : numeric - | SYMBEG symbol + | SYMBEG {lex_state = EXPR_FNAME;} symbol { - $$ = INT2FIX($2); + $$ = INT2FIX($3); } | REGEXP @@ -1008,9 +1057,9 @@ backref : NTH_REF superclass : term { - $$ = Qnil; + $$ = 0; } - | colon + | '<' { lex_state = EXPR_BEG; } @@ -1018,10 +1067,12 @@ superclass : term { $$ = $3; } + | error term {yyerrok;} -f_arglist : '(' f_args rparen +f_arglist : '(' f_args ')' { $$ = $2; + lex_state = EXPR_BEG; } | f_args term { @@ -1036,15 +1087,15 @@ f_args : /* no arg */ { $$ = NEW_ARGS($1, 0, -1); } - | f_arg comma rest_arg + | f_arg ',' rest_arg { $$ = NEW_ARGS($1, 0, $3); } - | f_arg comma f_optarg + | f_arg ',' f_optarg { $$ = NEW_ARGS($1, $3, -1); } - | f_arg comma f_optarg comma rest_arg + | f_arg ',' f_optarg ',' rest_arg { $$ = NEW_ARGS($1, $3, $5); } @@ -1052,7 +1103,7 @@ f_args : /* no arg */ { $$ = NEW_ARGS(0, $1, -1); } - | f_optarg comma rest_arg + | f_optarg ',' rest_arg { $$ = NEW_ARGS(0, $1, $3); } @@ -1060,23 +1111,18 @@ f_args : /* no arg */ { $$ = NEW_ARGS(0, 0, $1); } - | error - { - lex_state = EXPR_BEG; - $$ = NEW_ARGS(0, 0, -1); - } f_arg : IDENTIFIER { if (!is_local_id($1)) - Error("formal argument must be local variable"); + yyerror("formal argument must be local variable"); local_cnt($1); $$ = 1; } - | f_arg comma IDENTIFIER + | f_arg ',' IDENTIFIER { if (!is_local_id($3)) - Error("formal argument must be local variable"); + yyerror("formal argument must be local variable"); local_cnt($3); $$ += 1; } @@ -1084,7 +1130,7 @@ f_arg : IDENTIFIER f_opt : IDENTIFIER '=' arg { if (!is_local_id($1)) - Error("formal argument must be local variable"); + yyerror("formal argument must be local variable"); $$ = asignable($1, $3); } @@ -1092,7 +1138,7 @@ f_optarg : f_opt { $$ = NEW_BLOCK($1); } - | f_optarg comma f_opt + | f_optarg ',' f_opt { $$ = block_append($1, $3); } @@ -1100,7 +1146,7 @@ f_optarg : f_opt rest_arg : STAR IDENTIFIER { if (!is_local_id($2)) - Error("rest argument must be local variable"); + yyerror("rest argument must be local variable"); $$ = local_cnt($2); } @@ -1110,25 +1156,25 @@ singleton : var_ref $$ = NEW_SELF(); } else if (nd_type($1) == NODE_NIL) { - Error("Can't define single method for nil."); - $$ = Qnil; + yyerror("Can't define single method for nil."); + $$ = 0; } else { $$ = $1; } } - | LPAREN expr opt_nl rparen + | LPAREN expr opt_nl ')' { switch (nd_type($2)) { case NODE_STR: - case NODE_STR2: + case NODE_DSTR: case NODE_XSTR: - case NODE_XSTR2: + case NODE_DXSTR: case NODE_DREGX: case NODE_LIT: case NODE_ARRAY: case NODE_ZARRAY: - Error("Can't define single method for literals."); + yyerror("Can't define single method for literals."); default: break; } @@ -1137,7 +1183,7 @@ singleton : var_ref assoc_list : /* none */ { - $$ = Qnil; + $$ = 0; } | assocs trailer { @@ -1146,13 +1192,13 @@ assoc_list : /* none */ | args trailer { if ($1->nd_alen%2 != 0) { - Error("odd number list for Hash"); + yyerror("odd number list for Hash"); } $$ = $1; } assocs : assoc - | assocs comma assoc + | assocs ',' assoc { $$ = list_concat($1, $3); } @@ -1163,32 +1209,24 @@ assoc : arg ASSOC arg } operation : IDENTIFIER + | CONSTANT | FID -opt_term : /* none */ - | term +opt_terms : /* none */ + | terms opt_nl : /* none */ - | nl + | '\n' trailer : /* none */ - | nl - | comma - -term : sc - | nl + | '\n' + | ',' -sc : ';' { yyerrok; } -nl : '\n' { yyerrok; } - -colon : ':' - | SYMBEG - -rparen : ')' { yyerrok; } -rbracket : ']' { yyerrok; } -rbrace : '}' { yyerrok; } -comma : ',' { yyerrok; } +term : ';' {yyerrok;} + | '\n' +terms : term + | terms ';' {yyerrok;} %% #include <ctype.h> #include <sys/types.h> @@ -1206,51 +1244,138 @@ VALUE newfloat(); VALUE newinteger(); char *strdup(); -static NODE *var_extend(); +static NODE *str_extend(); #define LEAVE_BS 1 +static VALUE lex_input; /* non-nil if File */ +static char *lex_pbeg; static char *lex_p; -static int lex_len; +static char *lex_pend; -void -lex_setsrc(src, ptr, len) - char *src; - char *ptr; +static int +yyerror(msg) + char *msg; +{ + char *p, *pe, *buf; + int len, i; + + Error("%s", msg); + p = lex_p; + while (lex_pbeg <= p) { + if (*p == '\n') break; + p--; + } + p++; + + pe = lex_p; + while (pe < lex_pend) { + if (*pe == '\n') break; + pe++; + } + + len = pe - p; + if (len > 4) { + buf = ALLOCA_N(char, len+2); + MEMCPY(buf, p, char, len); + buf[len] = '\0'; + Error_Append("%s", buf); + + i = lex_p - p; + p = buf; pe = p + len; + + while (p < pe) { + if (*p != '\t') *p = ' '; + p++; + } + buf[i] = '^'; + buf[i+1] = '\0'; + Error_Append("%s", buf); + } + + return 0; +} + +static int newline_seen; + +static NODE* +yycompile(f) + char *f; +{ + int n; + + newline_seen = 0; + sourcefile = strdup(f); + eval_tree = 0; + n = yyparse(); + if (n == 0) return eval_tree; + + return 0; +} + +NODE* +compile_string(f, s, len) + char *f, *s; int len; { - sourcefile = strdup(src); + lex_pbeg = lex_p = s; + lex_pend = s + len; + lex_input = 0; + if (!sourcefile || strcmp(f, sourcefile)) /* not in eval() */ + sourceline = 1; - sourceline = 1; - lex_p = ptr; - lex_len = len; + return yycompile(f); } -#define nextc() ((--lex_len>=0)?(*lex_p++):-1) -#define pushback() (lex_len++, lex_p--) - -#define SCAN_HEX(i) \ -do { \ - int numlen; \ - i=scan_hex(lex_p, 2, &numlen); \ - lex_p += numlen; \ - lex_len -= numlen; \ -} while (0) - -#define SCAN_OCT(i) \ -do { \ - int numlen; \ - i=scan_oct(lex_p, 3, &numlen); \ - lex_p += numlen; \ - lex_len -= numlen; \ -} while (0) +NODE* +compile_file(f, file, start) + char *f; + VALUE file; + int start; +{ + lex_input = file; + lex_pbeg = lex_p = lex_pend = 0; + sourceline = start; + + return yycompile(f); +} + +int +nextc() +{ + int c; + + if (lex_p == lex_pend) { + if (lex_input) { + VALUE v = io_gets(lex_input); + + if (NIL_P(v)) return -1; + lex_pbeg = lex_p = RSTRING(v)->ptr; + lex_pend = lex_p + RSTRING(v)->len; + } + else { + return -1; + } + } + c = *lex_p++; + + return c; +} + +void +pushback(c) + int c; +{ + if (c == -1) return; + lex_p--; +} #define tokfix() (tokenbuf[tokidx]='\0') #define tok() tokenbuf #define toklen() tokidx #define toklast() (tokidx>0?tokenbuf[tokidx-1]:0) -char * +char* newtok() { tokidx = 0; @@ -1307,12 +1432,38 @@ read_escape() case '0': case '1': case '2': case '3': /* octal constant */ case '4': case '5': case '6': case '7': - pushback(); - SCAN_OCT(c); + pushback(c); + { + char buf[3]; + int i; + + for (i=0; i<3; i++) { + buf[i] = nextc(); + if (buf[i] == -1) goto eof; + if (buf[i] < '0' || '7' < buf[i]) { + pushback(buf[i]); + break; + } + } + c = scan_oct(buf, i+1, &i); + } return c; case 'x': /* hex constant */ - SCAN_HEX(c); + { + char buf[2]; + int i; + + for (i=0; i<2; i++) { + buf[i] = nextc(); + if (buf[i] == -1) goto eof; + if (!isxdigit(buf[i])) { + pushback(buf[i]); + break; + } + } + c = scan_hex(buf, i+1, &i); + } return c; case 'b': /* backspace */ @@ -1320,7 +1471,8 @@ read_escape() case 'M': if ((c = nextc()) != '-') { - Error("Invalid escape character syntax"); + yyerror("Invalid escape character syntax"); + pushback(c); return '\0'; } if ((c = nextc()) == '\\') { @@ -1333,7 +1485,8 @@ read_escape() case 'C': if ((c = nextc()) != '-') { - Error("Invalid escape character syntax"); + yyerror("Invalid escape character syntax"); + pushback(c); return '\0'; } case 'c': @@ -1348,8 +1501,7 @@ read_escape() eof: case -1: - Error("Invalid escape character syntax"); - pushback(); + yyerror("Invalid escape character syntax"); return '\0'; default: @@ -1358,16 +1510,23 @@ read_escape() } static int -parse_regx() +parse_regx(term) + int term; { register int c; int casefold = 0; int in_brack = 0; int re_start = sourceline; - NODE *list = Qnil; + int once = 0; + int quote = 0; + NODE *list = 0; newtok(); while ((c = nextc()) != -1) { + if (!in_brack && c == term) { + goto regx_end; + } + switch (c) { case '[': in_brack = 1; @@ -1377,7 +1536,7 @@ parse_regx() break; case '#': - list = var_extend(list, '/'); + list = str_extend(list, term); if (list == (NODE*)-1) return 0; continue; @@ -1405,6 +1564,11 @@ parse_regx() tokadd(c); break; + case '^': /* no \^ escape in regexp */ + tokadd('\\'); + tokadd('^'); + break; + case 'b': if (!in_brack) { tokadd('\\'); @@ -1413,22 +1577,44 @@ parse_regx() } /* fall through */ default: - pushback(); - tokadd('\\'); - tokadd(read_escape()); + if (c == '\n') { + sourceline++; + } + else if (c == term) { + tokadd(c); + } + else { + pushback(c); + tokadd('\\'); + tokadd(read_escape()); + } } continue; - case '/': /* end of the regexp */ - if (in_brack) - break; + case -1: + Error("unterminated regexp"); + return 0; - if ('i' == nextc()) { - casefold = 1; + default: + if (ismbchar(c)) { + tokadd(c); + c = nextc(); } - else { - casefold = 0; - pushback(); + break; + + regx_end: + for (;;) { + c = nextc(); + if (c == 'i') { + casefold = 1; + } + else if (c == 'o') { + once = 1; + } + else { + pushback(c); + break; + } } tokfix(); @@ -1438,8 +1624,8 @@ parse_regx() VALUE ss = str_new(tok(), toklen()); list_append(list, NEW_STR(ss)); } - nd_set_type(list, NODE_DREGX); - if (casefold) list->nd_cflag = 1; + nd_set_type(list, once?NODE_DREGX_ONCE:NODE_DREGX); + list->nd_cflag = casefold; yylval.node = list; return DREGEXP; } @@ -1447,16 +1633,6 @@ parse_regx() yylval.val = reg_new(tok(), toklen(), casefold); return REGEXP; } - case -1: - Error("unterminated regexp"); - return 0; - - default: - if (ismbchar(c)) { - tokadd(c); - c = nextc(); - } - break; } tokadd(c); } @@ -1465,16 +1641,18 @@ parse_regx() } static int -parse_string(term) - int term; +parse_string(func,term) + int func, term; { int c; - NODE *list = Qnil; + NODE *list = 0; int strstart; strstart = sourceline; newtok(); + while ((c = nextc()) != term) { + str_retry: if (c == -1) { unterm_str: sourceline = strstart; @@ -1489,7 +1667,7 @@ parse_string(term) sourceline++; } else if (c == '#') { - list = var_extend(list, term); + list = str_extend(list, term); if (list == (NODE*)-1) goto unterm_str; continue; } @@ -1502,34 +1680,89 @@ parse_string(term) tokadd(c); } else { - pushback(); - if (term != '"') tokadd('\\'); + pushback(c); + if (func != '"') tokadd('\\'); tokadd(read_escape()); } continue; } tokadd(c); } + tokfix(); lex_state = EXPR_END; - if (list == Qnil) { - yylval.val = str_new(tok(), toklen()); - return (term == '`') ? XSTRING : STRING; - } - else { + if (list) { if (toklen() > 0) { VALUE ss = str_new(tok(), toklen()); list_append(list, NEW_STR(ss)); } yylval.node = list; - if (term == '`') { - nd_set_type(list, NODE_XSTR2); - return XSTRING2; + if (func == '`') { + nd_set_type(list, NODE_DXSTR); + return DXSTRING; } else { - return STRING2; + return DSTRING; } } + else { + yylval.val = str_new(tok(), toklen()); + return (func == '`') ? XSTRING : STRING; + } +} + +static int +parse_qstring(term) + int term; +{ + int quote = 0; + int strstart; + int c; + + strstart = sourceline; + newtok(); + while ((c = nextc()) != term) { + qstr_retry: + if (c == -1) { + sourceline = strstart; + Error("unterminated string meets end of file"); + return 0; + } + if (ismbchar(c)) { + tokadd(c); + c = nextc(); + } + else if (c == '\n') { + sourceline++; + } + else if (c == '\\') { + c = nextc(); + switch (c) { + case '\n': + sourceline++; + continue; + + case '\\': + c = '\\'; + break; + + case '\'': + if (term == '\'') { + c = '\''; + break; + } + /* fall through */ + default: + tokadd('\\'); + } + } + tokadd(c); + } + + tokfix(); + yylval.val = str_new(tok(), toklen()); + lex_state = EXPR_END; + return STRING; } #define LAST(v) ((v)-1 + sizeof(v)/sizeof(v[0])) @@ -1540,22 +1773,18 @@ static struct kwtable { enum lex_state state; } kwtable [] = { "__END__", 0, EXPR_BEG, - "__FILE__", _FILE_, EXPR_END, - "__LINE__", _LINE_, EXPR_END, "alias", ALIAS, EXPR_FNAME, "and", AND, EXPR_BEG, "begin", BEGIN, EXPR_BEG, - "break", BREAK, EXPR_END, "case", CASE, EXPR_BEG, "class", CLASS, EXPR_BEG, - "continue", CONTINUE, EXPR_END, "def", DEF, EXPR_FNAME, "defined?", DEFINED, EXPR_END, + "do", DO, EXPR_BEG, "else", ELSE, EXPR_BEG, "elsif", ELSIF, EXPR_BEG, "end", END, EXPR_END, "ensure", ENSURE, EXPR_BEG, - "fail", FAIL, EXPR_END, "for", FOR, EXPR_BEG, "if", IF, EXPR_BEG, "in", IN, EXPR_BEG, @@ -1563,14 +1792,14 @@ static struct kwtable { "nil", NIL, EXPR_END, "not", NOT, EXPR_BEG, "or", OR, EXPR_BEG, - "redo", REDO, EXPR_END, - "rescue", RESCUE, EXPR_BEG, - "retry", RETRY, EXPR_END, + "rescue", RESCUE, EXPR_MID, "return", RETURN, EXPR_MID, "self", SELF, EXPR_END, "super", SUPER, EXPR_END, "then", THEN, EXPR_BEG, "undef", UNDEF, EXPR_FNAME, + "unless", UNLESS, EXPR_BEG, + "until", UNTIL, EXPR_BEG, "when", WHEN, EXPR_BEG, "while", WHILE, EXPR_BEG, "yield", YIELD, EXPR_END, @@ -1589,6 +1818,11 @@ yylex() int space_seen = 0; struct kwtable *low = kwtable, *mid, *high = LAST(kwtable); + if (newline_seen) { + sourceline++; + newline_seen = 0; + } + retry: switch (c = nextc()) { case '\0': /* NUL */ @@ -1614,10 +1848,11 @@ retry: } /* fall through */ case '\n': - sourceline++; - if (lex_state == EXPR_BEG - || lex_state == EXPR_FNAME) + if (lex_state == EXPR_BEG || lex_state == EXPR_FNAME) { + sourceline++; goto retry; + } + newline_seen++; lex_state = EXPR_BEG; return '\n'; @@ -1628,7 +1863,7 @@ retry: yylval.id = POW; return OP_ASGN; } - pushback(); + pushback(c); return POW; } if (c == '=') { @@ -1636,7 +1871,7 @@ retry: lex_state = EXPR_BEG; return OP_ASGN; } - pushback(); + pushback(c); if (lex_state == EXPR_ARG && space_seen && !isspace(c)){ arg_ambiguous(); lex_state = EXPR_BEG; @@ -1656,12 +1891,16 @@ retry: if (c == '~') { return NMATCH; } - pushback(); + pushback(c); return '!'; case '=': lex_state = EXPR_BEG; if ((c = nextc()) == '=') { + if ((c = nextc()) == '=') { + return EQQ; + } + pushback(c); return EQ; } if (c == '~') { @@ -1670,7 +1909,7 @@ retry: else if (c == '>') { return ASSOC; } - pushback(); + pushback(c); return '='; case '<': @@ -1679,7 +1918,7 @@ retry: if ((c = nextc()) == '>') { return CMP; } - pushback(); + pushback(c); return LEQ; } if (c == '<') { @@ -1687,10 +1926,10 @@ retry: yylval.id = LSHFT; return OP_ASGN; } - pushback(); + pushback(c); return LSHFT; } - pushback(); + pushback(c); return '<'; case '>': @@ -1699,64 +1938,24 @@ retry: return GEQ; } if (c == '>') { - if (nextc() == '=') { + if ((c = nextc()) == '=') { yylval.id = RSHFT; return OP_ASGN; } - pushback(); + pushback(c); return RSHFT; } - pushback(); + pushback(c); return '>'; case '"': + return parse_string(c,c); case '`': - return parse_string(c); + if (lex_state == EXPR_FNAME) return c; + return parse_string(c,c); case '\'': - { - int strstart; - - strstart = sourceline; - newtok(); - while ((c = nextc()) != '\'') { - if (c == -1) { - sourceline = strstart; - Error("unterminated string meets end of file"); - return 0; - } - if (ismbchar(c)) { - tokadd(c); - c = nextc(); - } - else if (c == '\n') { - sourceline++; - } - else if (c == '\\') { - c = nextc(); - switch (c) { - case '\n': - sourceline++; - continue; - - case '\'': - c = '\''; - break; - case '\\': - c = '\\'; - break; - - default: - tokadd('\\'); - } - } - tokadd(c); - } - tokfix(); - yylval.val = str_new(tok(), toklen()); - lex_state = EXPR_END; - return STRING; - } + return parse_qstring(c); case '?': if ((c = nextc()) == '\\') { @@ -1776,7 +1975,7 @@ retry: yylval.id = '&'; return OP_ASGN; } - pushback(); + pushback(c); return '&'; case '|': @@ -1788,7 +1987,7 @@ retry: yylval.id = '|'; return OP_ASGN; } - pushback(); + pushback(c); return '|'; case '+': @@ -1797,29 +1996,32 @@ retry: if (c == '@') { return UPLUS; } - pushback(); + pushback(c); return '+'; } + if (c == '=') { + lex_state = EXPR_BEG; + yylval.id = '+'; + return OP_ASGN; + } if (lex_state == EXPR_ARG) { - if (!space_seen || c == '=' || isspace(c)) { + if (space_seen && !isspace(c)) { arg_ambiguous(); + } + else { lex_state = EXPR_END; } } if (lex_state != EXPR_END) { - pushback(); - if (isdigit(c)) { + if (isdigit(c)) { goto start_num; } + pushback(c); lex_state = EXPR_BEG; return UPLUS; } lex_state = EXPR_BEG; - if (c == '=') { - yylval.id = '+'; - return OP_ASGN; - } - pushback(); + pushback(c); return '+'; case '-': @@ -1828,31 +2030,34 @@ retry: if (c == '@') { return UMINUS; } - pushback(); + pushback(c); return '-'; } + if (c == '=') { + lex_state = EXPR_BEG; + yylval.id = '-'; + return OP_ASGN; + } if (lex_state == EXPR_ARG) { - if (!space_seen || c == '=' || isspace(c)) { + if (space_seen && !isspace(c)) { arg_ambiguous(); + } + else { lex_state = EXPR_END; } } if (lex_state != EXPR_END) { if (isdigit(c)) { - pushback(); + pushback(c); c = '-'; goto start_num; } lex_state = EXPR_BEG; - pushback(); + pushback(c); return UMINUS; } lex_state = EXPR_BEG; - if (c == '=') { - yylval.id = '-'; - return OP_ASGN; - } - pushback(); + pushback(c); return '-'; case '.': @@ -1861,10 +2066,10 @@ retry: if ((c = nextc()) == '.') { return DOT3; } - pushback(); + pushback(c); return DOT2; } - pushback(); + pushback(c); if (!isdigit(c)) { return '.'; } @@ -1877,6 +2082,7 @@ retry: { int is_float, seen_point, seen_e; + is_float = seen_point = seen_e = 0; lex_state = EXPR_END; newtok(); if (c == '0') { @@ -1887,30 +2093,39 @@ retry: if (!isxdigit(c)) break; tokadd(c); } - pushback(); + pushback(c); tokfix(); yylval.val = str2inum(tok(), 16); return INTEGER; } - else if (c >= '0' && c <= '9') { + else if (c >= '0' && c <= '7') { /* octal */ do { tokadd(c); c = nextc(); } while (c >= '0' && c <= '9'); - pushback(); + pushback(c); tokfix(); yylval.val = str2inum(tok(), 8); return INTEGER; } + else if (c > '7' && c <= '9') { + Error("Illegal octal digit"); + } + else if (c == '.') { + tokadd('0'); + } + else { + pushback(c); + yylval.val = INT2FIX(0); + return INTEGER; + } } if (c == '-' || c == '+') { tokadd(c); c = nextc(); } - is_float = seen_point = seen_e = 0; - for (;;) { switch (c) { case '0': case '1': case '2': case '3': case '4': @@ -1922,10 +2137,13 @@ retry: if (seen_point) { goto decode_num; } - c = nextc(); - if (!isdigit(c)) { - pushback(); - goto decode_num; + else { + int c0 = nextc(); + if (!isdigit(c0)) { + pushback(c0); + goto decode_num; + } + c = c0; } tokadd('.'); tokadd(c); @@ -1957,7 +2175,7 @@ retry: } decode_num: - pushback(); + pushback(c); tokfix(); if (is_float) { double atof(); @@ -1981,30 +2199,29 @@ retry: lex_state = EXPR_BEG; return COLON2; } - pushback(); + pushback(c); if (isspace(c)) return ':'; return SYMBEG; case '/': - if (lex_state == EXPR_BEG - || lex_state == EXPR_MID) { - return parse_regx(); + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + return parse_regx('/'); + } + if ((c = nextc()) == '=') { + lex_state = EXPR_BEG; + yylval.id = '/'; + return OP_ASGN; } - c = nextc(); if (lex_state == EXPR_ARG) { - if (space_seen && c != '=' && !isspace(c)) { - pushback(); + if (space_seen && !isspace(c)) { + pushback(c); arg_ambiguous(); - return parse_regx(); + return parse_regx('/'); } } lex_state = EXPR_BEG; - if (c == '=') { - yylval.id = '/'; - return OP_ASGN; - } - pushback(); + pushback(c); return '/'; case '^': @@ -2013,7 +2230,7 @@ retry: yylval.id = '^'; return OP_ASGN; } - pushback(); + pushback(c); return c; case ',': @@ -2027,15 +2244,14 @@ retry: case '~': if (lex_state == EXPR_FNAME) { if ((c = nextc()) != '@') { - pushback(); + pushback(c); } } lex_state = EXPR_BEG; return c; case '(': - if (lex_state == EXPR_BEG - || lex_state == EXPR_MID) { + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { c = LPAREN; lex_state = EXPR_BEG; } @@ -2055,14 +2271,13 @@ retry: if ((c = nextc()) == '=') { return ASET; } - pushback(); + pushback(c); return AREF; } - pushback(); + pushback(c); return '['; } - else if (lex_state == EXPR_BEG - || lex_state == EXPR_MID) { + else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { c = LBRACK; } else if (lex_state == EXPR_ARG && space_seen) { @@ -2085,25 +2300,71 @@ retry: space_seen = 1; goto retry; /* skip \\n */ } - pushback(); + pushback(c); return '\\'; case '%': - lex_state = EXPR_BEG; - if (nextc() == '=') { + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + int term; + + c = nextc(); + quotation: + if (!isalnum(c)) { + term = c; + c = '"'; + } + else { + term = nextc(); + } + if (c == -1 || term == -1) { + Error("unterminated quoted string meets end of file"); + return 0; + } + if (term == '(') term = ')'; + else if (term == '[') term = ']'; + else if (term == '{') term = '}'; + else if (term == '<') term = '>'; + + switch (c) { + case 'Q': + return parse_string('"', term); + + case 'q': + return parse_qstring(term); + + case 'x': + return parse_string('`', term); + + case 'r': + return parse_regx(term); + + default: + Error("unknown type of string `%c'", c); + return 0; + } + } + if ((c = nextc()) == '=') { yylval.id = '%'; return OP_ASGN; } - pushback(); - return c; + if (lex_state == EXPR_ARG) { + if (space_seen && !isspace(c)) { + arg_ambiguous(); + goto quotation; + } + } + lex_state = EXPR_BEG; + pushback(c); + return '%'; case '$': lex_state = EXPR_END; newtok(); c = nextc(); switch (c) { + case '_': /* $_: last read line string */ case '~': /* $~: match-data */ - local_cnt('~'); + local_cnt(c); /* fall through */ case '*': /* $*: argv */ case '$': /* $$: pid */ @@ -2112,9 +2373,9 @@ retry: case '@': /* $@: error position */ case '/': /* $/: input record separator */ case '\\': /* $\: output record separator */ + case ';': /* $;: field separator */ case ',': /* $,: output field separator */ case '.': /* $.: last read line number */ - case '_': /* $_: last read line string */ case '=': /* $=: ignorecase */ case ':': /* $:: load path */ case '<': /* $<: reading filename */ @@ -2140,14 +2401,14 @@ retry: tokadd(c); c = nextc(); } - pushback(); + pushback(c); tokfix(); yylval.node = NEW_NTH_REF(atoi(tok())); return NTH_REF; default: if (!is_identchar(c)) { - pushback(); + pushback(c); return '$'; } case '0': @@ -2158,7 +2419,7 @@ retry: case '@': c = nextc(); if (!is_identchar(c)) { - pushback(); + pushback(c); return '@'; } newtok(); @@ -2187,7 +2448,7 @@ retry: tokadd(c); } else { - pushback(); + pushback(c); } tokfix(); @@ -2213,7 +2474,9 @@ retry: if (state != EXPR_BEG && state != EXPR_BEG) { if (mid->id == IF) return IF_MOD; + if (mid->id == UNLESS) return UNLESS_MOD; if (mid->id == WHILE) return WHILE_MOD; + if (mid->id == UNTIL) return UNTIL_MOD; } return mid->id; } @@ -2231,7 +2494,7 @@ retry: tokadd(c); } else { - pushback(); + pushback(c); } } else if (lex_state == EXPR_BEG){ @@ -2255,68 +2518,43 @@ retry: } static NODE* -var_extend(list, term) +str_extend(list, term) NODE *list; char term; { - int c, t, brace; + int c; VALUE ss; NODE *node; ID id; + int nest; c = nextc(); switch (c) { case '$': + case '@': case '{': break; - case '@': - t = nextc(); - pushback(); - if (!is_identchar(t)) { - tokadd('#'); - tokadd(c); - return list; - } default: tokadd('#'); - pushback(); + pushback(c); return list; } ss = str_new(tok(), toklen()); - if (list == Qnil) { - list = NEW_STR2(ss); + if (list == 0) { + list = NEW_DSTR(ss); } else if (toklen() > 0) { list_append(list, NEW_STR(ss)); } newtok(); - if (c == '{') { - brace = 1; - c = nextc(); - } - else { - brace = 0; - } switch (c) { case '$': + tokadd('$'); c = nextc(); if (c == -1) return (NODE*)-1; switch (c) { - case '&': - case '`': - case '\'': - case '+': - node = NEW_BACK_REF(c); - c = nextc(); - goto append_node; - - case '~': - local_cnt('~'); - id = '~'; - goto id_node; - case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -2324,55 +2562,108 @@ var_extend(list, term) tokadd(c); c = nextc(); } - tokfix(); - node = NEW_NTH_REF(atoi(tok())); - goto append_node; - } + pushback(c); + goto fetch_id; - tokadd('$'); - if (!is_identchar(c)) { + case '&': case '+': + case '_': case '~': + case '*': case '$': case '?': + case '!': case '@': case ',': + case '.': case '=': case ':': + case '<': case '>': case '\\': + refetch: tokadd(c); goto fetch_id; + + default: + if (c == term) { + list_append(list, NEW_STR(str_new2("#$"))); + pushback(c); + return list; + } + switch (c) { + case '\"': + case '/': + case '\'': + case '`': + goto refetch; + } + if (!is_identchar(c)) { + yyerror("bad global variable in string"); + newtok(); + return list; + } } /* through */ - case '@': + + case '@': tokadd(c); c = nextc(); - break; - } - while (is_identchar(c)) { - tokadd(c); - if (ismbchar(c)) { - c = nextc(); + while (is_identchar(c)) { tokadd(c); + if (ismbchar(c)) { + c = nextc(); + tokadd(c); + } + c = nextc(); } - c = nextc(); + pushback(c); + break; + + case '{': + nest = 0; + do { + loop_again: + c = nextc(); + switch (c) { + case -1: + if (nest > 0) { + bad_sub: + Error("bad substitution in string"); + newtok(); + return list; + } + return (NODE*)-1; + case '}': + if (nest == 0) break; + nest--; + tokadd(c); + goto loop_again; + case '\\': + c = read_escape(); + tokadd(c); + goto loop_again; + case '{': + nest++; + case '\"': + case '/': + case '`': + if (c == term) { + pushback(c); + list_append(list, NEW_STR(str_new2("#"))); + Warning("bad substitution in string"); + tokfix(); + list_append(list, NEW_STR(str_new(tok(), toklen()))); + newtok(); + return list; + } + add_char: + default: + tokadd(c); + break; + } + } while (c != '}'); } fetch_id: tokfix(); - if (strcmp("__LINE__", tok()) == 0) - id = _LINE_; - else if (strcmp("__FILE__", tok()) == 0) - id = _FILE_; - else - id = rb_intern(tok()); - id_node: - node = gettable(id); - - append_node: - if (brace) { - if (c != '}') - Error("Invalid variable name in string"); - } - else pushback(); - + node = NEW_EVSTR(tok(),toklen()); list_append(list, node); newtok(); + return list; } - NODE* newnode(type, a0, a1, a2) enum node_type type; @@ -2382,7 +2673,7 @@ newnode(type, a0, a1, a2) n->flags |= T_NODE; nd_set_type(n, type); - n->line = sourceline; + nd_set_line(n, sourceline); n->file = sourcefile; n->u1.node = a0; @@ -2406,8 +2697,8 @@ block_append(head, tail) extern int verbose; NODE *last; - if (tail == Qnil) return head; - if (head == Qnil) return tail; + if (tail == 0) return head; + if (head == 0) return tail; if (nd_type(head) != NODE_BLOCK) head = last = NEW_BLOCK(head); @@ -2420,11 +2711,7 @@ block_append(head, tail) if (verbose) { switch (nd_type(last->nd_head)) { - case NODE_BREAK: - case NODE_CONTINUE: - case NODE_REDO: case NODE_RETURN: - case NODE_RETRY: Warning("statement not reached"); break; @@ -2447,7 +2734,7 @@ list_append(head, tail) { NODE *last; - if (head == Qnil) return NEW_LIST(tail); + if (head == 0) return NEW_LIST(tail); last = head; while (last->nd_next) { @@ -2465,11 +2752,6 @@ list_concat(head, tail) { NODE *last; -#if 0 - if (nd_type(head) != NODE_ARRAY || nd_type(tail) != NODE_ARRAY) - Bug("list_concat() called with non-list"); -#endif - last = head; while (last->nd_next) { last = last->nd_next; @@ -2493,7 +2775,7 @@ call_op(recv, id, narg, arg1) value_expr(arg1); } - return NEW_CALL(recv, id, narg==1?NEW_LIST(arg1):Qnil); + return NEW_CALL(recv, id, narg==1?NEW_LIST(arg1):0); } static NODE* @@ -2506,19 +2788,11 @@ gettable(id) else if (id == NIL) { return NEW_NIL(); } - else if (id == _LINE_) { - return NEW_LIT(INT2FIX(sourceline)); - } - else if (id == _FILE_) { - VALUE s = str_new2(sourcefile); - - return NEW_STR(s); - } else if (is_local_id(id)) { if (local_id(id)) return NEW_LVAR(id); - if (dyna_id(id)) return NEW_DVAR(id); + if (dyna_var_defined(id)) return NEW_DVAR(id); /* method call without arguments */ - return NEW_FCALL(id, Qnil); + return NEW_FCALL(id, 0); } else if (is_global_id(id)) { return NEW_GVAR(id); @@ -2530,7 +2804,7 @@ gettable(id) return NEW_CVAR(id); } Bug("invalid id for gettable"); - return Qnil; + return 0; } static NODE* @@ -2538,17 +2812,13 @@ asignable(id, val) ID id; NODE *val; { - extern VALUE dyna_var_asgn(); - NODE *lhs = Qnil; + NODE *lhs = 0; if (id == SELF) { - Error("Can't change the value of self"); + yyerror("Can't change the value of self"); } else if (id == NIL) { - Error("Can't asign to nil"); - } - else if (id == _LINE_ || id == _FILE_) { - Error("Can't asign to special identifier"); + yyerror("Can't asign to nil"); } else if (is_local_id(id)) { if (local_id(id) || !dyna_in_block()) @@ -2566,7 +2836,7 @@ asignable(id, val) } else if (is_const_id(id)) { if (cur_mid || in_single) - Error("class constant asigned in method body"); + yyerror("dynamic constant asignment"); lhs = NEW_CASGN(id, val); } else { @@ -2625,22 +2895,17 @@ static int value_expr(node) NODE *node; { - if (node == Qnil) return TRUE; + if (node == 0) return TRUE; switch (nd_type(node)) { case NODE_RETURN: - case NODE_CONTINUE: - case NODE_BREAK: - case NODE_REDO: - case NODE_RETRY: - case NODE_FAIL: case NODE_WHILE: - case NODE_WHILE2: + case NODE_UNTIL: case NODE_CLASS: case NODE_MODULE: case NODE_DEFN: case NODE_DEFS: - Error("void value expression"); + yyerror("void value expression"); return FALSE; break; @@ -2666,19 +2931,26 @@ cond0(node) { enum node_type type = nd_type(node); - if (type == NODE_STR || type == NODE_STR2 || type == NODE_DREGX) { + switch (type) { + case NODE_DREGX: + case NODE_DREGX_ONCE: return call_op(NEW_GVAR(rb_intern("$_")),MATCH,1,node); - } - else if (type == NODE_LIT && TYPE(node->nd_lit) == T_REGEXP) { - return call_op(node,MATCH,1,NEW_GVAR(rb_intern("$_"))); - } - else if (type == NODE_DOT2 || type == NODE_DOT3) { + + case NODE_DOT2: + case NODE_DOT3: node->nd_beg = cond2(node->nd_beg); node->nd_end = cond2(node->nd_end); if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2); else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3); + return node; + + case NODE_LIT: + if (TYPE(node->nd_lit) == T_REGEXP) { + return NEW_MATCH(node); + } + default: + return node; } - return node; } static NODE* @@ -2700,7 +2972,7 @@ cond(node) node = cond0(node); if (type == NODE_CALL && node->nd_mid == '!') { - if (node->nd_args || node->nd_recv == Qnil) { + if (node->nd_args || node->nd_recv == 0) { Bug("method `!' called with wrong # of operand"); } node->nd_recv = cond0(node->nd_recv); @@ -2719,6 +2991,16 @@ cond2(node) return node; } +static NODE* +logop(type, left, right) + enum node_type type; + NODE *left, *right; +{ + value_expr(left); + + return newnode(type, cond(left), cond(right)); +} + st_table *new_idhash(); static struct local_vars { @@ -2797,10 +3079,8 @@ local_id(id) static void top_local_init() { - if (lvtbl == 0) { - local_push(); - } - else if (the_scope->local_tbl) { + local_push(); + if (the_scope->local_tbl) { lvtbl->cnt = the_scope->local_tbl[0]; } else { @@ -2813,7 +3093,6 @@ top_local_init() else { lvtbl->tbl = 0; } - NEW_CREF0(); /* initialize constant c-ref */ lvtbl->dlev = (the_dyna_vars?1:0); } @@ -2832,26 +3111,23 @@ top_local_setup() the_scope->local_vars = ALLOC_N(VALUE, len); if (vars) { MEMCPY(the_scope->local_vars, vars, VALUE, i); - MEMZERO(the_scope->local_vars+i, VALUE, len-i); + memclear(the_scope->local_vars+i, len-i); } else { - MEMZERO(the_scope->local_vars, VALUE, len); + memclear(the_scope->local_vars, len); } the_scope->flag = SCOPE_MALLOC; } else { REALLOC_N(the_scope->local_vars, VALUE, len); - MEMZERO(the_scope->local_vars+i, VALUE, len-i); + memclear(the_scope->local_vars+i, len-i); free(the_scope->local_tbl); } lvtbl->tbl[0] = len; the_scope->local_tbl = lvtbl->tbl; } - else if (lvtbl->tbl) { - free(lvtbl->tbl); - } } - cref_list = Qnil; + local_pop(); } static struct RVarmap* @@ -2878,10 +3154,9 @@ dyna_in_block() static void cref_pop() { - NODE *cref = cref_list; + NODE *cref = cur_cref; - cref_list = cref_list->nd_next; - cref->nd_next = Qnil; + cur_cref = cur_cref->nd_next; } void @@ -2893,22 +3168,22 @@ yyappend_print() } void -yywhole_loop(chop, split) +yywhile_loop(chop, split) int chop, split; { if (split) { eval_tree = block_append(NEW_GASGN(rb_intern("$F"), NEW_CALL(NEW_GVAR(rb_intern("$_")), - rb_intern("split"), Qnil)), + rb_intern("split"), 0)), eval_tree); } if (chop) { eval_tree = block_append(NEW_CALL(NEW_GVAR(rb_intern("$_")), - rb_intern("chop!"), Qnil), eval_tree); + rb_intern("chop!"), 0), eval_tree); } - eval_tree = NEW_WHILE(NEW_FCALL(rb_intern("gets"),0),eval_tree); + eval_tree = NEW_OPT_N(eval_tree); } static struct op_tbl rb_op_tbl[] = { @@ -2934,6 +3209,7 @@ static struct op_tbl rb_op_tbl[] = { '<', "<", LEQ, "<=", EQ, "==", + EQQ, "===", NEQ, "!=", MATCH, "=~", NMATCH, "!~", @@ -2948,7 +3224,8 @@ static struct op_tbl rb_op_tbl[] = { LSHFT, "<<", RSHFT, ">>", COLON2, "::", - Qnil, Qnil, + '`', "`", + 0, 0, }; char *rb_id2name(); @@ -2963,8 +3240,8 @@ Init_sym() { int strcmp(); - sym_tbl = st_init_table(strcmp, st_strhash); - rb_global_variable(&cref_list); + sym_tbl = st_init_strtable(); + rb_global_variable(&cur_cref); } ID @@ -3027,15 +3304,19 @@ rb_intern(name) return id; } -static char *find_ok; +struct find_ok { + ID id; + char *name; +}; static int -id_find(name, id1, id2) +id_find(name, id1, ok) char *name; - ID id1, id2; + ID id1; + struct find_ok *ok; { - if (id1 == id2) { - find_ok = name; + if (id1 == ok->id) { + ok->name = name; return ST_STOP; } return ST_CONTINUE; @@ -3045,7 +3326,7 @@ char * rb_id2name(id) ID id; { - find_ok = 0; + struct find_ok ok; if (id < LAST_TOKEN) { int i = 0; @@ -3056,8 +3337,10 @@ rb_id2name(id) } } - st_foreach(sym_tbl, id_find, id); - if (!find_ok && is_attrset_id(id)) { + ok.name = 0; + ok.id = id; + st_foreach(sym_tbl, id_find, &ok); + if (!ok.name && is_attrset_id(id)) { char *res; ID id2; @@ -3073,7 +3356,7 @@ rb_id2name(id) return rb_id2name(id); } } - return find_ok; + return ok.name; } static int @@ -3095,3 +3378,84 @@ rb_const_check(class, module) { st_foreach(module->iv_tbl, const_check, class); } + +void +local_var_append(id) + ID id; +{ + struct local_vars tmp; + struct local_vars *save = lvtbl; + + if (the_scope->local_tbl) { + tmp.cnt = the_scope->local_tbl[0]; + tmp.tbl = the_scope->local_tbl; + lvtbl->dlev = 0; + } + lvtbl = &tmp; + local_cnt(id); + lvtbl = save; +} + +static VALUE +special_local_get(c) + char c; +{ + int cnt, max; + + if (!the_scope->local_vars) return Qnil; + for (cnt=1, max=the_scope->local_tbl[0]+1; cnt<max ;cnt++) { + if (the_scope->local_tbl[cnt] == c) { + return the_scope->local_vars[cnt-1]; + } + } + return Qnil; +} + +static void +special_local_set(c, val) + char c; + VALUE val; +{ + int cnt, max; + + if (the_scope->local_tbl) { + for (cnt=1, max=the_scope->local_tbl[0]+1; cnt<max ;cnt++) { + if (the_scope->local_tbl[cnt] == c) { + the_scope->local_vars[cnt-1] = val; + return; + } + } + } + top_local_init(); + cnt = local_cnt(c); + top_local_setup(); + the_scope->local_vars[cnt] = val; +} + +VALUE +backref_get() +{ + return special_local_get('~'); +} + +void +backref_set(val) + VALUE val; +{ + special_local_set('~', val); +} + +VALUE +lastline_get() +{ + VALUE v = special_local_get('_'); + if (v == 1) return Qnil; /* $_ undefined */ + return v; +} + +void +lastline_set(val) + VALUE val; +{ + special_local_set('_', val); +} |