From aeb049c573be4dc24dd20650f40e4777e0f698cf Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Wed, 20 Jan 1999 04:59:32 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'RUBY'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/Win32API/depend | 1 + ext/mandel/MANIFEST | 3 + ext/mandel/mandel.c | 59 + ext/mandel/tkmandel.rb | 172 ++ ext/readline/MANIFEST | 4 + ext/readline/README | 55 + ext/readline/extconf.rb | 8 + ext/readline/readline.c | 386 +++ parse.c | 7224 +++++++++++++++++++++++++++++++++++++++++++++++ sample/mine.rb | 173 ++ sample/rename.rb | 297 ++ win32/win32.c | 2206 +++++++++++++++ win32/win32.h | 358 +++ 13 files changed, 10946 insertions(+) create mode 100644 ext/Win32API/depend create mode 100644 ext/mandel/MANIFEST create mode 100644 ext/mandel/mandel.c create mode 100644 ext/mandel/tkmandel.rb create mode 100644 ext/readline/MANIFEST create mode 100644 ext/readline/README create mode 100644 ext/readline/extconf.rb create mode 100644 ext/readline/readline.c create mode 100644 parse.c create mode 100644 sample/mine.rb create mode 100644 sample/rename.rb create mode 100644 win32/win32.c create mode 100644 win32/win32.h diff --git a/ext/Win32API/depend b/ext/Win32API/depend new file mode 100644 index 0000000000..517b546de3 --- /dev/null +++ b/ext/Win32API/depend @@ -0,0 +1 @@ +Win32API.o : Win32API.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h diff --git a/ext/mandel/MANIFEST b/ext/mandel/MANIFEST new file mode 100644 index 0000000000..8a72d2c3a9 --- /dev/null +++ b/ext/mandel/MANIFEST @@ -0,0 +1,3 @@ +MANIFEST +mandel.c +tkmandel.rb diff --git a/ext/mandel/mandel.c b/ext/mandel/mandel.c new file mode 100644 index 0000000000..359c0756da --- /dev/null +++ b/ext/mandel/mandel.c @@ -0,0 +1,59 @@ +/************************************************ + + mandel.c - + + $Author$ + +************************************************/ + +#include "ruby.h" +#include "math.h" + +static VALUE +mandel(self, re, im, max) + VALUE self; + VALUE re; + VALUE im; + VALUE max; +{ + double real, image; + double z_real, z_image; + double tmp_real; + int maximum; + int i; + + Check_Type(re, T_FLOAT); + Check_Type(im, T_FLOAT); + Check_Type(max, T_FIXNUM); + + real = RFLOAT(re)->value; + image = RFLOAT(im)->value; + maximum = FIX2INT(max); + + /*** + z = c = Complex(re, im) + for i in 0 .. $max_deapth + z = (z * z) + c + break if z.abs > 2 + end + return i + ***/ + + z_real = real; + z_image = image; + for (i = 0; i < maximum; i++) { + tmp_real = ((z_real * z_real) - (z_image * z_image)) + real; + z_image = ((z_real * z_image) + (z_image * z_real)) + image; + z_real = tmp_real; + if ( ((z_real * z_real) + (z_image * z_image)) > 4.0 ) { + break; + } + } + return INT2FIX(i); +} + +Init_mandel() +{ + VALUE mMandel = rb_define_module("Mandel"); + rb_define_module_function(mMandel, "mandel", mandel, 3); +} diff --git a/ext/mandel/tkmandel.rb b/ext/mandel/tkmandel.rb new file mode 100644 index 0000000000..5ebe90fb80 --- /dev/null +++ b/ext/mandel/tkmandel.rb @@ -0,0 +1,172 @@ +# require "complex" +require "mandel" +require "tkclass" + +DefaultMaxDepth = 30 +DefaultSX = -2.25 +DefaultSY = 1.75 +DefaultEX = 1.25 +DefaultEY = -1.75 + +def reset + $max_depth = DefaultMaxDepth + $s_re = DefaultSX + $s_im = DefaultSY + $e_re = DefaultEX + $e_im = DefaultEY + $dx = ($e_re - $s_re).abs / Width + $dy = ($e_im - $s_im).abs / Height + $photo.blank +end + + +Width = 400 +Height = 400 + +$c = Canvas.new { + width Width + height Height + } +$c.pack + +$c_rect = Rectangle.new($c, 0, 0, Width+1, Height+1) +$c_rect.fill "white" + +$colors = [] + +def colors_init + $colors = [] + for i in 0 .. 125 + $colors.push(format("#%02x%02x%02x", 250 - (i*2), i*2, 0)) + end + for i in 0 .. 125 + $colors.push(format("#%02x%02x%02x", 0, 250 - (i*2), i*2)) + end + $color_max = $colors.size - 1 +end + +def zoom(a, b, c, d) + center_x = (a + c) / 2 + center_y = (b + d) / 2 + size = (c - a).abs + size = (d - b).abs if (size < (d - b).abs) + size = 1 if (size < 1) + zoom_rate = ((Width + Height) / 2).to_f / size + $max_depth = ($max_depth.to_f * Math.sqrt(Math.sqrt(Math.sqrt(zoom_rate)))).to_i + + move_x_rate = (center_x - (Width / 2)).to_f / (Width / 2) + move_y_rate = (center_y - (Height / 2)).to_f / (Height / 2) + + center_re = ($s_re + $e_re) / 2 + center_im = ($s_im + $e_im) / 2 + c_size_re = ($e_re - $s_re).abs + c_size_im = ($e_im - $s_im).abs + + center_re = center_re + (move_x_rate * (c_size_re / 2)) + center_im = center_im - (move_y_rate * (c_size_im / 2)) + + $s_re = center_re - ((c_size_re / 2) / zoom_rate) + $s_im = center_im + ((c_size_im / 2) / zoom_rate) + $e_re = center_re + ((c_size_re / 2) / zoom_rate) + $e_im = center_im - ((c_size_im / 2) / zoom_rate) + + $dx = ($e_re - $s_re).abs / Width + $dy = ($e_im - $s_im).abs / Height + p [$s_re, $dx, $s_im, $dy] +end + + +def mandel(x, y) + re = $s_re + ($dx * x) + im = $s_im - ($dy * y) +# z = c = Complex(re, im) +# for i in 0 .. $max_depth +# z = (z * z) + c +# break if z.abs > 2 +# end +# return i + return Mandel.mandel(re, im, $max_depth) +end + +$buf = "{"+" "*Width+"}" +def calc + $c.update + return if $current_rect + depth = 0 + + for x in 0 .. Width - 1 + depth = mandel(x, $calc_y) + if depth >= $max_depth + $buf[x*8+1,7] = "#000000" + else + $buf[x*8+1,7] = $colors[$color_max * depth / $max_depth] + end + end + $photo.put($buf, 0, $calc_y) + + $calc_y += 1 + if (($calc_y % 20) == 0) + print "#{($calc_y * 100 / Height)}% done. -- depth #{$max_depth}\n" +# $mandel.image $photo + end + + if ($calc_y > Height - 1) + $calc_y = StartCalcY + $calc_on = false +# exit + end + + if $calc_on + Tk.after(1) { calc() } + end +end + +$photo = TkPhotoImage.new({'width'=>Width, 'height'=>Height}) +$mandel = TkcImage.new($c, Width/2, Height/2) { image $photo } +reset() +colors_init() +$calc_y = StartCalcY = 0 +$calc_on = true +calc() + +def clear +# $mandel.destroy if $mandel + $calc_y = StartCalcY +end + +$start_x = $start_y = 0 +$current_rect = nil + +def do_press(x, y) + $start_x = x + $start_y = y + $current_rect = Rectangle.new($c, x, y, x, y) { outline "white" } +end + +def do_motion(x, y) + if $current_rect + $current_rect.coords $start_x, $start_y, x, y + end +end + +def do_release(x, y) + if $current_rect + $current_rect.coords $start_x, $start_y, x, y + $current_rect.destroy + $current_rect = nil + clear() + $calc_on = true + zoom($start_x, $start_y, x, y) + calc() + end +end + +$c.bind("1", proc{|e| do_press e.x, e.y}) +$c.bind("B1-Motion", proc{|x, y| do_motion x, y}, "%x %y") +$c.bind("ButtonRelease-1", proc{|x, y| do_release x, y}, "%x %y") + +begin + Tk.mainloop +ensure +# File.delete("#tmpmandel#.gif") +end diff --git a/ext/readline/MANIFEST b/ext/readline/MANIFEST new file mode 100644 index 0000000000..f73a899abb --- /dev/null +++ b/ext/readline/MANIFEST @@ -0,0 +1,4 @@ +MANIFEST +README +extconf.rb +readline.c diff --git a/ext/readline/README b/ext/readline/README new file mode 100644 index 0000000000..8a5fe9120f --- /dev/null +++ b/ext/readline/README @@ -0,0 +1,55 @@ +GNU Readline Libraryを利用するための拡張モジュールです。 + +require "readline" +include Readline + +line = readline("Prompt> ", TRUE) + +のように使用してください。 + +[Readline] + +<モジュール関数> + +readline(prompt, add=nil) + + 一行入力を読み込みます。 + addがTRUEの場合、ヒストリに読み込んだ文字列を追加します。 + +<クラスメソッド> + +completion_proc = proc + + 補完時の動作を決定するProcオブジェクトを指定します。 + procは引数に入力文字列を取り、候補文字列の配列を返すように + してください。 + +completion_proc + + 補完時の動作を決定するProcオブジェクトを返します。 + +completion_case_fold = case_fold + + 補完時に大文字小文字を区別しない場合、TRUEを指定します。 + +completion_case_fold + + 補完時に大文字小文字を区別しない場合、TRUEを返します。 + +vi_editing_mode + + VIモードになります。 + +emacs_editing_mode + + Emacsモードになります。 + +<クラス定数> + +HISTORY + +ヒストリに対する操作はこの定数を通して行ってください。 +配列と同じように扱えるようになっています。 + + + \ No newline at end of file diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb new file mode 100644 index 0000000000..e55233eb20 --- /dev/null +++ b/ext/readline/extconf.rb @@ -0,0 +1,8 @@ +require "mkmf" + +have_library("termcap", "tgetnum") +if have_header("readline/readline.h") and + have_header("readline/history.h") and + have_library("readline", "readline") + create_makefile("readline") +end diff --git a/ext/readline/readline.c b/ext/readline/readline.c new file mode 100644 index 0000000000..9e471195e6 --- /dev/null +++ b/ext/readline/readline.c @@ -0,0 +1,386 @@ +/* readline.c -- GNU Readline module + Copyright (C) 1997-1998 Shugo Maeda */ + +#include +#include +#include + +#include "ruby.h" +#include "rubysig.h" + +static VALUE mReadline; + +#define TOLOWER(c) (isupper(c) ? tolower(c) : c) + +#define COMPLETION_PROC "completion_proc" +#define COMPLETION_CASE_FOLD "completion_case_fold" + +static int +readline_event() +{ + CHECK_INTS; +#ifdef USE_THREAD + rb_thread_schedule(); +#endif +} + +static VALUE +readline_readline(int argc, VALUE *argv, VALUE self) +{ + VALUE tmp, add_hist, result; + char *prompt = NULL; + char *buff; + + if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) { + prompt = STR2CSTR(tmp); + } + buff = readline(prompt); + if (RTEST(add_hist) && buff) { + add_history(buff); + } + if (buff) + result = rb_str_new2(buff); + else + result = Qnil; + if (buff) free(buff); + return result; +} + +static VALUE +readline_s_set_completion_proc(VALUE self, VALUE proc) +{ + if (!rb_respond_to(proc, rb_intern("call"))) + rb_raise(rb_eArgError, "argument have to respond to `call'"); + return rb_iv_set(mReadline, COMPLETION_PROC, proc); +} + +static VALUE +readline_s_get_completion_proc(VALUE self) +{ + return rb_iv_get(mReadline, COMPLETION_PROC); +} + +static VALUE +readline_s_set_completion_case_fold(VALUE self, VALUE val) +{ + return rb_iv_set(mReadline, COMPLETION_CASE_FOLD, val); +} + +static VALUE +readline_s_get_completion_case_fold(VALUE self) +{ + return rb_iv_get(mReadline, COMPLETION_CASE_FOLD); +} + +static char ** +readline_attempted_completion_function(char *text, int start, int end) +{ + VALUE proc, ary, temp; + char **result; + int case_fold; + int i, matches; + + proc = rb_iv_get(mReadline, COMPLETION_PROC); + rl_attempted_completion_over = 1; + case_fold = RTEST(rb_iv_get(mReadline, COMPLETION_CASE_FOLD)); + ary = rb_funcall(proc, rb_intern("call"), 1, rb_str_new2(text)); + if (TYPE(ary) != T_ARRAY) + ary = rb_Array(ary); + matches = RARRAY(ary)->len; + if (matches == 0) + return NULL; + result = ALLOC_N(char *, matches + 2); + for (i = 0; i < matches; i++) { + temp = rb_obj_as_string(RARRAY(ary)->ptr[i]); + result[i + 1] = ALLOC_N(char, RSTRING(temp)->len + 1); + strcpy(result[i + 1], RSTRING(temp)->ptr); + } + result[matches + 1] = NULL; + + if (matches == 1) { + result[0] = result[1]; + result[1] = NULL; + } else { + register int i = 1; + int low = 100000; + + while (i < matches) { + register int c1, c2, si; + + if (case_fold) { + for (si = 0; + (c1 = TOLOWER(result[i][si])) && + (c2 = TOLOWER(result[i + 1][si])); + si++) + if (c1 != c2) break; + } else { + for (si = 0; + (c1 = result[i][si]) && + (c2 = result[i + 1][si]); + si++) + if (c1 != c2) break; + } + + if (low > si) low = si; + i++; + } + result[0] = ALLOC_N(char, low + 1); + strncpy(result[0], result[1], low); + result[0][low] = '\0'; + } + + return result; +} + +static VALUE +readline_s_vi_editing_mode(VALUE self) +{ + rl_vi_editing_mode(); + return Qnil; +} + +static VALUE +readline_s_emacs_editing_mode(VALUE self) +{ + rl_emacs_editing_mode(); + return Qnil; +} + +static VALUE +hist_to_s(VALUE self) +{ + return rb_str_new2("HISTORY"); +} + +static VALUE +hist_get(VALUE self, VALUE index) +{ + HISTORY_STATE *state; + int i; + + state = history_get_history_state(); + i = NUM2INT(index); + if (i < 0 || i > state->length - 1) { + rb_raise(rb_eIndexError, "Invalid index"); + } + return rb_str_new2(state->entries[i]->line); +} + +static VALUE +hist_set(VALUE self, VALUE index, VALUE str) +{ + HISTORY_STATE *state; + int i; + + state = history_get_history_state(); + i = NUM2INT(index); + if (i < 0 || i > state->length - 1) { + rb_raise(rb_eIndexError, "Invalid index"); + } + replace_history_entry(i, STR2CSTR(str), NULL); + return str; +} + +static VALUE +hist_push(VALUE self, VALUE str) +{ + add_history(STR2CSTR(str)); + return self; +} + +static VALUE +hist_push_method(int argc, VALUE *argv, + VALUE self) +{ + VALUE str; + + while (argc--) { + str = *argv++; + add_history(STR2CSTR(str)); + } + return self; +} + +static VALUE +hist_pop(VALUE self) +{ + HISTORY_STATE *state; + HIST_ENTRY *entry; + + state = history_get_history_state(); + if (state->length > 0) { + entry = remove_history(state->length - 1); + return rb_str_new2(entry->line); + } else { + return Qnil; + } +} + +static VALUE +hist_shift(VALUE self) +{ + HISTORY_STATE *state; + HIST_ENTRY *entry; + + state = history_get_history_state(); + if (state->length > 0) { + entry = remove_history(0); + return rb_str_new2(entry->line); + } else { + return Qnil; + } +} + +static VALUE +hist_each(VALUE self) +{ + HISTORY_STATE *state; + int i; + + state = history_get_history_state(); + for (i = 0; i < state->length; i++) { + rb_yield(rb_str_new2(state->entries[i]->line)); + } + return Qnil; +} + +static VALUE +hist_length(VALUE self) +{ + HISTORY_STATE *state; + + state = history_get_history_state(); + return INT2NUM(state->length); +} + +static VALUE +hist_empty_p(VALUE self) +{ + HISTORY_STATE *state; + + state = history_get_history_state(); + if (state->length == 0) + return Qtrue; + else + return Qfalse; +} + +static VALUE +hist_delete_at(VALUE self, VALUE index) +{ + HISTORY_STATE *state; + HIST_ENTRY *entry; + int i; + + state = history_get_history_state(); + i = NUM2INT(index); + if (i < 0 || i > state->length - 1) { + rb_raise(rb_eIndexError, "Invalid index"); + } + entry = remove_history(NUM2INT(index)); + return rb_str_new2(entry->line); +} + +static VALUE +filename_completion_proc_call(VALUE self, VALUE str) +{ + VALUE result; + char **matches; + int i; + + matches = completion_matches(STR2CSTR(str), + filename_completion_function); + if (matches) { + result = rb_ary_new(); + for (i = 0; matches[i]; i++) { + rb_ary_push(result, rb_str_new2(matches[i])); + free(matches[i]); + } + free(matches); + if (RARRAY(result)->len >= 2) + rb_ary_shift(result); + } + else { + result = Qnil; + } + return result; +} + +static VALUE +username_completion_proc_call(VALUE self, VALUE str) +{ + VALUE result; + char **matches; + int i; + + matches = completion_matches(STR2CSTR(str), + username_completion_function); + if (matches) { + result = rb_ary_new(); + for (i = 0; matches[i]; i++) { + rb_ary_push(result, rb_str_new2(matches[i])); + free(matches[i]); + } + free(matches); + if (RARRAY(result)->len >= 2) + rb_ary_shift(result); + } + else { + result = Qnil; + } + return result; +} + +void +Init_readline(void) +{ + VALUE histary, fcomp, ucomp; + + using_history(); + + mReadline = rb_define_module("Readline"); + rb_define_module_function(mReadline, "readline", + readline_readline, -1); + rb_define_singleton_method(mReadline, "completion_proc=", + readline_s_set_completion_proc, 1); + rb_define_singleton_method(mReadline, "completion_proc", + readline_s_get_completion_proc, 0); + rb_define_singleton_method(mReadline, "completion_case_fold=", + readline_s_set_completion_case_fold, 1); + rb_define_singleton_method(mReadline, "completion_case_fold", + readline_s_get_completion_case_fold, 0); + rb_define_singleton_method(mReadline, "vi_editing_mode", + readline_s_vi_editing_mode, 0); + rb_define_singleton_method(mReadline, "emacs_editing_mode", + readline_s_emacs_editing_mode, 0); + + histary = rb_obj_alloc(rb_cObject); + rb_extend_object(histary, rb_mEnumerable); + rb_define_singleton_method(histary,"to_s", hist_to_s, 0); + rb_define_singleton_method(histary,"[]", hist_get, 1); + rb_define_singleton_method(histary,"[]=", hist_set, 2); + rb_define_singleton_method(histary,"<<", hist_push, 1); + rb_define_singleton_method(histary,"push", hist_push_method, -1); + rb_define_singleton_method(histary,"pop", hist_pop, 0); + rb_define_singleton_method(histary,"shift", hist_shift, 0); + rb_define_singleton_method(histary,"each", hist_each, 0); + rb_define_singleton_method(histary,"length", hist_length, 0); + rb_define_singleton_method(histary,"empty?", hist_empty_p, 0); + rb_define_singleton_method(histary,"delete_at", hist_delete_at, 1); + rb_define_const(mReadline, "HISTORY", histary); + + fcomp = rb_obj_alloc(rb_cObject); + rb_define_singleton_method(fcomp, "call", + filename_completion_proc_call, 1); + rb_define_const(mReadline, "FILENAME_COMPLETION_PROC", fcomp); + + ucomp = rb_obj_alloc(rb_cObject); + rb_define_singleton_method(ucomp, "call", + username_completion_proc_call, 1); + rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp); + + rl_attempted_completion_function + = (CPPFunction *) readline_attempted_completion_function; + rl_event_hook = readline_event; + rl_clear_signals(); +} diff --git a/parse.c b/parse.c new file mode 100644 index 0000000000..8c3bcc545a --- /dev/null +++ b/parse.c @@ -0,0 +1,7224 @@ + +/* A Bison parser, made from parse.y + by GNU Bison version 1.25.90 + */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define kCLASS 257 +#define kMODULE 258 +#define kDEF 259 +#define kUNDEF 260 +#define kBEGIN 261 +#define kRESCUE 262 +#define kENSURE 263 +#define kEND 264 +#define kIF 265 +#define kUNLESS 266 +#define kTHEN 267 +#define kELSIF 268 +#define kELSE 269 +#define kCASE 270 +#define kWHEN 271 +#define kWHILE 272 +#define kUNTIL 273 +#define kFOR 274 +#define kBREAK 275 +#define kNEXT 276 +#define kREDO 277 +#define kRETRY 278 +#define kIN 279 +#define kDO 280 +#define kRETURN 281 +#define kYIELD 282 +#define kSUPER 283 +#define kSELF 284 +#define kNIL 285 +#define kTRUE 286 +#define kFALSE 287 +#define kAND 288 +#define kOR 289 +#define kNOT 290 +#define kIF_MOD 291 +#define kUNLESS_MOD 292 +#define kWHILE_MOD 293 +#define kUNTIL_MOD 294 +#define kALIAS 295 +#define kDEFINED 296 +#define klBEGIN 297 +#define klEND 298 +#define k__LINE__ 299 +#define k__FILE__ 300 +#define tIDENTIFIER 301 +#define tFID 302 +#define tGVAR 303 +#define tIVAR 304 +#define tCONSTANT 305 +#define tINTEGER 306 +#define tFLOAT 307 +#define tSTRING 308 +#define tXSTRING 309 +#define tREGEXP 310 +#define tDSTRING 311 +#define tDXSTRING 312 +#define tDREGEXP 313 +#define tNTH_REF 314 +#define tBACK_REF 315 +#define tUPLUS 316 +#define tUMINUS 317 +#define tPOW 318 +#define tCMP 319 +#define tEQ 320 +#define tEQQ 321 +#define tNEQ 322 +#define tGEQ 323 +#define tLEQ 324 +#define tANDOP 325 +#define tOROP 326 +#define tMATCH 327 +#define tNMATCH 328 +#define tDOT2 329 +#define tDOT3 330 +#define tAREF 331 +#define tASET 332 +#define tLSHFT 333 +#define tRSHFT 334 +#define tCOLON2 335 +#define tCOLON3 336 +#define tOP_ASGN 337 +#define tASSOC 338 +#define tLPAREN 339 +#define tLBRACK 340 +#define tLBRACE 341 +#define tSTAR 342 +#define tAMPER 343 +#define tSYMBEG 344 +#define LAST_TOKEN 345 + +#line 13 "parse.y" + + +#define YYDEBUG 1 +#include "ruby.h" +#include "env.h" +#include "node.h" +#include "st.h" +#include + +/* hack for bison */ +#ifdef const +# undef const +#endif + +#define ID_SCOPE_SHIFT 3 +#define ID_SCOPE_MASK 0x07 +#define ID_LOCAL 0x01 +#define ID_INSTANCE 0x02 +#define ID_GLOBAL 0x03 +#define ID_ATTRSET 0x04 +#define ID_CONST 0x05 + +#define is_id_notop(id) ((id)>LAST_TOKEN) +#define is_local_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL) +#define is_global_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL) +#define is_instance_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE) +#define is_attrset_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET) +#define is_const_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_CONST) + +NODE *ruby_eval_tree_begin = 0; +NODE *ruby_eval_tree = 0; + +char *ruby_sourcefile; /* current source file */ +int ruby_sourceline; /* current line no. */ + +static int yylex(); +static int yyerror(); + +static enum lex_state { + EXPR_BEG, /* ignore newline, +/- is a sign. */ + EXPR_MID, /* newline significant, +/- is a sign. */ + EXPR_END, /* newline significant, +/- is a operator. */ + EXPR_ARG, /* newline significant, +/- is a operator. */ + EXPR_FNAME, /* ignore newline, +/- is a operator, no reserved words. */ + EXPR_DOT, /* immediate after `.', no reserved words. */ + EXPR_CLASS, /* immediate after `class', no here document. */ +} lex_state; + +static int class_nest = 0; +static int in_single = 0; +static ID cur_mid = 0; + +static int value_expr(); +static NODE *cond(); +static NODE *logop(); + +static NODE *newline_node(); +static void fixpos(); + +static NODE *block_append(); +static NODE *list_append(); +static NODE *list_concat(); +static NODE *arg_add(); +static NODE *call_op(); +static int in_defined = 0; + +static NODE *arg_blk_pass(); +static NODE *new_call(); +static NODE *new_fcall(); + +static NODE *gettable(); +static NODE *assignable(); +static NODE *aryset(); +static NODE *attrset(); +static void rb_backref_error(); + +static NODE *match_gen(); +static void local_push(); +static void local_pop(); +static int local_append(); +static int local_cnt(); +static int local_id(); +static ID *local_tbl(); + +static struct RVarmap *dyna_push(); +static void dyna_pop(); +static int dyna_in_block(); + +#define cref_push() NEW_CREF() +static void cref_pop(); +static NODE *cur_cref; + +static void top_local_init(); +static void top_local_setup(); + +#line 109 "parse.y" +typedef union { + NODE *node; + VALUE val; + ID id; + int num; + struct RVarmap *vars; +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 617 +#define YYFLAG -32768 +#define YYNTBASE 118 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 345 ? yytranslate[x] : 206) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 116, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 104, 2, 2, 2, 103, 98, 2, 115, + 110, 101, 99, 111, 100, 109, 102, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 93, 117, 95, + 91, 94, 92, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 112, 2, 113, 97, 2, 114, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 107, 96, 108, 105, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 106 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 1, 4, 7, 8, 10, 14, 17, 20, 21, + 26, 30, 34, 38, 41, 45, 49, 53, 57, 58, + 64, 69, 71, 75, 78, 81, 83, 87, 91, 94, + 97, 99, 102, 107, 112, 115, 117, 121, 123, 127, + 129, 133, 136, 142, 145, 147, 151, 154, 156, 160, + 162, 167, 171, 173, 175, 177, 179, 181, 183, 185, + 187, 189, 190, 195, 197, 199, 201, 203, 205, 207, + 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, + 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, + 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, + 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, + 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, + 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, + 329, 330, 335, 342, 348, 354, 358, 359, 364, 371, + 377, 383, 387, 391, 395, 399, 403, 407, 411, 415, + 419, 422, 425, 429, 433, 437, 441, 445, 449, 453, + 457, 461, 465, 469, 473, 477, 480, 483, 487, 491, + 495, 499, 500, 505, 511, 513, 515, 516, 519, 521, + 524, 530, 533, 539, 544, 552, 556, 558, 561, 564, + 565, 567, 568, 570, 574, 576, 581, 584, 586, 587, + 590, 592, 596, 600, 603, 605, 607, 609, 611, 613, + 615, 617, 622, 626, 630, 635, 639, 641, 646, 650, + 652, 653, 660, 662, 665, 667, 670, 677, 684, 690, + 696, 701, 709, 716, 720, 721, 728, 729, 737, 738, + 744, 745, 752, 753, 754, 764, 766, 768, 770, 772, + 774, 776, 779, 781, 783, 785, 791, 792, 795, 797, + 799, 800, 803, 805, 809, 810, 816, 817, 823, 825, + 827, 829, 831, 833, 838, 845, 849, 856, 861, 863, + 869, 871, 876, 879, 881, 883, 889, 890, 891, 894, + 896, 899, 901, 903, 905, 907, 909, 911, 913, 915, + 917, 919, 921, 923, 925, 927, 929, 931, 933, 935, + 937, 939, 940, 945, 948, 953, 956, 963, 968, 973, + 976, 981, 984, 987, 989, 990, 992, 996, 1000, 1002, + 1006, 1009, 1012, 1015, 1016, 1018, 1023, 1024, 1027, 1030, + 1032, 1036, 1040, 1042, 1044, 1046, 1048, 1050, 1051, 1053, + 1054, 1056, 1057, 1059, 1061, 1063, 1065, 1067 +}; + +static const short yyrhs[] = { -1, + 119, 120, 0, 121, 201, 0, 0, 122, 0, 121, + 205, 122, 0, 1, 122, 0, 172, 168, 0, 0, + 41, 135, 123, 135, 0, 41, 49, 49, 0, 41, + 49, 61, 0, 41, 49, 60, 0, 6, 136, 0, + 122, 37, 125, 0, 122, 38, 125, 0, 122, 39, + 125, 0, 122, 40, 125, 0, 0, 43, 124, 107, + 120, 108, 0, 44, 107, 120, 108, 0, 125, 0, + 127, 91, 151, 0, 27, 152, 0, 28, 152, 0, + 126, 0, 125, 34, 125, 0, 125, 35, 125, 0, + 36, 125, 0, 104, 126, 0, 140, 0, 199, 146, + 0, 154, 109, 199, 146, 0, 154, 81, 199, 146, + 0, 29, 146, 0, 129, 0, 85, 128, 110, 0, + 129, 0, 85, 128, 110, 0, 131, 0, 131, 88, + 133, 0, 131, 132, 0, 131, 132, 111, 88, 133, + 0, 88, 133, 0, 133, 0, 85, 128, 110, 0, + 130, 111, 0, 130, 0, 132, 111, 130, 0, 182, + 0, 154, 112, 144, 113, 0, 154, 109, 47, 0, + 184, 0, 47, 0, 51, 0, 47, 0, 51, 0, + 48, 0, 138, 0, 139, 0, 135, 0, 0, 136, + 111, 137, 135, 0, 75, 0, 96, 0, 97, 0, + 98, 0, 65, 0, 66, 0, 67, 0, 73, 0, + 94, 0, 69, 0, 95, 0, 70, 0, 79, 0, + 80, 0, 99, 0, 100, 0, 101, 0, 88, 0, + 102, 0, 103, 0, 64, 0, 105, 0, 62, 0, + 63, 0, 77, 0, 78, 0, 114, 0, 45, 0, + 46, 0, 43, 0, 44, 0, 41, 0, 34, 0, + 7, 0, 21, 0, 16, 0, 3, 0, 5, 0, + 42, 0, 26, 0, 15, 0, 14, 0, 10, 0, + 9, 0, 33, 0, 20, 0, 37, 0, 25, 0, + 4, 0, 22, 0, 31, 0, 36, 0, 35, 0, + 23, 0, 8, 0, 24, 0, 27, 0, 30, 0, + 29, 0, 13, 0, 32, 0, 6, 0, 38, 0, + 40, 0, 17, 0, 39, 0, 28, 0, 0, 182, + 91, 141, 140, 0, 154, 112, 144, 113, 91, 140, + 0, 154, 109, 47, 91, 140, 0, 154, 109, 51, + 91, 140, 0, 184, 91, 140, 0, 0, 182, 83, + 142, 140, 0, 154, 112, 144, 113, 83, 140, 0, + 154, 109, 47, 83, 140, 0, 154, 109, 51, 83, + 140, 0, 184, 83, 140, 0, 140, 75, 140, 0, + 140, 76, 140, 0, 140, 99, 140, 0, 140, 100, + 140, 0, 140, 101, 140, 0, 140, 102, 140, 0, + 140, 103, 140, 0, 140, 64, 140, 0, 62, 140, + 0, 63, 140, 0, 140, 96, 140, 0, 140, 97, + 140, 0, 140, 98, 140, 0, 140, 65, 140, 0, + 140, 94, 140, 0, 140, 69, 140, 0, 140, 95, + 140, 0, 140, 70, 140, 0, 140, 66, 140, 0, + 140, 67, 140, 0, 140, 68, 140, 0, 140, 73, + 140, 0, 140, 74, 140, 0, 104, 140, 0, 105, + 140, 0, 140, 79, 140, 0, 140, 80, 140, 0, + 140, 71, 140, 0, 140, 72, 140, 0, 0, 42, + 202, 143, 140, 0, 140, 92, 140, 93, 140, 0, + 154, 0, 145, 0, 0, 146, 202, 0, 126, 0, + 150, 148, 0, 150, 111, 88, 140, 148, 0, 197, + 148, 0, 197, 111, 88, 140, 148, 0, 150, 111, + 197, 148, 0, 150, 111, 197, 111, 88, 140, 148, + 0, 88, 140, 148, 0, 147, 0, 89, 140, 0, + 111, 147, 0, 0, 150, 0, 0, 140, 0, 150, + 111, 140, 0, 150, 0, 150, 111, 88, 140, 0, + 88, 140, 0, 146, 0, 0, 150, 203, 0, 179, + 0, 154, 81, 51, 0, 154, 81, 47, 0, 82, + 134, 0, 54, 0, 57, 0, 55, 0, 58, 0, + 59, 0, 183, 0, 184, 0, 154, 112, 144, 113, + 0, 86, 153, 113, 0, 87, 196, 108, 0, 27, + 115, 152, 110, 0, 27, 115, 110, 0, 27, 0, + 28, 115, 152, 110, 0, 28, 115, 110, 0, 28, + 0, 0, 42, 202, 115, 155, 125, 110, 0, 48, + 0, 199, 170, 0, 173, 0, 173, 170, 0, 11, + 125, 162, 120, 164, 10, 0, 12, 125, 162, 120, + 165, 10, 0, 18, 125, 163, 120, 10, 0, 19, + 125, 163, 120, 10, 0, 16, 120, 174, 10, 0, + 20, 166, 25, 125, 163, 120, 10, 0, 7, 120, + 177, 165, 178, 10, 0, 85, 120, 110, 0, 0, + 3, 134, 185, 156, 120, 10, 0, 0, 3, 79, + 125, 204, 157, 120, 10, 0, 0, 4, 134, 158, + 120, 10, 0, 0, 5, 135, 159, 187, 120, 10, + 0, 0, 0, 5, 195, 200, 160, 135, 161, 187, + 120, 10, 0, 21, 0, 22, 0, 23, 0, 24, + 0, 204, 0, 13, 0, 204, 13, 0, 204, 0, + 26, 0, 165, 0, 14, 125, 162, 120, 164, 0, + 0, 15, 120, 0, 133, 0, 127, 0, 0, 96, + 96, 0, 72, 0, 96, 166, 96, 0, 0, 26, + 169, 167, 120, 10, 0, 0, 107, 171, 167, 120, + 108, 0, 47, 0, 51, 0, 48, 0, 173, 0, + 126, 0, 199, 115, 145, 110, 0, 154, 109, 199, + 115, 145, 110, 0, 154, 109, 199, 0, 154, 81, + 199, 115, 145, 110, 0, 29, 115, 145, 110, 0, + 29, 0, 17, 175, 162, 120, 176, 0, 150, 0, + 150, 111, 88, 140, 0, 88, 140, 0, 165, 0, + 174, 0, 8, 149, 163, 120, 177, 0, 0, 0, + 9, 120, 0, 181, 0, 90, 180, 0, 56, 0, + 135, 0, 50, 0, 49, 0, 52, 0, 53, 0, + 47, 0, 50, 0, 49, 0, 51, 0, 31, 0, + 30, 0, 32, 0, 33, 0, 46, 0, 45, 0, + 182, 0, 60, 0, 61, 0, 204, 0, 0, 95, + 186, 125, 204, 0, 1, 204, 0, 115, 188, 202, + 110, 0, 188, 204, 0, 189, 111, 191, 111, 192, + 194, 0, 189, 111, 191, 194, 0, 189, 111, 192, + 194, 0, 189, 194, 0, 191, 111, 192, 194, 0, + 191, 194, 0, 192, 194, 0, 193, 0, 0, 47, + 0, 189, 111, 47, 0, 47, 91, 140, 0, 190, + 0, 191, 111, 190, 0, 88, 47, 0, 89, 47, + 0, 111, 193, 0, 0, 183, 0, 85, 125, 202, + 110, 0, 0, 197, 203, 0, 150, 203, 0, 198, + 0, 197, 111, 198, 0, 140, 84, 140, 0, 47, + 0, 51, 0, 48, 0, 109, 0, 81, 0, 0, + 205, 0, 0, 116, 0, 0, 116, 0, 111, 0, + 117, 0, 116, 0, 204, 0, 205, 117, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 231, 240, 248, 250, 254, 258, 262, 267, 276, 277, + 282, 288, 297, 302, 308, 314, 320, 330, 340, 348, + 355, 363, 365, 371, 378, 383, 384, 388, 392, 397, + 402, 404, 409, 415, 421, 429, 430, 435, 436, 441, + 445, 449, 453, 457, 462, 463, 468, 473, 477, 482, + 486, 490, 494, 500, 504, 506, 507, 508, 509, 514, + 520, 524, 525, 529, 530, 531, 532, 533, 534, 535, + 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, + 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, + 557, 557, 557, 557, 558, 558, 558, 558, 558, 558, + 558, 559, 559, 559, 559, 559, 559, 559, 560, 560, + 560, 560, 560, 560, 560, 561, 561, 561, 561, 561, + 561, 561, 562, 562, 562, 562, 562, 562, 563, 563, + 565, 566, 573, 578, 583, 588, 594, 595, 610, 625, + 636, 647, 652, 656, 660, 664, 668, 672, 676, 680, + 684, 688, 692, 696, 700, 704, 708, 712, 716, 720, + 724, 728, 732, 736, 740, 744, 749, 753, 757, 761, + 765, 769, 770, 774, 780, 785, 793, 797, 799, 804, + 808, 813, 818, 823, 828, 833, 838, 840, 846, 850, + 855, 856, 861, 866, 872, 884, 889, 895, 909, 913, + 915, 919, 924, 929, 933, 937, 938, 942, 943, 944, + 945, 946, 951, 959, 963, 970, 976, 982, 987, 991, + 995, 995, 1000, 1004, 1009, 1010, 1019, 1028, 1037, 1045, + 1053, 1061, 1069, 1089, 1093, 1103, 1111, 1118, 1126, 1135, + 1143, 1151, 1160, 1161, 1168, 1176, 1180, 1184, 1188, 1193, + 1194, 1195, 1197, 1198, 1200, 1201, 1210, 1214, 1219, 1220, + 1222, 1226, 1230, 1234, 1239, 1244, 1252, 1257, 1264, 1268, + 1272, 1276, 1277, 1279, 1284, 1290, 1296, 1302, 1308, 1316, + 1323, 1324, 1329, 1335, 1336, 1338, 1345, 1350, 1354, 1359, + 1360, 1364, 1366, 1367, 1368, 1370, 1371, 1373, 1374, 1375, + 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1384, 1389, 1390, + 1392, 1396, 1400, 1404, 1406, 1411, 1416, 1420, 1424, 1428, + 1432, 1436, 1440, 1444, 1448, 1453, 1460, 1468, 1475, 1480, + 1485, 1492, 1497, 1501, 1506, 1519, 1537, 1541, 1545, 1553, + 1554, 1559, 1564, 1565, 1566, 1568, 1569, 1571, 1572, 1574, + 1575, 1577, 1578, 1579, 1581, 1582, 1584, 1585 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","kCLASS", +"kMODULE","kDEF","kUNDEF","kBEGIN","kRESCUE","kENSURE","kEND","kIF","kUNLESS", +"kTHEN","kELSIF","kELSE","kCASE","kWHEN","kWHILE","kUNTIL","kFOR","kBREAK","kNEXT", +"kREDO","kRETRY","kIN","kDO","kRETURN","kYIELD","kSUPER","kSELF","kNIL","kTRUE", +"kFALSE","kAND","kOR","kNOT","kIF_MOD","kUNLESS_MOD","kWHILE_MOD","kUNTIL_MOD", +"kALIAS","kDEFINED","klBEGIN","klEND","k__LINE__","k__FILE__","tIDENTIFIER", +"tFID","tGVAR","tIVAR","tCONSTANT","tINTEGER","tFLOAT","tSTRING","tXSTRING", +"tREGEXP","tDSTRING","tDXSTRING","tDREGEXP","tNTH_REF","tBACK_REF","tUPLUS", +"tUMINUS","tPOW","tCMP","tEQ","tEQQ","tNEQ","tGEQ","tLEQ","tANDOP","tOROP","tMATCH", +"tNMATCH","tDOT2","tDOT3","tAREF","tASET","tLSHFT","tRSHFT","tCOLON2","tCOLON3", +"tOP_ASGN","tASSOC","tLPAREN","tLBRACK","tLBRACE","tSTAR","tAMPER","tSYMBEG", +"'='","'?'","':'","'>'","'<'","'|'","'^'","'&'","'+'","'-'","'*'","'/'","'%'", +"'!'","'~'","LAST_TOKEN","'{'","'}'","'.'","')'","','","'['","']'","'`'","'('", +"'\\n'","';'","program","@1","compstmt","stmts","stmt","@2","@3","expr","command_call", +"mlhs","mlhs_entry","mlhs_basic","mlhs_item","mlhs_head","mlhs_tail","lhs","cname", +"fname","undef_list","@4","op","reswords","arg","@5","@6","@7","aref_args","opt_call_args", +"call_args","block_arg","opt_block_arg","opt_list","args","mrhs","ret_args", +"array","primary","@8","@9","@10","@11","@12","@13","@14","then","do","if_tail", +"opt_else","iter_var","opt_iter_var","iter_do_block","@15","iter_block","@16", +"iterator","method_call","case_body","when_args","cases","rescue","ensure","literal", +"symbol","numeric","variable","var_ref","backref","superclass","@17","f_arglist", +"f_args","f_arg","f_opt","f_optarg","f_rest_arg","f_block_arg","opt_f_block_arg", +"singleton","assoc_list","assocs","assoc","operation","dot_or_colon","opt_terms", +"opt_nl","trailer","term","terms", NULL +}; +#endif + +static const short yyr1[] = { 0, + 119, 118, 120, 121, 121, 121, 121, 122, 123, 122, + 122, 122, 122, 122, 122, 122, 122, 122, 124, 122, + 122, 122, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 126, 126, 126, 126, 127, 127, 128, 128, 129, + 129, 129, 129, 129, 130, 130, 131, 132, 132, 133, + 133, 133, 133, 134, 134, 135, 135, 135, 135, 135, + 136, 137, 136, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 141, 140, 140, 140, 140, 140, 142, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, + 140, 143, 140, 140, 140, 144, 145, 145, 146, 146, + 146, 146, 146, 146, 146, 146, 146, 147, 148, 148, + 149, 149, 150, 150, 151, 151, 151, 152, 153, 153, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 155, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 156, 154, 157, 154, 158, 154, + 159, 154, 160, 161, 154, 154, 154, 154, 154, 162, + 162, 162, 163, 163, 164, 164, 165, 165, 166, 166, + 167, 167, 167, 167, 169, 168, 171, 170, 172, 172, + 172, 172, 172, 173, 173, 173, 173, 173, 173, 174, + 175, 175, 175, 176, 176, 177, 177, 178, 178, 179, + 179, 179, 180, 180, 180, 181, 181, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 183, 184, 184, + 185, 186, 185, 185, 187, 187, 188, 188, 188, 188, + 188, 188, 188, 188, 188, 189, 189, 190, 191, 191, + 192, 193, 194, 194, 195, 195, 196, 196, 196, 197, + 197, 198, 199, 199, 199, 200, 200, 201, 201, 202, + 202, 203, 203, 203, 204, 204, 205, 205 +}; + +static const short yyr2[] = { 0, + 0, 2, 2, 0, 1, 3, 2, 2, 0, 4, + 3, 3, 3, 2, 3, 3, 3, 3, 0, 5, + 4, 1, 3, 2, 2, 1, 3, 3, 2, 2, + 1, 2, 4, 4, 2, 1, 3, 1, 3, 1, + 3, 2, 5, 2, 1, 3, 2, 1, 3, 1, + 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 4, 6, 5, 5, 3, 0, 4, 6, 5, + 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, + 3, 0, 4, 5, 1, 1, 0, 2, 1, 2, + 5, 2, 5, 4, 7, 3, 1, 2, 2, 0, + 1, 0, 1, 3, 1, 4, 2, 1, 0, 2, + 1, 3, 3, 2, 1, 1, 1, 1, 1, 1, + 1, 4, 3, 3, 4, 3, 1, 4, 3, 1, + 0, 6, 1, 2, 1, 2, 6, 6, 5, 5, + 4, 7, 6, 3, 0, 6, 0, 7, 0, 5, + 0, 6, 0, 0, 9, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 5, 0, 2, 1, 1, + 0, 2, 1, 3, 0, 5, 0, 5, 1, 1, + 1, 1, 1, 4, 6, 3, 6, 4, 1, 5, + 1, 4, 2, 1, 1, 5, 0, 0, 2, 1, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 4, 2, 4, 2, 6, 4, 4, 2, + 4, 2, 2, 1, 0, 1, 3, 3, 1, 3, + 2, 2, 2, 0, 1, 4, 0, 2, 2, 1, + 3, 3, 1, 1, 1, 1, 1, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 2 +}; + +static const short yydefact[] = { 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 246, 247, 248, 249, 217, 220, 279, + 303, 302, 304, 305, 0, 0, 350, 19, 0, 307, + 306, 343, 345, 300, 299, 344, 296, 297, 205, 207, + 292, 206, 208, 209, 309, 310, 0, 0, 0, 0, + 199, 337, 0, 0, 0, 0, 2, 348, 5, 22, + 26, 0, 36, 0, 40, 45, 31, 175, 0, 225, + 201, 290, 308, 210, 211, 0, 7, 54, 55, 0, + 0, 239, 100, 112, 101, 125, 97, 118, 107, 106, + 123, 105, 104, 99, 128, 109, 98, 113, 117, 119, + 111, 103, 120, 130, 122, 121, 114, 124, 108, 96, + 116, 115, 110, 126, 129, 127, 95, 102, 93, 94, + 91, 92, 56, 58, 57, 86, 87, 84, 68, 69, + 70, 73, 75, 71, 64, 88, 89, 76, 77, 0, + 81, 72, 74, 65, 66, 67, 78, 79, 80, 82, + 83, 85, 90, 241, 59, 60, 308, 335, 0, 121, + 114, 124, 108, 91, 92, 56, 57, 61, 14, 287, + 298, 223, 301, 0, 26, 225, 0, 0, 0, 0, + 217, 220, 279, 350, 260, 259, 0, 0, 50, 53, + 0, 0, 0, 0, 0, 0, 179, 193, 198, 187, + 190, 24, 175, 308, 211, 190, 340, 0, 25, 177, + 35, 29, 0, 9, 351, 172, 0, 0, 151, 175, + 152, 204, 0, 0, 0, 36, 193, 352, 0, 352, + 0, 352, 44, 295, 294, 293, 291, 30, 166, 167, + 356, 355, 3, 357, 349, 0, 0, 0, 0, 0, + 0, 0, 47, 0, 0, 48, 42, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 177, 265, 8, 267, 226, + 137, 131, 0, 0, 177, 32, 224, 0, 0, 312, + 235, 311, 0, 350, 325, 347, 346, 243, 62, 192, + 257, 251, 0, 250, 0, 0, 0, 254, 0, 253, + 0, 0, 0, 0, 177, 0, 190, 188, 216, 0, + 0, 0, 180, 0, 177, 0, 182, 219, 0, 0, + 350, 11, 13, 12, 0, 221, 0, 0, 0, 0, + 0, 234, 37, 354, 353, 200, 213, 339, 214, 354, + 338, 358, 6, 15, 16, 17, 18, 27, 28, 0, + 195, 23, 0, 41, 0, 150, 156, 161, 162, 163, + 158, 160, 170, 171, 164, 165, 143, 144, 168, 169, + 0, 157, 159, 153, 154, 155, 145, 146, 147, 148, + 149, 203, 345, 202, 0, 343, 344, 276, 0, 176, + 261, 261, 0, 0, 142, 136, 0, 237, 314, 0, + 0, 0, 0, 326, 0, 0, 325, 0, 0, 334, + 329, 334, 334, 324, 0, 0, 0, 191, 0, 288, + 257, 252, 257, 0, 281, 0, 231, 0, 0, 0, + 52, 344, 276, 0, 0, 0, 186, 215, 342, 0, + 194, 189, 190, 343, 0, 0, 0, 341, 218, 278, + 178, 10, 0, 173, 0, 21, 37, 194, 197, 0, + 46, 0, 49, 0, 177, 34, 0, 0, 0, 0, + 177, 33, 212, 263, 0, 0, 0, 138, 132, 274, + 0, 0, 0, 240, 336, 0, 331, 332, 350, 0, + 316, 0, 320, 0, 322, 0, 323, 244, 63, 0, + 0, 258, 0, 0, 0, 0, 255, 0, 283, 0, + 0, 229, 230, 51, 0, 190, 0, 184, 212, 190, + 0, 20, 0, 43, 174, 0, 140, 134, 141, 135, + 0, 0, 0, 262, 0, 0, 0, 0, 313, 236, + 328, 0, 242, 327, 334, 334, 333, 0, 330, 334, + 325, 287, 289, 233, 0, 227, 228, 0, 257, 0, + 181, 0, 183, 222, 196, 277, 275, 139, 133, 264, + 266, 268, 238, 315, 0, 318, 319, 321, 0, 286, + 0, 282, 284, 285, 280, 232, 190, 334, 0, 257, + 185, 317, 245, 256, 0, 0, 0 +}; + +static const short yydefgoto[] = { 615, + 1, 224, 58, 59, 345, 217, 60, 61, 62, 225, + 63, 64, 65, 257, 66, 81, 154, 169, 436, 155, + 156, 67, 414, 413, 347, 409, 410, 341, 200, 333, + 437, 201, 372, 202, 229, 220, 473, 421, 501, 303, + 305, 435, 571, 313, 319, 526, 527, 188, 496, 288, + 411, 290, 412, 69, 176, 317, 446, 605, 311, 524, + 71, 237, 72, 204, 74, 205, 301, 420, 428, 429, + 430, 431, 432, 433, 567, 513, 159, 231, 206, 207, + 191, 308, 243, 216, 356, 314, 245 +}; + +static const short yypact[] = {-32768, + 1581, 4673, 29, 135, 4070, 4379, 2015, 4763, 4763, 2487, + 4763, 4763, 5841,-32768,-32768,-32768,-32768, 3427, 3517, 3607, +-32768,-32768,-32768,-32768, 4763, 4276, -45,-32768, 39,-32768, +-32768, 1679, 1898,-32768,-32768, 1793,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768, 5573, 5573, 135, 2578, + 5573, 5573, 6105, 4173, 5663, 5573,-32768, -25, 338, 93, + 136, 64,-32768, 59, 5929,-32768, 6104, 0, 147, 22, +-32768,-32768, 122,-32768, 168, 3067, 338,-32768,-32768, 4763, + 41,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768, -9, 1, 2, 12,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 79, 85, 125,-32768, 130,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 4763, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 175,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 74, 212, + 3157, 3247, 3337, 33,-32768, 118, 33, 221, 21, 21, + 155, 172, 177, -45,-32768, 192, 62, 285, 71, 78, + -17, 2686, 5573, 5573, 5573, 4483,-32768, 1089,-32768,-32768, + 205,-32768, 80, 210, 222, 211,-32768, 4578,-32768, 4853, +-32768,-32768, 36,-32768,-32768, 215, 230, 2794, 284, 143, + 284,-32768, 2578, 251, 257, 258, 6104, -22, 243, -22, + 264, 92,-32768,-32768,-32768,-32768,-32768,-32768, 284, 284, +-32768,-32768,-32768,-32768, 2976, 4763, 4763, 4763, 4763, 4763, + 4763, 5213,-32768, 2578, 6105,-32768, 268, 5573, 5573, 5573, + 5573, 5573, 5573, 5573, 5573, 5573, 5573, 5573, 5573, 5573, + 5573, 5573, 5573, 5573, 5573, 5573, 5573, 5573, 5573, 5573, + 5573, 5573, 5573, 235, 280, 4853,-32768,-32768,-32768,-32768, +-32768,-32768, 5573, 5573, 4853,-32768,-32768, 31, -25,-32768, +-32768,-32768, 2885, 28, -2,-32768,-32768,-32768,-32768, 5573, + 365,-32768, 2123, 382, 2305, 5303, 387,-32768, 2885,-32768, + 2885, 215, 235, 306, 4853, 4763, 749, 6104,-32768, 288, + 5573, 4943,-32768, 311, 4853, 5033,-32768,-32768, 290, 293, + -45,-32768,-32768,-32768, 4379,-32768, 5573, 2794, 297, 311, + 298,-32768, 299, 5573,-32768,-32768,-32768,-32768,-32768, 5573, +-32768,-32768, 338, 93, 93, 93, 93,-32768,-32768, 5573, + 300,-32768, 302,-32768, 6017, 284, 670, 670, 670, 670, + 286, 286, 1385, 6184, 670, 670, 6144, 6144, 129, 129, + 1339, 286, 286, 99, 99, 291, 66, 66, 284, 284, + 284, 3697,-32768, 3787, 3877, 197, 226, 3967, 296,-32768, + 68, 68, 5573, 5573, 6104, 6104, 304,-32768,-32768, 4763, + 2885, 391, 305, 326, 375, 376, 13, 2885, -25, 313, +-32768, 314, 315,-32768, 4379, 4379, 15, 318, 2396, 422, + 246,-32768, 365, 5573, 321, 25,-32768, 423, 425, 322, + 103,-32768, 324, 327, 21, 352,-32768,-32768, 6104, 5573, + 1089,-32768, 333, 232, 332, 5573, 1089,-32768,-32768,-32768, +-32768,-32768, 4763, 6104, 339,-32768, 253, 6104, 6104, 5393, +-32768, 6105,-32768, 5573, 4853,-32768, 5573, 5573, 5573, 5573, + 4853,-32768, 208,-32768, 5753, 2885, 2794, 6104, 6104,-32768, + 2885, 31, 439,-32768,-32768, 5573,-32768,-32768, -45, 440, +-32768, 26,-32768, 30,-32768, 362,-32768,-32768,-32768, 2015, + 5573,-32768, 2885, 443, 4763, 444,-32768, 445, 6104, 5483, + 2214,-32768,-32768, 160, 2885, 749, 5123,-32768, 238, 749, + 23,-32768, 5573,-32768, 6104, 346, 6104, 6104, 6104, 6104, + 347, 5573, 5573,-32768, 363, 448, 353, 450,-32768,-32768, + 6104, 355,-32768, 326, 351, 315,-32768, 326,-32768, 315, + -2, 212,-32768,-32768, 33,-32768,-32768, 5573, 206, 457, +-32768, 5573,-32768,-32768, 6104,-32768,-32768, 6104, 6104,-32768, +-32768,-32768,-32768,-32768, 30,-32768,-32768,-32768, 2885,-32768, + 2123, 6104,-32768,-32768,-32768,-32768, 749, 315, 458, 246, +-32768,-32768,-32768,-32768, 469, 470,-32768 +}; + +static const short yypgoto[] = {-32768, +-32768, 479,-32768, 32,-32768,-32768, 95, 1321, -10, -149, + -27, -49,-32768,-32768, 16, 46, 7,-32768,-32768,-32768, +-32768, 1012,-32768,-32768,-32768, -247, -196, 8, -300, -201, +-32768, -12,-32768, 18,-32768, -1,-32768,-32768,-32768,-32768, +-32768,-32768,-32768, -173, -159, -139, -289, -20, 61,-32768, +-32768, -46,-32768,-32768, 115, -103,-32768,-32768, -95,-32768, +-32768,-32768,-32768, 616, 473, 698,-32768,-32768, -89, 56, +-32768, -444, -24, -461, -274, -389,-32768,-32768, -32, -301, + 256,-32768,-32768, -169, 119, -56,-32768 +}; + + +#define YYLAST 6287 + + +static const short yytable[] = { 68, + 68, 244, 185, 315, 337, 68, 68, 68, 68, 68, + 68, 187, 168, 340, 322, 256, 203, 203, 203, 232, + 321, 440, 226, 68, 302, 199, 199, 211, 186, 297, + 434, 462, 214, 77, 468, 462, 209, 312, 228, 230, + 318, 299, 515, 517, 424, 312, 318, -272, 68, 82, + 566, 187, 570, 203, 250, 251, 250, 251, 468, 424, + 236, 250, 251, 187, 250, 251, 250, 251, 233, 569, + 215, -303, 564, 351, 203, 78, 568, 454, 68, 79, + 284, -302, -304, 296, 342, 425, 426, 465, 354, 289, + 241, 242, -305, 355, 222, 343, 344, 295, 417, -303, + 425, 426, 174, 177, 373, 179, 180, 80, 285, -302, + -304, 286, 427, 425, 426, 70, 70, 425, 426, 212, + -305, 70, 320, 320, 70, 457, 250, 251, 289, 258, + 241, 242, 584, 608, 423, 300, 241, 242, 68, 494, + 241, 242, 323, 215, 297, 218, 241, 242, 241, 242, + 569, -308, 434, 528, 252, 462, 241, 242, -211, -307, + 284, -273, 258, 495, 70, -306, 281, 282, 283, 253, + 324, 471, 287, 325, 298, 596, 597, 271, 272, -308, + 598, 78, -308, -343, 309, 79, -211, -307, 334, -211, + 68, 335, 258, -306, 203, 226, 278, 279, 280, 281, + 282, 283, 360, 199, 291, -298, 203, 355, 203, -343, + -301, -343, 292, 330, -343, 199, 68, -343, 612, 310, + 439, 68, 316, 323, 289, 339, 226, 279, 280, 281, + 282, 283, -50, -298, 304, 468, 462, 316, -301, 371, + -212, 418, 419, 68, 68, 68, 68, 68, 68, 68, + 293, 350, 68, 187, 335, 306, 76, 76, 294, 525, + 439, 538, 76, 76, 76, 76, 76, 76, -212, 196, + 374, -212, 531, 76, 76, 76, 363, 520, -53, 487, + 76, 402, 403, 307, 203, 404, 208, 488, 546, 603, + 552, 210, 291, 203, 551, 535, 434, 438, 553, 463, + 292, 68, -45, 445, 293, 76, 70, -52, 489, 326, + 76, 68, 294, 68, 487, 332, 490, 68, -51, 68, + 552, 336, 488, 203, 68, 483, 406, 403, 553, 346, + 407, 76, 70, 203, 581, 76, 348, 70, 583, 562, + 364, 365, 366, 367, 368, 369, 68, 258, 358, 258, + 361, 472, 451, 403, 258, 357, 452, 464, 403, 70, + 352, 407, -39, -46, 271, 272, 353, -38, 70, 271, + 272, 359, 511, 187, 246, 247, 248, 249, 375, 439, + 320, 276, 277, 278, 279, 280, 281, 282, 283, 279, + 280, 281, 282, 283, 442, 76, 447, 458, 320, 469, + 504, 601, 470, 203, 476, 611, 203, 477, 493, -46, + 480, 481, 486, 500, 505, 492, 506, 70, 68, 68, + 455, 507, 508, 512, 514, 516, 68, 70, 521, 70, + 523, 530, 532, 70, 533, 70, 485, 68, 491, 534, + 194, 518, 519, 537, 539, 559, 542, 76, 560, 563, + 426, 76, 574, 576, 577, 586, 587, 591, 590, 593, + 592, 595, 70, 76, 594, 76, 606, 613, 616, 617, + 614, 68, 497, 76, 555, 604, 600, 158, 76, 57, + 187, 599, 509, 203, 185, 170, 0, 565, 178, 203, + 0, 0, 0, 187, 68, 68, 0, 544, 0, 68, + 76, 76, 76, 76, 76, 76, 76, 0, 0, 76, + 186, 0, 0, 0, 502, 0, 0, 0, 68, 0, + 0, 68, 0, 68, 0, 0, 0, 0, 0, 68, + 0, 0, 0, 68, 0, 70, 0, 0, 0, 405, + 408, 76, 70, 0, 0, 0, 0, 0, 0, 0, + 76, 0, 0, 70, 0, 0, 0, 0, 76, 0, + 0, 0, 0, 0, 0, 0, 0, 541, 76, 0, + 76, 0, 0, 0, 76, 0, 76, 0, 450, 453, + 76, 76, 0, 0, 0, 0, 0, 0, 0, 408, + 76, 0, 0, 0, 0, 0, 0, 68, 0, 68, + 0, 0, 0, 76, 0, 453, 0, 0, 0, 0, + 70, 70, 0, 0, 0, 70, 73, 73, 0, 575, + 157, 0, 73, 73, 73, 73, 73, 73, 189, 0, + 0, 0, 0, 0, 70, 0, 0, 70, 0, 0, + 73, 0, 0, 0, 0, 70, 0, 0, 0, 70, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 76, 0, 0, 76, 0, 73, 0, 0, 189, 0, + 0, 0, 0, 0, 0, 76, 76, 0, 0, 0, + 189, 0, 0, 76, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 76, 73, 349, 0, 75, 75, + 0, 0, 0, 0, 75, 75, 75, 75, 75, 75, + 190, 0, 0, 70, 0, 70, 0, 0, 0, 0, + 0, 0, 75, 0, 0, 0, 0, 0, 76, 0, + 0, 0, 0, 258,-32768,-32768,-32768,-32768, 263, 264, + 76, 0,-32768,-32768, 0, 0, 76, 75, 271, 272, + 190, 76, 76, 0, 0, 73, 76, 0, 0, 0, + 0, 0, 190, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 283, 0, 0, 76, 0, 75, 76, 0, + 76, 422, 0, 0, 0, 0, 76, 0, 0, 0, + 76, 441, 0, 443, 0, 0, 0, 448, 0, 449, + 0, 0, 0, 0, 0, 0, 0, 73, 0, 0, + 0, 0, 258, 259, 260, 261, 262, 263, 264, 265, + 266, 267, 268, 269, 270, 0, 475, 271, 272, 0, + 0, 0, 0, 73, 0, 0, 0, 75, 73, 0, + 273, 0, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 0, 0, 76, 0, 76, 0, 0, 456, + 73, 73, 73, 73, 73, 73, 73, 0, 0, 73, + 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 503, + 0, 0, 0, 0, 0, 0, 510, 0, 0, 0, + 0, 0, 0, 0, 0, 75, 0, 522, 73, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 73, 0, + 73, 0, 0, 0, 73, 0, 73, 0, 0, 0, + 0, 73, 75, 75, 75, 75, 75, 75, 75, 0, + 0, 75, 190, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 556, 557, 0, 0, 0, 558, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 189, 0, 0, 0, 0, 0, 0, 0, 572, 0, + 75, 573, 0, 0, 0, 0, 0, 0, 0, 579, + 75, 0, 75, 580, 0, 0, 75, 0, 75, 0, + 0, 0, 0, 75, 0, 0, 0, 0, 0, 198, + 198, 198, 0, 0, 0, 73, 73, 0, 0, 0, + 0, 0, 0, 73, 0, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 73, 0, 0, 0, 219, 221, + 0, 0, 227, 198, 0, 0, 239, 240, 0, 0, + 0, 0, 190, 0, 0, 0, 0, 609, 0, 610, + 0, 0, 0, 0, 0, 0, 0, 198, 73, 0, + 0, 0, 0, 0, 0, 0, 0, 189, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 189, 73, 73, 0, 0, 0, 73, 75, 75, 0, + 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 73, 75, 0, 73, 0, + 73, 0, 0, 0, 0, 0, 73, 0, 0, 0, + 73, 0, 258, 259, 260, 261, 262, 263, 264, 265, + 266, 267, 268, 269, 270, 0, 0, 271, 272, 0, + 75, 0, 331, 0, 0, 0, 0, 0, 0, 190, + 273, 0, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 190, 75, 75, 0, 0, 0, 75, 0, + 0, 0, 0, 0, 327, 328, 239, 198, 0, 0, + 0, 0, 0, 0, 73, 0, 73, 75, 0, 198, + 75, 198, 75, 0, 0, 0, 0, 0, 75, 0, + 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 227, 0, 0, 0, 0, 0, 376, + 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, + 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, + 397, 398, 399, 400, 401, 0, 75, 198, 75, 0, + 0, 0, 0, 0, 415, 416, 198, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 227, 0, 0, 0, 0, 0, 227, 175, 175, + 0, 175, 175, 0, 0, 0, 198, 0, 197, 197, + 197, 0, 459, 461, 0, 175, 198, 467, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 474, 0, + 0, 0, 0, 0, 0, 478, 0, 0, 0, 0, + 0, 467, 0, 0, 0, 238, 0, 0, 0, 0, + 0, 479, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 197, 0, 0, 0, + 175, 0, 258, 259, 260, 261, 262, 263, 264, 265, + 266, 267, 268, 269, 270, 0, 198, 271, 272, 198, + 0, 0, 0, 0, 498, 499, 0, 0, 0, 0, + 273, 484, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 0, 0, 0, 0, 0, 0, 258, 259, + 260, 261, 262, 263, 264, 529, 0, 267, 268, 0, + 175, 0, 0, 271, 272, 0, 0, 0, 0, 0, + 0, 536, 0, 0, 0, 0, 0, 540, 274, 275, + 276, 277, 278, 279, 280, 281, 282, 283, 0, 0, + 0, 478, 0, 0, 0, 545, 198, 0, 547, 548, + 549, 550, 198, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 197, 561, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 197, 0, + 197, 0, 478, 0, 0, 0, 0, 0, 0, 0, + 0, 478, 0, 0, 0, 0, 0, 0, 467, 0, + 0, 0, 0, 0, 585, 0, 0, 0, 0, 0, + 0, 0, 0, 588, 589, 0, 175, 175, 175, 175, + 175, 175, 0, 0, 0, 0, 0, 0, 0, 0, + -4, 2, 0, 3, 4, 5, 6, 7, 0, 602, + 0, 8, 9, 607, 0, 0, 10, 0, 11, 12, + 13, 14, 15, 16, 17, 0, 197, 18, 19, 20, + 21, 22, 23, 24, 0, 197, 25, 0, 0, 0, + 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 0, 197, 175, 0, 0, 0, + 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 50, 51, 52, 53, 0, + 54, 0, 0, 0, 0, 0, 0, 0, -298, 0, + 0, 0, 0, 0, 55, 56, -298, -298, -298, 0, + 0, 0, -298, -298, 0, -298, -4, -4, 0, 0, + 0, 0, 0, 0, -269, 0, 0, 0, 0, 0, + 0, 0, -298, -298, 0, -298, -298, -298, -298, 0, + 0, 0, 0, 0, 0, 197, 0, 0, 197, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 175, 0, -298, -298, -298, -298, -298, -298, -298, -298, + -298, -298, -298, -298, -298, 0, 0, -298, -298, -298, + 0, -298, 0, 0, 0, 0, 0, 0, 0, -298, + -298, 0, -298, -298, -298, -298, -298, -298, -298, -298, + -298, -298, 0, 0, 0, 0, -298, -298, -298, -298, + -298, 0, -301, 175, -298, -298, 0, 0, 0, 0, + -301, -301, -301, 0, 0, 197, -301, -301, 0, -301, + 0, 197, 0, 0, 0, 0, 0, 0, -270, 0, + 0, 0, 0, 0, 0, 0, -301, -301, 0, -301, + -301, -301, -301, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 175, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -301, -301, -301, -301, + -301, -301, -301, -301, -301, -301, -301, -301, -301, 0, + 0, -301, -301, -301, 0, -301, 0, 0, 0, 0, + 0, 0, 0, -301, -301, 0, -301, -301, -301, -301, + -301, -301, -301, -301, -301, -301, 0, -223, 0, 0, + -301, -301, -301, -301, -301, -223, -223, -223, -301, -301, + 0, -223, -223, 0, -223, 0, 0, 0, 0, 0, + 0, 0, 0, -271, 0, 0, 0, 0, 0, 0, + 0, -223, -223, 0, -223, -223, -223, -223, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -223, -223, -223, -223, -223, -223, -223, -223, -223, + -223, -223, -223, -223, 0, 0, -223, -223, -223, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -223, + 0, -223, -223, -223, -223, -223, -223, -223, -223, -223, + -223, 0, 0, 0, 0, -223, -223, -223, 0, -223, + 0, 0, 0, -223, -223, 2, 0, 3, 4, 5, + 6, 7, -4, -4, -4, 8, 9, 0, 0, -4, + 10, 0, 11, 12, 13, 14, 15, 16, 17, 0, + 0, 18, 19, 20, 21, 22, 23, 24, 0, 0, + 25, 0, 0, 0, 0, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 49, 0, 0, 50, + 51, 52, 53, 0, 54, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 55, 56, + 0, 0, 0, 2, 0, 3, 4, 5, 6, 7, + -4, -4, -4, 8, 9, 0, -4, -4, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 0, 0, 25, 0, + 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 50, 51, 52, + 53, 0, 54, 0, 2, 0, 3, 4, 5, 6, + 7, 0, 0, -4, 8, 9, 55, 56, -4, 10, + -4, 11, 12, 13, 14, 15, 16, 17, -4, -4, + 18, 19, 20, 21, 22, 23, 24, 0, 0, 25, + 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 49, 0, 0, 50, 51, + 52, 53, 0, 54, 0, 2, 0, 3, 4, 5, + 6, 7, 0, 0, -4, 8, 9, 55, 56, -4, + 10, 0, 11, 12, 13, 14, 15, 16, 17, -4, + -4, 18, 19, 20, 21, 22, 23, 24, 0, 0, + 25, 0, 0, 0, 0, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 49, 0, 0, 50, + 51, 52, 53, 0, 54, 0, 2, 0, 3, 4, + 5, 6, 7, 0, -4, -4, 8, 9, 55, 56, + 0, 10, 0, 11, 12, 13, 14, 15, 16, 17, + -4, -4, 18, 19, 20, 21, 22, 23, 24, 0, + 0, 25, 0, 0, 0, 0, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, + 50, 51, 52, 53, 0, 54, 0, 2, 0, 3, + 4, 5, 6, 7, 0, 0, 0, 8, 9, 55, + 56, 0, 10, -4, 11, 12, 13, 14, 15, 16, + 17, -4, -4, 18, 19, 20, 21, 22, 23, 24, + 0, 0, 25, 0, 0, 0, 0, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 50, 51, 52, 53, 0, 54, 0, 2, 0, + 3, 4, 5, 6, 7, 0, 0, 0, 8, 9, + 55, 56, 0, 10, 0, 11, 12, 13, 14, 15, + 16, 17, -4, -4, 18, 19, 20, 21, 22, 23, + 24, 0, 0, 25, 0, 0, 0, 0, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, + 0, 0, 223, 51, 52, 53, 0, 54, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 55, 56, 0, 0, 0, 2, -4, 3, 4, + 5, 6, 7, -4, -4, 0, 8, 9, 0, 0, + 0, 10, 0, 11, 12, 13, 14, 15, 16, 17, + 0, 0, 18, 19, 20, 21, 22, 23, 24, 0, + 0, 25, 0, 0, 0, 0, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, + 50, 51, 52, 53, 0, 54, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, + 56, 0, 0, 0, 2, -4, 3, 4, 5, 6, + 7, -4, -4, 0, 8, 9, 0, 0, 0, 10, + 0, 11, 12, 13, 14, 15, 16, 17, 0, 0, + 18, 19, 20, 21, 22, 23, 24, 0, 0, 25, + 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 49, 0, 0, 50, 51, + 52, 53, 0, 54, 0, 2, 0, 3, 4, 5, + 6, 7, 0, 0, -4, 8, 9, 55, 56, 0, + 10, -4, 11, 12, 13, 14, 15, 16, 17, -4, + -4, 18, 19, 20, 21, 22, 23, 24, 0, 0, + 25, 0, 0, 0, 0, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 49, 0, 0, 50, + 51, 52, 53, 0, 54, 0, 0, 0, 3, 4, + 5, 6, 7, 0, 0, 0, 8, 9, 55, 56, + 0, 10, 0, 11, 12, 13, 14, 15, 16, 17, + -4, -4, 18, 19, 20, 21, 22, 23, 24, 0, + 0, 25, 0, 0, 0, 0, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, + 50, 51, 52, 53, 0, 54, 0, 0, 0, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 55, + 56, 0, 10, 0, 11, 12, 13, 14, 15, 16, + 17, 0, 362, 181, 182, 20, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 192, 51, 52, 193, 194, 54, 0, 0, -343, + -343, -343, 0, -343, 0, 0, 0, -343, -343, 0, + 195, 56, -343, 289, -343, -343, -343, -343, -343, -343, + -343, 295, 0, -343, -343, -343, -343, -343, -343, -343, + 0, 0, 0, 0, 0, 0, 0, 0, -343, 0, + 0, -343, -343, -343, -343, -343, -343, -343, -343, -343, + -343, -343, -343, -343, -343, -343, -343, -343, -343, -343, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -343, 0, + 0, -343, -343, -343, -343, -343, -343, 0, 0, -345, + -345, -345, 0, -345, 0, 0, 0, -345, -345, 0, + -343, -343, -345, -343, -345, -345, -345, -345, -345, -345, + -345, -343, 0, -345, -345, -345, -345, -345, -345, -345, + 0, 0, 0, 0, 0, 0, 0, 0, -345, 0, + 0, -345, -345, -345, -345, -345, -345, -345, -345, -345, + -345, -345, -345, -345, -345, -345, -345, -345, -345, -345, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -345, 0, + 0, -345, -345, -345, -345, -345, -345, 0, 0, -344, + -344, -344, 0, -344, 0, 0, 0, -344, -344, 0, + -345, -345, -344, -345, -344, -344, -344, -344, -344, -344, + -344, -345, 0, -344, -344, -344, -344, -344, -344, -344, + 0, 0, 0, 0, 0, 0, 0, 0, -344, 0, + 0, -344, -344, -344, -344, -344, -344, -344, -344, -344, + -344, -344, -344, -344, -344, -344, -344, -344, -344, -344, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -344, 0, + 0, -344, -344, -344, -344, -344, -344, 0, 0, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 0, + -344, -344, 10, -344, 11, 12, 13, 14, 15, 16, + 17, -344, 0, 181, 182, 20, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 192, 51, 52, 193, 194, 54, 0, 0, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 0, + 195, 56, 10, 0, 11, 12, 13, 14, 15, 16, + 17, 196, 0, 181, 182, 20, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 192, 51, 52, 193, 194, 54, 0, 0, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 0, + 195, 56, 10, 0, 11, 12, 13, 14, 15, 16, + 17, 208, 0, 181, 182, 20, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 192, 51, 52, 193, 194, 54, 0, 0, -343, + -343, -343, 0, -343, 0, 0, 0, -343, -343, 0, + 195, 56, -343, 0, -343, -343, -343, -343, -343, -343, + -343, 210, 0, -343, -343, -343, -343, -343, -343, -343, + 0, 0, 0, 0, 0, 0, 0, 0, -343, 0, + 0, -343, -343, -343, -343, -343, -343, -343, -343, -343, + -343, -343, -343, -343, -343, -343, -343, -343, -343, -343, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -343, 0, + 0, -343, -343, -343, -343, -343, -343, 0, 0, -344, + -344, -344, 0, -344, 0, 0, 0, -344, -344, 0, + -343, -343, -344, 0, -344, -344, -344, -344, -344, -344, + -344, -343, 0, -344, -344, -344, -344, -344, -344, -344, + 0, 0, 0, 0, 0, 0, 0, 0, -344, 0, + 0, -344, -344, -344, -344, -344, -344, -344, -344, -344, + -344, -344, -344, -344, -344, -344, -344, -344, -344, -344, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -344, 0, + 0, -344, -344, -344, -344, -344, -344, 0, 0, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 0, + -344, -344, 10, 0, 11, 12, 13, 14, 15, 16, + 17, -344, 0, 181, 182, 20, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 192, 51, 52, 193, 194, 54, 0, 0, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 0, + 195, 56, 10, 0, 11, 12, 13, 14, 15, 16, + 17, 485, 0, 181, 182, 20, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 192, 51, 52, 193, 194, 54, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 195, 56, 83, 84, 85, 86, 87, 88, 89, 90, + 0, 491, 91, 92, 93, 94, 95, 0, 0, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 34, 35, + 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 126, 127, 128, 129, 130, 131, 0, 132, 133, + 0, 0, 134, 0, 135, 0, 136, 137, 138, 139, + 0, 0, 0, 0, 140, 0, 0, 141, 0, 0, + 0, 0, 0, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 0, 152, 83, 84, 85, 86, 87, + 88, 89, 90, 153, 0, 91, 92, 93, 94, 95, + 0, 0, 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 160, 161, 162, 163, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 164, 165, 166, + 124, 234, 235, 167, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 126, 127, 128, 129, 130, 131, + 0, 132, 133, 0, 0, 134, 0, 135, 0, 136, + 137, 138, 139, 0, 0, 0, 0, 0, 0, 0, + 141, 0, 0, 0, 0, 0, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 0, 152, 83, 84, + 85, 86, 87, 88, 89, 90, 153, 0, 91, 92, + 93, 94, 95, 0, 0, 96, 97, 98, 99, 100, + 101, 102, 103, 104, 105, 160, 161, 162, 163, 110, + 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, + 164, 165, 166, 124, 213, 0, 167, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 126, 127, 128, + 129, 130, 131, 0, 132, 133, 0, 0, 134, 0, + 135, 0, 136, 137, 138, 139, 0, 0, 0, 0, + 0, 0, 0, 141, 0, 0, 0, 0, 0, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 0, + 152, 83, 84, 85, 86, 87, 88, 89, 90, 153, + 0, 91, 92, 93, 94, 95, 0, 0, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 160, 161, + 162, 163, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 164, 165, 166, 124, 0, 0, 167, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 126, 127, 128, 129, 130, 131, 0, 132, 133, 0, + 0, 134, 0, 135, 0, 136, 137, 138, 139, 0, + 0, 0, 0, 0, 0, 0, 141, 0, 0, 0, + 0, 0, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 0, 152, 0, 3, 4, 5, 0, 7, + 0, 0, 153, 8, 9, 0, 0, 0, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 20, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 193, 194, 54, 0, 0, 0, 0, 0, 0, 0, + 3, 4, 5, 0, 7, 0, 195, 56, 8, 9, + 0, 0, 329, 10, 0, 11, 12, 13, 14, 15, + 16, 17, 0, 0, 181, 182, 20, 21, 22, 23, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 27, + 0, 0, 30, 31, 171, 172, 34, 35, 173, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, + 0, 0, 192, 51, 52, 193, 194, 54, 0, 0, + 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, + 0, 195, 56, 8, 9, 0, 0, 338, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 0, 0, 25, 0, + 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 50, 51, 52, + 53, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 55, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 0, 0, 25, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 50, 51, 52, + 53, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 55, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 20, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 193, 194, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 460, 194, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 466, 194, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 582, 194, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 370, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 444, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 543, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 578, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 0, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 20, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 27, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 192, 51, 52, + 0, 0, 54, 0, 0, 3, 4, 5, 0, 7, + 0, 0, 0, 8, 9, 0, 195, 56, 10, 0, + 11, 12, 13, 14, 15, 16, 17, 0, 0, 181, + 182, 183, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 184, 0, 0, 30, 31, 171, + 172, 34, 35, 173, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 0, 50, 51, 52, + 53, 0, 54, 3, 4, 5, 0, 7, 554, 0, + 0, 8, 9, 0, 0, 0, 10, 0, 11, 12, + 13, 14, 15, 16, 17, 0, 0, 181, 182, 183, + 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, + 0, 0, 184, 0, 0, 30, 31, 171, 172, 34, + 35, 173, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 49, 0, 0, 50, 51, 52, 53, 0, + 54, 3, 4, 5, 0, 7, 0, 0, 0, 8, + 9, 0, 0, 0, 10, 0, 11, 12, 13, 14, + 15, 16, 17, 0, 0, 181, 182, 183, 21, 22, + 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, + 184, 0, 0, 30, 31, 171, 172, 34, 35, 173, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 49, 0, 0, 254, 51, 52, 255, 0, 54, 3, + 4, 5, 0, 7, 0, 0, 0, 8, 9, 0, + 0, 0, 10, 0, 11, 12, 13, 14, 15, 16, + 17, 0, 0, 181, 182, 183, 21, 22, 23, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 184, 0, + 0, 30, 31, 171, 172, 34, 35, 173, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, + 0, 254, 51, 52, 482, 0, 54, 3, 4, 5, + 0, 7, 0, 0, 0, 8, 9, 0, 0, 0, + 10, 0, 11, 12, 13, 14, 15, 16, 17, 0, + 0, 181, 182, 183, 21, 22, 23, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 184, 0, 0, 30, + 31, 171, 172, 34, 35, 173, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 0, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 0, 0, 271, 272, 0, 0, 49, 0, 0, 192, + 51, 52, 0, 0, 54, 273, 0, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268,-32768,-32768, + 0, 0, 271, 272, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 258, 259, 260, + 261, 262, 263, 264, 265, 0, 267, 268, 0, 0, + 0, 0, 271, 272, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283 +}; + +static const short yycheck[] = { 1, + 2, 58, 13, 177, 206, 7, 8, 9, 10, 11, + 12, 13, 6, 210, 184, 65, 18, 19, 20, 52, + 180, 311, 50, 25, 81, 18, 19, 20, 13, 76, + 305, 332, 26, 2, 336, 336, 19, 13, 51, 52, + 26, 1, 432, 433, 47, 13, 26, 26, 50, 4, + 512, 53, 514, 55, 34, 35, 34, 35, 360, 47, + 54, 34, 35, 65, 34, 35, 34, 35, 53, 514, + 116, 81, 47, 223, 76, 47, 47, 325, 80, 51, + 81, 81, 81, 76, 49, 88, 89, 335, 111, 107, + 116, 117, 81, 116, 49, 60, 61, 115, 295, 109, + 88, 89, 8, 9, 254, 11, 12, 79, 109, 109, + 109, 112, 115, 88, 89, 1, 2, 88, 89, 25, + 109, 7, 179, 180, 10, 327, 34, 35, 107, 64, + 116, 117, 110, 595, 304, 95, 116, 117, 140, 72, + 116, 117, 81, 116, 191, 107, 116, 117, 116, 117, + 595, 81, 427, 443, 91, 456, 116, 117, 81, 81, + 81, 26, 64, 96, 50, 81, 101, 102, 103, 111, + 109, 341, 26, 112, 80, 565, 566, 79, 80, 109, + 570, 47, 112, 81, 111, 51, 109, 109, 109, 112, + 192, 112, 64, 109, 196, 223, 98, 99, 100, 101, + 102, 103, 111, 196, 83, 81, 208, 116, 210, 107, + 81, 109, 91, 196, 112, 208, 218, 115, 608, 8, + 15, 223, 17, 81, 107, 208, 254, 99, 100, 101, + 102, 103, 111, 109, 140, 537, 537, 17, 109, 252, + 81, 298, 299, 245, 246, 247, 248, 249, 250, 251, + 83, 109, 254, 255, 112, 81, 1, 2, 91, 14, + 15, 463, 7, 8, 9, 10, 11, 12, 109, 115, + 255, 112, 446, 18, 19, 20, 245, 437, 111, 83, + 25, 47, 48, 109, 286, 51, 115, 91, 485, 579, + 83, 115, 83, 295, 491, 455, 571, 310, 91, 332, + 91, 303, 111, 316, 83, 50, 192, 111, 83, 25, + 55, 313, 91, 315, 83, 111, 91, 319, 111, 321, + 83, 111, 91, 325, 326, 375, 47, 48, 91, 115, + 51, 76, 218, 335, 536, 80, 107, 223, 540, 509, + 246, 247, 248, 249, 250, 251, 348, 64, 230, 64, + 232, 345, 47, 48, 64, 113, 51, 47, 48, 245, + 110, 51, 110, 111, 79, 80, 110, 110, 254, 79, + 80, 108, 429, 375, 37, 38, 39, 40, 111, 15, + 437, 96, 97, 98, 99, 100, 101, 102, 103, 99, + 100, 101, 102, 103, 13, 140, 10, 110, 455, 110, + 10, 575, 110, 405, 108, 607, 408, 110, 113, 111, + 111, 110, 405, 110, 110, 408, 91, 303, 420, 421, + 326, 47, 47, 111, 111, 111, 428, 313, 111, 315, + 9, 111, 10, 319, 10, 321, 115, 439, 115, 113, + 89, 435, 436, 111, 113, 502, 108, 192, 10, 10, + 89, 196, 10, 10, 10, 110, 110, 10, 96, 10, + 108, 111, 348, 208, 110, 210, 10, 10, 0, 0, + 610, 473, 412, 218, 495, 579, 572, 5, 223, 1, + 482, 571, 427, 485, 495, 7, -1, 512, 10, 491, + -1, -1, -1, 495, 496, 497, -1, 482, -1, 501, + 245, 246, 247, 248, 249, 250, 251, -1, -1, 254, + 495, -1, -1, -1, 420, -1, -1, -1, 520, -1, + -1, 523, -1, 525, -1, -1, -1, -1, -1, 531, + -1, -1, -1, 535, -1, 421, -1, -1, -1, 284, + 285, 286, 428, -1, -1, -1, -1, -1, -1, -1, + 295, -1, -1, 439, -1, -1, -1, -1, 303, -1, + -1, -1, -1, -1, -1, -1, -1, 473, 313, -1, + 315, -1, -1, -1, 319, -1, 321, -1, 323, 324, + 325, 326, -1, -1, -1, -1, -1, -1, -1, 334, + 335, -1, -1, -1, -1, -1, -1, 599, -1, 601, + -1, -1, -1, 348, -1, 350, -1, -1, -1, -1, + 496, 497, -1, -1, -1, 501, 1, 2, -1, 525, + 5, -1, 7, 8, 9, 10, 11, 12, 13, -1, + -1, -1, -1, -1, 520, -1, -1, 523, -1, -1, + 25, -1, -1, -1, -1, 531, -1, -1, -1, 535, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 405, -1, -1, 408, -1, 50, -1, -1, 53, -1, + -1, -1, -1, -1, -1, 420, 421, -1, -1, -1, + 65, -1, -1, 428, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 439, 80, 218, -1, 1, 2, + -1, -1, -1, -1, 7, 8, 9, 10, 11, 12, + 13, -1, -1, 599, -1, 601, -1, -1, -1, -1, + -1, -1, 25, -1, -1, -1, -1, -1, 473, -1, + -1, -1, -1, 64, 65, 66, 67, 68, 69, 70, + 485, -1, 73, 74, -1, -1, 491, 50, 79, 80, + 53, 496, 497, -1, -1, 140, 501, -1, -1, -1, + -1, -1, 65, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, -1, -1, 520, -1, 80, 523, -1, + 525, 303, -1, -1, -1, -1, 531, -1, -1, -1, + 535, 313, -1, 315, -1, -1, -1, 319, -1, 321, + -1, -1, -1, -1, -1, -1, -1, 192, -1, -1, + -1, -1, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, -1, 348, 79, 80, -1, + -1, -1, -1, 218, -1, -1, -1, 140, 223, -1, + 92, -1, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, -1, -1, 599, -1, 601, -1, -1, 111, + 245, 246, 247, 248, 249, 250, 251, -1, -1, 254, + 255, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 192, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 421, + -1, -1, -1, -1, -1, -1, 428, -1, -1, -1, + -1, -1, -1, -1, -1, 218, -1, 439, 303, -1, + 223, -1, -1, -1, -1, -1, -1, -1, 313, -1, + 315, -1, -1, -1, 319, -1, 321, -1, -1, -1, + -1, 326, 245, 246, 247, 248, 249, 250, 251, -1, + -1, 254, 255, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 348, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 496, 497, -1, -1, -1, 501, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 375, -1, -1, -1, -1, -1, -1, -1, 520, -1, + 303, 523, -1, -1, -1, -1, -1, -1, -1, 531, + 313, -1, 315, 535, -1, -1, 319, -1, 321, -1, + -1, -1, -1, 326, -1, -1, -1, -1, -1, 18, + 19, 20, -1, -1, -1, 420, 421, -1, -1, -1, + -1, -1, -1, 428, -1, 348, -1, -1, -1, -1, + -1, -1, -1, -1, 439, -1, -1, -1, 47, 48, + -1, -1, 51, 52, -1, -1, 55, 56, -1, -1, + -1, -1, 375, -1, -1, -1, -1, 599, -1, 601, + -1, -1, -1, -1, -1, -1, -1, 76, 473, -1, + -1, -1, -1, -1, -1, -1, -1, 482, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 495, 496, 497, -1, -1, -1, 501, 420, 421, -1, + -1, -1, -1, -1, -1, 428, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 520, 439, -1, 523, -1, + 525, -1, -1, -1, -1, -1, 531, -1, -1, -1, + 535, -1, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, -1, -1, 79, 80, -1, + 473, -1, 84, -1, -1, -1, -1, -1, -1, 482, + 92, -1, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 495, 496, 497, -1, -1, -1, 501, -1, + -1, -1, -1, -1, 193, 194, 195, 196, -1, -1, + -1, -1, -1, -1, 599, -1, 601, 520, -1, 208, + 523, 210, 525, -1, -1, -1, -1, -1, 531, -1, + -1, -1, 535, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 252, -1, -1, -1, -1, -1, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, + 279, 280, 281, 282, 283, -1, 599, 286, 601, -1, + -1, -1, -1, -1, 293, 294, 295, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 310, -1, -1, -1, -1, -1, 316, 8, 9, + -1, 11, 12, -1, -1, -1, 325, -1, 18, 19, + 20, -1, 331, 332, -1, 25, 335, 336, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 347, -1, + -1, -1, -1, -1, -1, 354, -1, -1, -1, -1, + -1, 360, -1, -1, -1, 55, -1, -1, -1, -1, + -1, 370, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 76, -1, -1, -1, + 80, -1, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, -1, 405, 79, 80, 408, + -1, -1, -1, -1, 413, 414, -1, -1, -1, -1, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, -1, -1, -1, -1, -1, -1, 64, 65, + 66, 67, 68, 69, 70, 444, -1, 73, 74, -1, + 140, -1, -1, 79, 80, -1, -1, -1, -1, -1, + -1, 460, -1, -1, -1, -1, -1, 466, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, -1, -1, + -1, 480, -1, -1, -1, 484, 485, -1, 487, 488, + 489, 490, 491, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 196, 506, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 208, -1, + 210, -1, 521, -1, -1, -1, -1, -1, -1, -1, + -1, 530, -1, -1, -1, -1, -1, -1, 537, -1, + -1, -1, -1, -1, 543, -1, -1, -1, -1, -1, + -1, -1, -1, 552, 553, -1, 246, 247, 248, 249, + 250, 251, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, -1, 3, 4, 5, 6, 7, -1, 578, + -1, 11, 12, 582, -1, -1, 16, -1, 18, 19, + 20, 21, 22, 23, 24, -1, 286, 27, 28, 29, + 30, 31, 32, 33, -1, 295, 36, -1, -1, -1, + -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, -1, 325, 326, -1, -1, -1, + -1, -1, -1, -1, -1, 335, -1, -1, -1, -1, + -1, -1, 82, -1, -1, 85, 86, 87, 88, -1, + 90, -1, -1, -1, -1, -1, -1, -1, 0, -1, + -1, -1, -1, -1, 104, 105, 8, 9, 10, -1, + -1, -1, 14, 15, -1, 17, 116, 117, -1, -1, + -1, -1, -1, -1, 26, -1, -1, -1, -1, -1, + -1, -1, 34, 35, -1, 37, 38, 39, 40, -1, + -1, -1, -1, -1, -1, 405, -1, -1, 408, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 420, -1, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, -1, -1, 79, 80, 81, + -1, 83, -1, -1, -1, -1, -1, -1, -1, 91, + 92, -1, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, -1, -1, -1, -1, 108, 109, 110, 111, + 112, -1, 0, 473, 116, 117, -1, -1, -1, -1, + 8, 9, 10, -1, -1, 485, 14, 15, -1, 17, + -1, 491, -1, -1, -1, -1, -1, -1, 26, -1, + -1, -1, -1, -1, -1, -1, 34, 35, -1, 37, + 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 525, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, -1, + -1, 79, 80, 81, -1, 83, -1, -1, -1, -1, + -1, -1, -1, 91, 92, -1, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, -1, 0, -1, -1, + 108, 109, 110, 111, 112, 8, 9, 10, 116, 117, + -1, 14, 15, -1, 17, -1, -1, -1, -1, -1, + -1, -1, -1, 26, -1, -1, -1, -1, -1, -1, + -1, 34, 35, -1, 37, 38, 39, 40, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, -1, -1, 79, 80, 81, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 92, + -1, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, -1, -1, -1, -1, 108, 109, 110, -1, 112, + -1, -1, -1, 116, 117, 1, -1, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, -1, -1, 15, + 16, -1, 18, 19, 20, 21, 22, 23, 24, -1, + -1, 27, 28, 29, 30, 31, 32, 33, -1, -1, + 36, -1, -1, -1, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 82, -1, -1, 85, + 86, 87, 88, -1, 90, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 104, 105, + -1, -1, -1, 1, -1, 3, 4, 5, 6, 7, + 116, 117, 10, 11, 12, -1, 14, 15, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, 36, -1, + -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, 1, -1, 3, 4, 5, 6, + 7, -1, -1, 10, 11, 12, 104, 105, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 116, 117, + 27, 28, 29, 30, 31, 32, 33, -1, -1, 36, + -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, + 87, 88, -1, 90, -1, 1, -1, 3, 4, 5, + 6, 7, -1, -1, 10, 11, 12, 104, 105, 15, + 16, -1, 18, 19, 20, 21, 22, 23, 24, 116, + 117, 27, 28, 29, 30, 31, 32, 33, -1, -1, + 36, -1, -1, -1, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 82, -1, -1, 85, + 86, 87, 88, -1, 90, -1, 1, -1, 3, 4, + 5, 6, 7, -1, 9, 10, 11, 12, 104, 105, + -1, 16, -1, 18, 19, 20, 21, 22, 23, 24, + 116, 117, 27, 28, 29, 30, 31, 32, 33, -1, + -1, 36, -1, -1, -1, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 82, -1, -1, + 85, 86, 87, 88, -1, 90, -1, 1, -1, 3, + 4, 5, 6, 7, -1, -1, -1, 11, 12, 104, + 105, -1, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 116, 117, 27, 28, 29, 30, 31, 32, 33, + -1, -1, 36, -1, -1, -1, -1, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, -1, 90, -1, 1, -1, + 3, 4, 5, 6, 7, -1, -1, -1, 11, 12, + 104, 105, -1, 16, -1, 18, 19, 20, 21, 22, + 23, 24, 116, 117, 27, 28, 29, 30, 31, 32, + 33, -1, -1, 36, -1, -1, -1, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, + -1, -1, 85, 86, 87, 88, -1, 90, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 104, 105, -1, -1, -1, 1, 110, 3, 4, + 5, 6, 7, 116, 117, -1, 11, 12, -1, -1, + -1, 16, -1, 18, 19, 20, 21, 22, 23, 24, + -1, -1, 27, 28, 29, 30, 31, 32, 33, -1, + -1, 36, -1, -1, -1, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 82, -1, -1, + 85, 86, 87, 88, -1, 90, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, + 105, -1, -1, -1, 1, 110, 3, 4, 5, 6, + 7, 116, 117, -1, 11, 12, -1, -1, -1, 16, + -1, 18, 19, 20, 21, 22, 23, 24, -1, -1, + 27, 28, 29, 30, 31, 32, 33, -1, -1, 36, + -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, + 87, 88, -1, 90, -1, 1, -1, 3, 4, 5, + 6, 7, -1, -1, 10, 11, 12, 104, 105, -1, + 16, 108, 18, 19, 20, 21, 22, 23, 24, 116, + 117, 27, 28, 29, 30, 31, 32, 33, -1, -1, + 36, -1, -1, -1, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 82, -1, -1, 85, + 86, 87, 88, -1, 90, -1, -1, -1, 3, 4, + 5, 6, 7, -1, -1, -1, 11, 12, 104, 105, + -1, 16, -1, 18, 19, 20, 21, 22, 23, 24, + 116, 117, 27, 28, 29, 30, 31, 32, 33, -1, + -1, 36, -1, -1, -1, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 82, -1, -1, + 85, 86, 87, 88, -1, 90, -1, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, 104, + 105, -1, 16, -1, 18, 19, 20, 21, 22, 23, + 24, -1, 117, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, 107, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, 107, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, 107, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, 107, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + 104, 105, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 115, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, 89, 90, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 104, 105, 3, 4, 5, 6, 7, 8, 9, 10, + -1, 115, 13, 14, 15, 16, 17, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 62, 63, 64, 65, 66, 67, -1, 69, 70, + -1, -1, 73, -1, 75, -1, 77, 78, 79, 80, + -1, -1, -1, -1, 85, -1, -1, 88, -1, -1, + -1, -1, -1, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, -1, 105, 3, 4, 5, 6, 7, + 8, 9, 10, 114, -1, 13, 14, 15, 16, 17, + -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 62, 63, 64, 65, 66, 67, + -1, 69, 70, -1, -1, 73, -1, 75, -1, 77, + 78, 79, 80, -1, -1, -1, -1, -1, -1, -1, + 88, -1, -1, -1, -1, -1, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, -1, 105, 3, 4, + 5, 6, 7, 8, 9, 10, 114, -1, 13, 14, + 15, 16, 17, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, -1, 51, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 62, 63, 64, + 65, 66, 67, -1, 69, 70, -1, -1, 73, -1, + 75, -1, 77, 78, 79, 80, -1, -1, -1, -1, + -1, -1, -1, 88, -1, -1, -1, -1, -1, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, -1, + 105, 3, 4, 5, 6, 7, 8, 9, 10, 114, + -1, 13, 14, 15, 16, 17, -1, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, -1, -1, 51, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 62, 63, 64, 65, 66, 67, -1, 69, 70, -1, + -1, 73, -1, 75, -1, 77, 78, 79, 80, -1, + -1, -1, -1, -1, -1, -1, 88, -1, -1, -1, + -1, -1, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, -1, 105, -1, 3, 4, 5, -1, 7, + -1, -1, 114, 11, 12, -1, -1, -1, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, 89, 90, -1, -1, -1, -1, -1, -1, -1, + 3, 4, 5, -1, 7, -1, 104, 105, 11, 12, + -1, -1, 110, 16, -1, 18, 19, 20, 21, 22, + 23, 24, -1, -1, 27, 28, 29, 30, 31, 32, + 33, -1, -1, -1, -1, -1, -1, -1, -1, 42, + -1, -1, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, + -1, -1, 85, 86, 87, 88, 89, 90, -1, -1, + -1, -1, -1, -1, -1, 3, 4, 5, 6, 7, + -1, 104, 105, 11, 12, -1, -1, 110, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, 36, -1, + -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, 36, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, 89, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, 89, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, 89, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, 89, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + -1, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + -1, -1, 90, -1, -1, 3, 4, 5, -1, 7, + -1, -1, -1, 11, 12, -1, 104, 105, 16, -1, + 18, 19, 20, 21, 22, 23, 24, -1, -1, 27, + 28, 29, 30, 31, 32, 33, -1, -1, -1, -1, + -1, -1, -1, -1, 42, -1, -1, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 82, -1, -1, 85, 86, 87, + 88, -1, 90, 3, 4, 5, -1, 7, 96, -1, + -1, 11, 12, -1, -1, -1, 16, -1, 18, 19, + 20, 21, 22, 23, 24, -1, -1, 27, 28, 29, + 30, 31, 32, 33, -1, -1, -1, -1, -1, -1, + -1, -1, 42, -1, -1, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 82, -1, -1, 85, 86, 87, 88, -1, + 90, 3, 4, 5, -1, 7, -1, -1, -1, 11, + 12, -1, -1, -1, 16, -1, 18, 19, 20, 21, + 22, 23, 24, -1, -1, 27, 28, 29, 30, 31, + 32, 33, -1, -1, -1, -1, -1, -1, -1, -1, + 42, -1, -1, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 82, -1, -1, 85, 86, 87, 88, -1, 90, 3, + 4, 5, -1, 7, -1, -1, -1, 11, 12, -1, + -1, -1, 16, -1, 18, 19, 20, 21, 22, 23, + 24, -1, -1, 27, 28, 29, 30, 31, 32, 33, + -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, + -1, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 82, -1, + -1, 85, 86, 87, 88, -1, 90, 3, 4, 5, + -1, 7, -1, -1, -1, 11, 12, -1, -1, -1, + 16, -1, 18, 19, 20, 21, 22, 23, 24, -1, + -1, 27, 28, 29, 30, 31, 32, 33, -1, -1, + -1, -1, -1, -1, -1, -1, 42, -1, -1, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, -1, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + -1, -1, 79, 80, -1, -1, 82, -1, -1, 85, + 86, 87, -1, -1, 90, 92, -1, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + -1, -1, 79, 80, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 64, 65, 66, + 67, 68, 69, 70, 71, -1, 73, 74, -1, -1, + -1, -1, 79, 80, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/misc/bison.simple" +/* This file comes from bison-1.25.90. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 216 "/usr/share/misc/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 1: +#line 231 "parse.y" +{ + yyval.vars = ruby_dyna_vars; + lex_state = EXPR_BEG; + top_local_init(); + NEW_CREF0(); /* initialize constant c-ref */ + if ((VALUE)ruby_class == rb_cObject) class_nest = 0; + else class_nest = 1; + ; + break;} +case 2: +#line 240 "parse.y" +{ + ruby_eval_tree = block_append(ruby_eval_tree, yyvsp[0].node); + top_local_setup(); + cur_cref = 0; + class_nest = 0; + ruby_dyna_vars = yyvsp[-1].vars; + ; + break;} +case 4: +#line 251 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 5: +#line 255 "parse.y" +{ + yyval.node = newline_node(yyvsp[0].node); + ; + break;} +case 6: +#line 259 "parse.y" +{ + yyval.node = block_append(yyvsp[-2].node, newline_node(yyvsp[0].node)); + ; + break;} +case 7: +#line 263 "parse.y" +{ + yyval.node = yyvsp[0].node; + ; + break;} +case 8: +#line 268 "parse.y" +{ + if (yyvsp[-1].node && nd_type(yyvsp[-1].node) == NODE_BLOCK_PASS) { + rb_compile_error("both block arg and actual block given"); + } + yyvsp[0].node->nd_iter = yyvsp[-1].node; + yyval.node = yyvsp[0].node; + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 9: +#line 276 "parse.y" +{lex_state = EXPR_FNAME;; + break;} +case 10: +#line 277 "parse.y" +{ + if (cur_mid || in_single) + yyerror("alias within method"); + yyval.node = NEW_ALIAS(yyvsp[-2].id, yyvsp[0].id); + ; + break;} +case 11: +#line 283 "parse.y" +{ + if (cur_mid || in_single) + yyerror("alias within method"); + yyval.node = NEW_VALIAS(yyvsp[-1].id, yyvsp[0].id); + ; + break;} +case 12: +#line 289 "parse.y" +{ + char buf[3]; + + if (cur_mid || in_single) + yyerror("alias within method"); + sprintf(buf, "$%c", yyvsp[0].node->nd_nth); + yyval.node = NEW_VALIAS(yyvsp[-1].id, rb_intern(buf)); + ; + break;} +case 13: +#line 298 "parse.y" +{ + yyerror("can't make alias for the number variables"); + yyval.node = 0; + ; + break;} +case 14: +#line 303 "parse.y" +{ + if (cur_mid || in_single) + yyerror("undef within method"); + yyval.node = yyvsp[0].node; + ; + break;} +case 15: +#line 309 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_IF(cond(yyvsp[0].node), yyvsp[-2].node, 0); + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 16: +#line 315 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_UNLESS(cond(yyvsp[0].node), yyvsp[-2].node, 0); + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 17: +#line 321 "parse.y" +{ + value_expr(yyvsp[0].node); + if (nd_type(yyvsp[-2].node) == NODE_BEGIN) { + yyval.node = NEW_WHILE(cond(yyvsp[0].node), yyvsp[-2].node->nd_body, 0); + } + else { + yyval.node = NEW_WHILE(cond(yyvsp[0].node), yyvsp[-2].node, 1); + } + ; + break;} +case 18: +#line 331 "parse.y" +{ + value_expr(yyvsp[0].node); + if (nd_type(yyvsp[-2].node) == NODE_BEGIN) { + yyval.node = NEW_UNTIL(cond(yyvsp[0].node), yyvsp[-2].node->nd_body, 0); + } + else { + yyval.node = NEW_UNTIL(cond(yyvsp[0].node), yyvsp[-2].node, 1); + } + ; + break;} +case 19: +#line 341 "parse.y" +{ + if (cur_mid || in_single) { + yyerror("BEGIN in method"); + } + + local_push(); + ; + break;} +case 20: +#line 349 "parse.y" +{ + ruby_eval_tree_begin = block_append(ruby_eval_tree_begin, + NEW_PREEXE(yyvsp[-1].node)); + local_pop(); + yyval.node = 0; + ; + break;} +case 21: +#line 356 "parse.y" +{ + if (cur_mid || in_single) { + yyerror("END in method; use at_exit"); + } + + yyval.node = NEW_ITER(0, NEW_POSTEXE(), yyvsp[-1].node); + ; + break;} +case 23: +#line 366 "parse.y" +{ + value_expr(yyvsp[0].node); + yyvsp[-2].node->nd_value = yyvsp[0].node; + yyval.node = yyvsp[-2].node; + ; + break;} +case 24: +#line 372 "parse.y" +{ + value_expr(yyvsp[0].node); + if (!cur_mid && !in_single) + yyerror("return appeared outside of method"); + yyval.node = NEW_RETURN(yyvsp[0].node); + ; + break;} +case 25: +#line 379 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_YIELD(yyvsp[0].node); + ; + break;} +case 27: +#line 385 "parse.y" +{ + yyval.node = logop(NODE_AND, yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 28: +#line 389 "parse.y" +{ + yyval.node = logop(NODE_OR, yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 29: +#line 393 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_NOT(cond(yyvsp[0].node)); + ; + break;} +case 30: +#line 398 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_NOT(cond(yyvsp[0].node)); + ; + break;} +case 32: +#line 405 "parse.y" +{ + yyval.node = new_fcall(yyvsp[-1].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 33: +#line 410 "parse.y" +{ + value_expr(yyvsp[-3].node); + yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-3].node); + ; + break;} +case 34: +#line 416 "parse.y" +{ + value_expr(yyvsp[-3].node); + yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-3].node); + ; + break;} +case 35: +#line 422 "parse.y" +{ + if (!cur_mid && !in_single && !in_defined) + yyerror("super called outside of method"); + yyval.node = NEW_SUPER(yyvsp[0].node); + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 37: +#line 431 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 39: +#line 437 "parse.y" +{ + yyval.node = NEW_MASGN(NEW_LIST(yyvsp[-1].node), 0); + ; + break;} +case 40: +#line 442 "parse.y" +{ + yyval.node = NEW_MASGN(NEW_LIST(yyvsp[0].node), 0); + ; + break;} +case 41: +#line 446 "parse.y" +{ + yyval.node = NEW_MASGN(NEW_LIST(yyvsp[-2].node), yyvsp[0].node); + ; + break;} +case 42: +#line 450 "parse.y" +{ + yyval.node = NEW_MASGN(list_concat(NEW_LIST(yyvsp[-1].node),yyvsp[0].node), 0); + ; + break;} +case 43: +#line 454 "parse.y" +{ + yyval.node = NEW_MASGN(list_concat(NEW_LIST(yyvsp[-4].node),yyvsp[-3].node),yyvsp[0].node); + ; + break;} +case 44: +#line 458 "parse.y" +{ + yyval.node = NEW_MASGN(0, yyvsp[0].node); + ; + break;} +case 46: +#line 464 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 47: +#line 469 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 48: +#line 474 "parse.y" +{ + yyval.node = NEW_LIST(yyvsp[0].node); + ; + break;} +case 49: +#line 478 "parse.y" +{ + yyval.node = list_append(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 50: +#line 483 "parse.y" +{ + yyval.node = assignable(yyvsp[0].id, 0); + ; + break;} +case 51: +#line 487 "parse.y" +{ + yyval.node = aryset(yyvsp[-3].node, yyvsp[-1].node, 0); + ; + break;} +case 52: +#line 491 "parse.y" +{ + yyval.node = attrset(yyvsp[-2].node, yyvsp[0].id, 0); + ; + break;} +case 53: +#line 495 "parse.y" +{ + rb_backref_error(yyvsp[0].node); + yyval.node = 0; + ; + break;} +case 54: +#line 501 "parse.y" +{ + yyerror("class/module name must be CONSTANT"); + ; + break;} +case 59: +#line 510 "parse.y" +{ + lex_state = EXPR_END; + yyval.id = yyvsp[0].id; + ; + break;} +case 60: +#line 515 "parse.y" +{ + lex_state = EXPR_END; + yyval.id = yyvsp[0].id; + ; + break;} +case 61: +#line 521 "parse.y" +{ + yyval.node = NEW_UNDEF(yyvsp[0].id); + ; + break;} +case 62: +#line 524 "parse.y" +{lex_state = EXPR_FNAME;; + break;} +case 63: +#line 525 "parse.y" +{ + yyval.node = block_append(yyvsp[-3].node, NEW_UNDEF(yyvsp[0].id)); + ; + break;} +case 64: +#line 529 "parse.y" +{ yyval.id = tDOT2; ; + break;} +case 65: +#line 530 "parse.y" +{ yyval.id = '|'; ; + break;} +case 66: +#line 531 "parse.y" +{ yyval.id = '^'; ; + break;} +case 67: +#line 532 "parse.y" +{ yyval.id = '&'; ; + break;} +case 68: +#line 533 "parse.y" +{ yyval.id = tCMP; ; + break;} +case 69: +#line 534 "parse.y" +{ yyval.id = tEQ; ; + break;} +case 70: +#line 535 "parse.y" +{ yyval.id = tEQQ; ; + break;} +case 71: +#line 536 "parse.y" +{ yyval.id = tMATCH; ; + break;} +case 72: +#line 537 "parse.y" +{ yyval.id = '>'; ; + break;} +case 73: +#line 538 "parse.y" +{ yyval.id = tGEQ; ; + break;} +case 74: +#line 539 "parse.y" +{ yyval.id = '<'; ; + break;} +case 75: +#line 540 "parse.y" +{ yyval.id = tLEQ; ; + break;} +case 76: +#line 541 "parse.y" +{ yyval.id = tLSHFT; ; + break;} +case 77: +#line 542 "parse.y" +{ yyval.id = tRSHFT; ; + break;} +case 78: +#line 543 "parse.y" +{ yyval.id = '+'; ; + break;} +case 79: +#line 544 "parse.y" +{ yyval.id = '-'; ; + break;} +case 80: +#line 545 "parse.y" +{ yyval.id = '*'; ; + break;} +case 81: +#line 546 "parse.y" +{ yyval.id = '*'; ; + break;} +case 82: +#line 547 "parse.y" +{ yyval.id = '/'; ; + break;} +case 83: +#line 548 "parse.y" +{ yyval.id = '%'; ; + break;} +case 84: +#line 549 "parse.y" +{ yyval.id = tPOW; ; + break;} +case 85: +#line 550 "parse.y" +{ yyval.id = '~'; ; + break;} +case 86: +#line 551 "parse.y" +{ yyval.id = tUPLUS; ; + break;} +case 87: +#line 552 "parse.y" +{ yyval.id = tUMINUS; ; + break;} +case 88: +#line 553 "parse.y" +{ yyval.id = tAREF; ; + break;} +case 89: +#line 554 "parse.y" +{ yyval.id = tASET; ; + break;} +case 90: +#line 555 "parse.y" +{ yyval.id = '`'; ; + break;} +case 131: +#line 565 "parse.y" +{yyval.node = assignable(yyvsp[-1].id, 0);; + break;} +case 132: +#line 566 "parse.y" +{ + yyval.node = yyvsp[-1].node; + if (yyval.node) { + yyval.node->nd_value = yyvsp[0].node; + fixpos(yyval.node, yyvsp[0].node); + } + ; + break;} +case 133: +#line 574 "parse.y" +{ + yyval.node = aryset(yyvsp[-5].node, yyvsp[-3].node, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-5].node); + ; + break;} +case 134: +#line 579 "parse.y" +{ + yyval.node = attrset(yyvsp[-4].node, yyvsp[-2].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 135: +#line 584 "parse.y" +{ + yyval.node = attrset(yyvsp[-4].node, yyvsp[-2].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 136: +#line 589 "parse.y" +{ + value_expr(yyvsp[0].node); + rb_backref_error(yyvsp[-2].node); + yyval.node = 0; + ; + break;} +case 137: +#line 594 "parse.y" +{yyval.node = assignable(yyvsp[-1].id, 0);; + break;} +case 138: +#line 595 "parse.y" +{ + if (yyvsp[-2].id == tOROP) { + yyvsp[-1].node->nd_value = yyvsp[0].node; + yyval.node = NEW_OP_ASGN_OR(gettable(yyvsp[-3].id), yyvsp[-1].node); + } + else if (yyvsp[-2].id == tANDOP) { + yyvsp[-1].node->nd_value = yyvsp[0].node; + yyval.node = NEW_OP_ASGN_AND(gettable(yyvsp[-3].id), yyvsp[-1].node); + } + else { + yyval.node = yyvsp[-1].node; + yyval.node->nd_value = call_op(gettable(yyvsp[-3].id), yyvsp[-2].id, 1, yyvsp[0].node); + } + fixpos(yyval.node, yyvsp[0].node); + ; + break;} +case 139: +#line 611 "parse.y" +{ + NODE *args = NEW_LIST(yyvsp[0].node); + + list_append(yyvsp[-3].node, NEW_NIL()); + list_concat(args, yyvsp[-3].node); + if (yyvsp[-1].id == tOROP) { + yyvsp[-1].id = 0; + } + else if (yyvsp[-1].id == tANDOP) { + yyvsp[-1].id = 1; + } + yyval.node = NEW_OP_ASGN1(yyvsp[-5].node, yyvsp[-1].id, args); + fixpos(yyval.node, yyvsp[-5].node); + ; + break;} +case 140: +#line 626 "parse.y" +{ + if (yyvsp[-1].id == tOROP) { + yyvsp[-1].id = 0; + } + else if (yyvsp[-1].id == tANDOP) { + yyvsp[-1].id = 1; + } + yyval.node = NEW_OP_ASGN2(yyvsp[-4].node, yyvsp[-2].id, yyvsp[-1].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-4].node); + ; + break;} +case 141: +#line 637 "parse.y" +{ + if (yyvsp[-1].id == tOROP) { + yyvsp[-1].id = 0; + } + else if (yyvsp[-1].id == tANDOP) { + yyvsp[-1].id = 1; + } + yyval.node = NEW_OP_ASGN2(yyvsp[-4].node, yyvsp[-2].id, yyvsp[-1].id, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-4].node); + ; + break;} +case 142: +#line 648 "parse.y" +{ + rb_backref_error(yyvsp[-2].node); + yyval.node = 0; + ; + break;} +case 143: +#line 653 "parse.y" +{ + yyval.node = NEW_DOT2(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 144: +#line 657 "parse.y" +{ + yyval.node = NEW_DOT3(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 145: +#line 661 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '+', 1, yyvsp[0].node); + ; + break;} +case 146: +#line 665 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '-', 1, yyvsp[0].node); + ; + break;} +case 147: +#line 669 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '*', 1, yyvsp[0].node); + ; + break;} +case 148: +#line 673 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '/', 1, yyvsp[0].node); + ; + break;} +case 149: +#line 677 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '%', 1, yyvsp[0].node); + ; + break;} +case 150: +#line 681 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tPOW, 1, yyvsp[0].node); + ; + break;} +case 151: +#line 685 "parse.y" +{ + yyval.node = call_op(yyvsp[0].node, tUPLUS, 0); + ; + break;} +case 152: +#line 689 "parse.y" +{ + yyval.node = call_op(yyvsp[0].node, tUMINUS, 0); + ; + break;} +case 153: +#line 693 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '|', 1, yyvsp[0].node); + ; + break;} +case 154: +#line 697 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '^', 1, yyvsp[0].node); + ; + break;} +case 155: +#line 701 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '&', 1, yyvsp[0].node); + ; + break;} +case 156: +#line 705 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tCMP, 1, yyvsp[0].node); + ; + break;} +case 157: +#line 709 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '>', 1, yyvsp[0].node); + ; + break;} +case 158: +#line 713 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tGEQ, 1, yyvsp[0].node); + ; + break;} +case 159: +#line 717 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, '<', 1, yyvsp[0].node); + ; + break;} +case 160: +#line 721 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tLEQ, 1, yyvsp[0].node); + ; + break;} +case 161: +#line 725 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tEQ, 1, yyvsp[0].node); + ; + break;} +case 162: +#line 729 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tEQQ, 1, yyvsp[0].node); + ; + break;} +case 163: +#line 733 "parse.y" +{ + yyval.node = NEW_NOT(call_op(yyvsp[-2].node, tEQ, 1, yyvsp[0].node)); + ; + break;} +case 164: +#line 737 "parse.y" +{ + yyval.node = match_gen(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 165: +#line 741 "parse.y" +{ + yyval.node = NEW_NOT(match_gen(yyvsp[-2].node, yyvsp[0].node)); + ; + break;} +case 166: +#line 745 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_NOT(cond(yyvsp[0].node)); + ; + break;} +case 167: +#line 750 "parse.y" +{ + yyval.node = call_op(yyvsp[0].node, '~', 0); + ; + break;} +case 168: +#line 754 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tLSHFT, 1, yyvsp[0].node); + ; + break;} +case 169: +#line 758 "parse.y" +{ + yyval.node = call_op(yyvsp[-2].node, tRSHFT, 1, yyvsp[0].node); + ; + break;} +case 170: +#line 762 "parse.y" +{ + yyval.node = logop(NODE_AND, yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 171: +#line 766 "parse.y" +{ + yyval.node = logop(NODE_OR, yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 172: +#line 769 "parse.y" +{in_defined = 1;; + break;} +case 173: +#line 770 "parse.y" +{ + in_defined = 0; + yyval.node = NEW_DEFINED(yyvsp[0].node); + ; + break;} +case 174: +#line 775 "parse.y" +{ + value_expr(yyvsp[-4].node); + yyval.node = NEW_IF(cond(yyvsp[-4].node), yyvsp[-2].node, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-4].node); + ; + break;} +case 175: +#line 781 "parse.y" +{ + yyval.node = yyvsp[0].node; + ; + break;} +case 176: +#line 786 "parse.y" +{ + if (yyvsp[0].node && nd_type(yyvsp[0].node) == NODE_BLOCK_PASS) { + rb_compile_error("block argument should not be given"); + } + yyval.node = yyvsp[0].node; + ; + break;} +case 177: +#line 794 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 179: +#line 800 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_LIST(yyvsp[0].node); + ; + break;} +case 180: +#line 805 "parse.y" +{ + yyval.node = arg_blk_pass(yyvsp[-1].node, yyvsp[0].node); + ; + break;} +case 181: +#line 809 "parse.y" +{ + yyval.node = arg_add(yyvsp[-4].node, yyvsp[-1].node); + yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node); + ; + break;} +case 182: +#line 814 "parse.y" +{ + yyval.node = NEW_LIST(NEW_HASH(yyvsp[-1].node)); + yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node); + ; + break;} +case 183: +#line 819 "parse.y" +{ + yyval.node = arg_add(NEW_LIST(NEW_HASH(yyvsp[-4].node)), yyvsp[-1].node); + yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node); + ; + break;} +case 184: +#line 824 "parse.y" +{ + yyval.node = list_append(yyvsp[-3].node, NEW_HASH(yyvsp[-1].node)); + yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node); + ; + break;} +case 185: +#line 829 "parse.y" +{ + yyval.node = arg_add(list_append(yyvsp[-6].node, NEW_HASH(yyvsp[-4].node)), yyvsp[-1].node); + yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node); + ; + break;} +case 186: +#line 834 "parse.y" +{ + value_expr(yyvsp[-1].node); + yyval.node = arg_blk_pass(NEW_RESTARGS(yyvsp[-1].node), yyvsp[0].node); + ; + break;} +case 188: +#line 841 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_BLOCK_PASS(yyvsp[0].node); + ; + break;} +case 189: +#line 847 "parse.y" +{ + yyval.node = yyvsp[0].node; + ; + break;} +case 190: +#line 851 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 192: +#line 857 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 193: +#line 862 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_LIST(yyvsp[0].node); + ; + break;} +case 194: +#line 867 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = list_append(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 195: +#line 873 "parse.y" +{ + if (yyvsp[0].node && + nd_type(yyvsp[0].node) == NODE_ARRAY && + yyvsp[0].node->nd_next == 0) + { + yyval.node = yyvsp[0].node->nd_head; + } + else { + yyval.node = yyvsp[0].node; + } + ; + break;} +case 196: +#line 885 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = arg_add(yyvsp[-3].node, yyvsp[0].node); + ; + break;} +case 197: +#line 890 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = yyvsp[0].node; + ; + break;} +case 198: +#line 896 "parse.y" +{ + yyval.node = yyvsp[0].node; + if (yyvsp[0].node) { + if (nd_type(yyvsp[0].node) == NODE_ARRAY && + yyvsp[0].node->nd_next == 0) { + yyval.node = yyvsp[0].node->nd_head; + } + else if (nd_type(yyvsp[0].node) == NODE_BLOCK_PASS) { + rb_compile_error("block argument should not be given"); + } + } + ; + break;} +case 199: +#line 910 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 201: +#line 916 "parse.y" +{ + yyval.node = NEW_LIT(yyvsp[0].val); + ; + break;} +case 202: +#line 920 "parse.y" +{ + value_expr(yyvsp[-2].node); + yyval.node = NEW_COLON2(yyvsp[-2].node, yyvsp[0].id); + ; + break;} +case 203: +#line 925 "parse.y" +{ + value_expr(yyvsp[-2].node); + yyval.node = new_call(yyvsp[-2].node, yyvsp[0].id, 0); + ; + break;} +case 204: +#line 930 "parse.y" +{ + yyval.node = NEW_COLON3(yyvsp[0].id); + ; + break;} +case 205: +#line 934 "parse.y" +{ + yyval.node = NEW_STR(yyvsp[0].val); + ; + break;} +case 207: +#line 939 "parse.y" +{ + yyval.node = NEW_XSTR(yyvsp[0].val); + ; + break;} +case 212: +#line 947 "parse.y" +{ + value_expr(yyvsp[-3].node); + yyval.node = NEW_CALL(yyvsp[-3].node, tAREF, yyvsp[-1].node); + ; + break;} +case 213: +#line 952 "parse.y" +{ + if (yyvsp[-1].node == 0) + yyval.node = NEW_ZARRAY(); /* zero length array*/ + else { + yyval.node = yyvsp[-1].node; + } + ; + break;} +case 214: +#line 960 "parse.y" +{ + yyval.node = NEW_HASH(yyvsp[-1].node); + ; + break;} +case 215: +#line 964 "parse.y" +{ + if (!cur_mid && !in_single) + yyerror("return appeared outside of method"); + value_expr(yyvsp[-1].node); + yyval.node = NEW_RETURN(yyvsp[-1].node); + ; + break;} +case 216: +#line 971 "parse.y" +{ + if (!cur_mid && !in_single) + yyerror("return appeared outside of method"); + yyval.node = NEW_RETURN(0); + ; + break;} +case 217: +#line 977 "parse.y" +{ + if (!cur_mid && !in_single) + yyerror("return appeared outside of method"); + yyval.node = NEW_RETURN(0); + ; + break;} +case 218: +#line 983 "parse.y" +{ + value_expr(yyvsp[-1].node); + yyval.node = NEW_YIELD(yyvsp[-1].node); + ; + break;} +case 219: +#line 988 "parse.y" +{ + yyval.node = NEW_YIELD(0); + ; + break;} +case 220: +#line 992 "parse.y" +{ + yyval.node = NEW_YIELD(0); + ; + break;} +case 221: +#line 995 "parse.y" +{in_defined = 1;; + break;} +case 222: +#line 996 "parse.y" +{ + in_defined = 0; + yyval.node = NEW_DEFINED(yyvsp[-1].node); + ; + break;} +case 223: +#line 1001 "parse.y" +{ + yyval.node = NEW_VCALL(yyvsp[0].id); + ; + break;} +case 224: +#line 1005 "parse.y" +{ + yyvsp[0].node->nd_iter = NEW_FCALL(yyvsp[-1].id, 0); + yyval.node = yyvsp[0].node; + ; + break;} +case 226: +#line 1011 "parse.y" +{ + if (yyvsp[-1].node && nd_type(yyvsp[-1].node) == NODE_BLOCK_PASS) { + rb_compile_error("both block arg and actual block given"); + } + yyvsp[0].node->nd_iter = yyvsp[-1].node; + yyval.node = yyvsp[0].node; + fixpos(yyval.node, yyvsp[-1].node); + ; + break;} +case 227: +#line 1023 "parse.y" +{ + value_expr(yyvsp[-4].node); + yyval.node = NEW_IF(cond(yyvsp[-4].node), yyvsp[-2].node, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-4].node); + ; + break;} +case 228: +#line 1032 "parse.y" +{ + value_expr(yyvsp[-4].node); + yyval.node = NEW_UNLESS(cond(yyvsp[-4].node), yyvsp[-2].node, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-4].node); + ; + break;} +case 229: +#line 1040 "parse.y" +{ + value_expr(yyvsp[-3].node); + yyval.node = NEW_WHILE(cond(yyvsp[-3].node), yyvsp[-1].node, 1); + fixpos(yyval.node, yyvsp[-3].node); + ; + break;} +case 230: +#line 1048 "parse.y" +{ + value_expr(yyvsp[-3].node); + yyval.node = NEW_UNTIL(cond(yyvsp[-3].node), yyvsp[-1].node, 1); + fixpos(yyval.node, yyvsp[-3].node); + ; + break;} +case 231: +#line 1056 "parse.y" +{ + value_expr(yyvsp[-2].node); + yyval.node = NEW_CASE(yyvsp[-2].node, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-2].node); + ; + break;} +case 232: +#line 1064 "parse.y" +{ + value_expr(yyvsp[-5].node); + yyval.node = NEW_FOR(yyvsp[-5].node, yyvsp[-3].node, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-5].node); + ; + break;} +case 233: +#line 1075 "parse.y" +{ + if (!yyvsp[-3].node && !yyvsp[-2].node && !yyvsp[-1].node) + yyval.node = NEW_BEGIN(yyvsp[-4].node); + else { + if (yyvsp[-3].node) yyvsp[-4].node = NEW_RESCUE(yyvsp[-4].node, yyvsp[-3].node, yyvsp[-2].node); + else if (yyvsp[-2].node) { + rb_warn("else without rescue is useless"); + yyvsp[-4].node = block_append(yyvsp[-4].node, yyvsp[-2].node); + } + if (yyvsp[-1].node) yyvsp[-4].node = NEW_ENSURE(yyvsp[-4].node, yyvsp[-1].node); + yyval.node = yyvsp[-4].node; + } + fixpos(yyval.node, yyvsp[-4].node); + ; + break;} +case 234: +#line 1090 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 235: +#line 1094 "parse.y" +{ + if (cur_mid || in_single) + yyerror("class definition in method body"); + + class_nest++; + cref_push(); + local_push(); + ; + break;} +case 236: +#line 1104 "parse.y" +{ + yyval.node = NEW_CLASS(yyvsp[-4].id, yyvsp[-1].node, yyvsp[-3].node); + fixpos(yyval.node, yyvsp[-3].node); + local_pop(); + cref_pop(); + class_nest--; + ; + break;} +case 237: +#line 1112 "parse.y" +{ + class_nest++; + cref_push(); + local_push(); + ; + break;} +case 238: +#line 1119 "parse.y" +{ + yyval.node = NEW_SCLASS(yyvsp[-4].node, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-4].node); + local_pop(); + cref_pop(); + class_nest--; + ; + break;} +case 239: +#line 1127 "parse.y" +{ + if (cur_mid || in_single) + yyerror("module definition in method body"); + class_nest++; + cref_push(); + local_push(); + ; + break;} +case 240: +#line 1136 "parse.y" +{ + yyval.node = NEW_MODULE(yyvsp[-3].id, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-1].node); + local_pop(); + cref_pop(); + class_nest--; + ; + break;} +case 241: +#line 1144 "parse.y" +{ + if (cur_mid || in_single) + yyerror("nested method definition"); + cur_mid = yyvsp[0].id; + local_push(); + ; + break;} +case 242: +#line 1153 "parse.y" +{ + /* NOEX_PRIVATE for toplevel */ + yyval.node = NEW_DEFN(yyvsp[-4].id, yyvsp[-2].node, yyvsp[-1].node, class_nest?0:1); + fixpos(yyval.node, yyvsp[-2].node); + local_pop(); + cur_mid = 0; + ; + break;} +case 243: +#line 1160 "parse.y" +{lex_state = EXPR_FNAME;; + break;} +case 244: +#line 1161 "parse.y" +{ + value_expr(yyvsp[-3].node); + in_single++; + local_push(); + lex_state = EXPR_END; /* force for args */ + ; + break;} +case 245: +#line 1170 "parse.y" +{ + yyval.node = NEW_DEFS(yyvsp[-7].node, yyvsp[-4].id, yyvsp[-2].node, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-7].node); + local_pop(); + in_single--; + ; + break;} +case 246: +#line 1177 "parse.y" +{ + yyval.node = NEW_BREAK(); + ; + break;} +case 247: +#line 1181 "parse.y" +{ + yyval.node = NEW_NEXT(); + ; + break;} +case 248: +#line 1185 "parse.y" +{ + yyval.node = NEW_REDO(); + ; + break;} +case 249: +#line 1189 "parse.y" +{ + yyval.node = NEW_RETRY(); + ; + break;} +case 256: +#line 1204 "parse.y" +{ + value_expr(yyvsp[-3].node); + yyval.node = NEW_IF(cond(yyvsp[-3].node), yyvsp[-1].node, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-3].node); + ; + break;} +case 257: +#line 1211 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 258: +#line 1215 "parse.y" +{ + yyval.node = yyvsp[0].node; + ; + break;} +case 261: +#line 1223 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 262: +#line 1227 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 263: +#line 1231 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 264: +#line 1235 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 265: +#line 1240 "parse.y" +{ + yyval.vars = dyna_push(); + ; + break;} +case 266: +#line 1246 "parse.y" +{ + yyval.node = NEW_ITER(yyvsp[-2].node, 0, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-2].node?yyvsp[-2].node:yyvsp[-1].node); + dyna_pop(yyvsp[-3].vars); + ; + break;} +case 267: +#line 1253 "parse.y" +{ + yyval.vars = dyna_push(); + ; + break;} +case 268: +#line 1258 "parse.y" +{ + yyval.node = NEW_ITER(yyvsp[-2].node, 0, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-2].node?yyvsp[-2].node:yyvsp[-1].node); + dyna_pop(yyvsp[-3].vars); + ; + break;} +case 269: +#line 1265 "parse.y" +{ + yyval.node = NEW_VCALL(yyvsp[0].id); + ; + break;} +case 270: +#line 1269 "parse.y" +{ + yyval.node = NEW_VCALL(yyvsp[0].id); + ; + break;} +case 271: +#line 1273 "parse.y" +{ + yyval.node = NEW_VCALL(yyvsp[0].id); + ; + break;} +case 274: +#line 1280 "parse.y" +{ + yyval.node = new_fcall(yyvsp[-3].id, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-1].node); + ; + break;} +case 275: +#line 1285 "parse.y" +{ + value_expr(yyvsp[-5].node); + yyval.node = new_call(yyvsp[-5].node, yyvsp[-3].id, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-5].node); + ; + break;} +case 276: +#line 1291 "parse.y" +{ + value_expr(yyvsp[-2].node); + yyval.node = new_call(yyvsp[-2].node, yyvsp[0].id, 0); + fixpos(yyval.node, yyvsp[-2].node); + ; + break;} +case 277: +#line 1297 "parse.y" +{ + value_expr(yyvsp[-5].node); + yyval.node = new_call(yyvsp[-5].node, yyvsp[-3].id, yyvsp[-1].node); + fixpos(yyval.node, yyvsp[-5].node); + ; + break;} +case 278: +#line 1303 "parse.y" +{ + if (!cur_mid && !in_single && !in_defined) + yyerror("super called outside of method"); + yyval.node = NEW_SUPER(yyvsp[-1].node); + ; + break;} +case 279: +#line 1309 "parse.y" +{ + if (!cur_mid && !in_single && !in_defined) + yyerror("super called outside of method"); + yyval.node = NEW_ZSUPER(); + ; + break;} +case 280: +#line 1319 "parse.y" +{ + yyval.node = NEW_WHEN(yyvsp[-3].node, yyvsp[-1].node, yyvsp[0].node); + ; + break;} +case 282: +#line 1325 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = list_append(yyvsp[-3].node, NEW_WHEN(yyvsp[0].node, 0, 0)); + ; + break;} +case 283: +#line 1330 "parse.y" +{ + value_expr(yyvsp[0].node); + yyval.node = NEW_LIST(NEW_WHEN(yyvsp[0].node, 0, 0)); + ; + break;} +case 286: +#line 1341 "parse.y" +{ + yyval.node = NEW_RESBODY(yyvsp[-3].node, yyvsp[-1].node, yyvsp[0].node); + fixpos(yyval.node, yyvsp[-3].node?yyvsp[-3].node:yyvsp[-1].node); + ; + break;} +case 287: +#line 1346 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 288: +#line 1351 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 289: +#line 1355 "parse.y" +{ + yyval.node = yyvsp[0].node; + ; + break;} +case 291: +#line 1361 "parse.y" +{ + yyval.val = INT2FIX(yyvsp[0].id); + ; + break;} +case 302: +#line 1377 "parse.y" +{yyval.id = kNIL;; + break;} +case 303: +#line 1378 "parse.y" +{yyval.id = kSELF;; + break;} +case 304: +#line 1379 "parse.y" +{yyval.id = kTRUE;; + break;} +case 305: +#line 1380 "parse.y" +{yyval.id = kFALSE;; + break;} +case 306: +#line 1381 "parse.y" +{yyval.id = k__FILE__;; + break;} +case 307: +#line 1382 "parse.y" +{yyval.id = k__LINE__;; + break;} +case 308: +#line 1385 "parse.y" +{ + yyval.node = gettable(yyvsp[0].id); + ; + break;} +case 311: +#line 1393 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 312: +#line 1397 "parse.y" +{ + lex_state = EXPR_BEG; + ; + break;} +case 313: +#line 1401 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 314: +#line 1404 "parse.y" +{yyerrok; yyval.node = 0;; + break;} +case 315: +#line 1407 "parse.y" +{ + yyval.node = yyvsp[-2].node; + lex_state = EXPR_BEG; + ; + break;} +case 316: +#line 1412 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 317: +#line 1417 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(yyvsp[-5].num, yyvsp[-3].node, yyvsp[-1].id), yyvsp[0].node); + ; + break;} +case 318: +#line 1421 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(yyvsp[-3].num, yyvsp[-1].node, -1), yyvsp[0].node); + ; + break;} +case 319: +#line 1425 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(yyvsp[-3].num, 0, yyvsp[-1].id), yyvsp[0].node); + ; + break;} +case 320: +#line 1429 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(yyvsp[-1].num, 0, -1), yyvsp[0].node); + ; + break;} +case 321: +#line 1433 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(0, yyvsp[-3].node, yyvsp[-1].id), yyvsp[0].node); + ; + break;} +case 322: +#line 1437 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(0, yyvsp[-1].node, -1), yyvsp[0].node); + ; + break;} +case 323: +#line 1441 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(0, 0, yyvsp[-1].id), yyvsp[0].node); + ; + break;} +case 324: +#line 1445 "parse.y" +{ + yyval.node = block_append(NEW_ARGS(0, 0, -1), yyvsp[0].node); + ; + break;} +case 325: +#line 1449 "parse.y" +{ + yyval.node = NEW_ARGS(0, 0, -1); + ; + break;} +case 326: +#line 1454 "parse.y" +{ + if (!is_local_id(yyvsp[0].id)) + yyerror("formal argument must be local variable"); + local_cnt(yyvsp[0].id); + yyval.num = 1; + ; + break;} +case 327: +#line 1461 "parse.y" +{ + if (!is_local_id(yyvsp[0].id)) + yyerror("formal argument must be local variable"); + local_cnt(yyvsp[0].id); + yyval.num += 1; + ; + break;} +case 328: +#line 1469 "parse.y" +{ + if (!is_local_id(yyvsp[-2].id)) + yyerror("formal argument must be local variable"); + yyval.node = assignable(yyvsp[-2].id, yyvsp[0].node); + ; + break;} +case 329: +#line 1476 "parse.y" +{ + yyval.node = NEW_BLOCK(yyvsp[0].node); + yyval.node->nd_end = yyval.node; + ; + break;} +case 330: +#line 1481 "parse.y" +{ + yyval.node = block_append(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 331: +#line 1486 "parse.y" +{ + if (!is_local_id(yyvsp[0].id)) + yyerror("rest argument must be local variable"); + yyval.id = local_cnt(yyvsp[0].id); + ; + break;} +case 332: +#line 1493 "parse.y" +{ + yyval.node = NEW_BLOCK_ARG(yyvsp[0].id); + ; + break;} +case 333: +#line 1498 "parse.y" +{ + yyval.node = yyvsp[0].node; + ; + break;} +case 334: +#line 1502 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 335: +#line 1507 "parse.y" +{ + if (nd_type(yyvsp[0].node) == NODE_SELF) { + yyval.node = NEW_SELF(); + } + else if (nd_type(yyvsp[0].node) == NODE_NIL) { + yyerror("Can't define single method for nil."); + yyval.node = 0; + } + else { + yyval.node = yyvsp[0].node; + } + ; + break;} +case 336: +#line 1520 "parse.y" +{ + switch (nd_type(yyvsp[-2].node)) { + case NODE_STR: + case NODE_DSTR: + case NODE_XSTR: + case NODE_DXSTR: + case NODE_DREGX: + case NODE_LIT: + case NODE_ARRAY: + case NODE_ZARRAY: + yyerror("Can't define single method for literals."); + default: + break; + } + yyval.node = yyvsp[-2].node; + ; + break;} +case 337: +#line 1538 "parse.y" +{ + yyval.node = 0; + ; + break;} +case 338: +#line 1542 "parse.y" +{ + yyval.node = yyvsp[-1].node; + ; + break;} +case 339: +#line 1546 "parse.y" +{ + if (yyvsp[-1].node->nd_alen%2 != 0) { + yyerror("odd number list for Hash"); + } + yyval.node = yyvsp[-1].node; + ; + break;} +case 341: +#line 1555 "parse.y" +{ + yyval.node = list_concat(yyvsp[-2].node, yyvsp[0].node); + ; + break;} +case 342: +#line 1560 "parse.y" +{ + yyval.node = list_append(NEW_LIST(yyvsp[-2].node), yyvsp[0].node); + ; + break;} +case 355: +#line 1581 "parse.y" +{yyerrok;; + break;} +case 358: +#line 1585 "parse.y" +{yyerrok;; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 542 "/usr/share/misc/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 1586 "parse.y" + +#include +#include +#include "regex.h" +#include "util.h" + +#define is_identchar(c) ((c)!=-1&&(ISALNUM(c) || (c) == '_' || ismbchar(c))) + +static char *tokenbuf = NULL; +static int tokidx, toksiz = 0; + +char *strdup(); + +static NODE *rb_str_extend(); + +#define LEAVE_BS 1 + +static VALUE (*lex_gets)(); /* gets function */ +static VALUE lex_input; /* non-nil if File */ +static VALUE lex_lastline; /* gc protect */ +static char *lex_pbeg; +static char *lex_p; +static char *lex_pend; + +static int +yyerror(msg) + char *msg; +{ + char *p, *pe, *buf; + int len, i; + + rb_compile_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'; + rb_compile_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'; + rb_compile_error_append("%s", buf); + } + + return 0; +} + +static int newline_seen; +static int heredoc_end; + +int ruby_in_compile = 0; +int ruby__end__seen; + +static NODE* +yycompile(f) + char *f; +{ + int n; + + ruby__end__seen = 0; + ruby_eval_tree = 0; + newline_seen = 0; + ruby_sourcefile = f; + ruby_in_compile = 1; + n = yyparse(); + ruby_in_compile = 0; + if (n == 0) return ruby_eval_tree; + + return 0; +} + +static int lex_gets_ptr; + +static VALUE +lex_get_str(s) + VALUE s; +{ + char *beg, *end, *pend; + + beg = RSTRING(s)->ptr; + if (lex_gets_ptr) { + if (RSTRING(s)->len == lex_gets_ptr) return Qnil; + beg += lex_gets_ptr; + } + pend = RSTRING(s)->ptr + RSTRING(s)->len; + end = beg; + while (end < pend) { + if (*end++ == '\n') break; + } + lex_gets_ptr = end - RSTRING(s)->ptr; + return rb_str_new(beg, end - beg); +} + +NODE* +rb_compile_string(f, s) + char *f; + VALUE s; +{ + lex_gets = lex_get_str; + lex_gets_ptr = 0; + lex_input = s; + lex_pbeg = lex_p = lex_pend = 0; + if (!ruby_sourcefile || strcmp(f, ruby_sourcefile)) /* not in eval() */ + ruby_sourceline = 1; + + return yycompile(f); +} + +NODE* +rb_compile_cstr(f, s, len) + char *f, *s; + int len; +{ + return rb_compile_string(f, rb_str_new(s, len)); +} + +NODE* +rb_compile_file(f, file, start) + char *f; + VALUE file; + int start; +{ + lex_gets = rb_io_gets; + lex_input = file; + lex_pbeg = lex_p = lex_pend = 0; + ruby_sourceline = start; + + return yycompile(strdup(f)); +} + + +static void +normalize_newline(line) + VALUE line; +{ + if (RSTRING(line)->len >= 2 && + RSTRING(line)->ptr[RSTRING(line)->len-1] == '\n' && + RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r') + { + RSTRING(line)->ptr[RSTRING(line)->len-2] = '\n'; + RSTRING(line)->len--; + } +} + +static int +nextc() +{ + int c; + + if (lex_p == lex_pend) { + if (lex_input) { + VALUE v = (*lex_gets)(lex_input); + + if (NIL_P(v)) return -1; + if (heredoc_end > 0) { + ruby_sourceline = heredoc_end+1; + heredoc_end = 0; + } + normalize_newline(v); + while (RSTRING(v)->len >= 2 && + RSTRING(v)->ptr[RSTRING(v)->len-1] == '\n' && + RSTRING(v)->ptr[RSTRING(v)->len-2] == '\\') { + VALUE v2 = (*lex_gets)(lex_input); + + if (!NIL_P(v2)) { + normalize_newline(v2); + rb_str_cat(v, RSTRING(v2)->ptr, RSTRING(v2)->len); + } + } + lex_pbeg = lex_p = RSTRING(v)->ptr; + lex_pend = lex_p + RSTRING(v)->len; + if (strncmp(lex_pbeg, "__END__", 7) == 0 && lex_pbeg[7] == '\n') { + ruby__end__seen = 1; + lex_lastline = 0; + return -1; + } + lex_lastline = v; + } + else { + lex_lastline = 0; + return -1; + } + } + c = (unsigned char)*lex_p++; + + return c; +} + +static 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) + +static char* +newtok() +{ + tokidx = 0; + if (!tokenbuf) { + toksiz = 60; + tokenbuf = ALLOC_N(char, 60); + } + if (toksiz > 4096) { + toksiz = 60; + REALLOC_N(tokenbuf, char, 60); + } + return tokenbuf; +} + +static void +tokadd(c) + char c; +{ + tokenbuf[tokidx++] = c; + if (tokidx >= toksiz) { + toksiz *= 2; + REALLOC_N(tokenbuf, char, toksiz); + } +} + +static int +read_escape() +{ + int c; + + switch (c = nextc()) { + case '\\': /* Backslash */ + return c; + + case 'n': /* newline */ + return '\n'; + + case 't': /* horizontal tab */ + return '\t'; + + case 'r': /* carriage-return */ + return '\r'; + + case 'f': /* form-feed */ + return '\f'; + + case 'v': /* vertical tab */ + return '\13'; + + case 'a': /* alarm(bell) */ + return '\007'; + + case 'e': /* escape */ + return 033; + + case '0': case '1': case '2': case '3': /* octal constant */ + case '4': case '5': case '6': case '7': + { + char buf[3]; + int i; + + pushback(c); + for (i=0; i<3; i++) { + c = nextc(); + if (c == -1) goto eof; + if (c < '0' || '7' < c) { + pushback(c); + break; + } + buf[i] = c; + } + c = scan_oct(buf, i+1, &i); + } + return c; + + case 'x': /* hex constant */ + { + 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 */ + return '\b'; + + case 's': /* space */ + return ' '; + + case 'M': + if ((c = nextc()) != '-') { + yyerror("Invalid escape character syntax"); + pushback(c); + return '\0'; + } + if ((c = nextc()) == '\\') { + return read_escape() | 0x80; + } + else if (c == -1) goto eof; + else { + return ((c & 0xff) | 0x80); + } + + case 'C': + if ((c = nextc()) != '-') { + yyerror("Invalid escape character syntax"); + pushback(c); + return '\0'; + } + case 'c': + if ((c = nextc())== '\\') { + c = read_escape(); + } + else if (c == '?') + return 0177; + else if (c == -1) goto eof; + return c & 0x9f; + + eof: + case -1: + yyerror("Invalid escape character syntax"); + return '\0'; + + default: + return c; + } +} + +static int +parse_regx(term, paren) + int term; +{ + register int c; + char kcode = 0; + int once = 0; + int nest = 0; + int options = 0; + int in_brack = 0; + int re_start = ruby_sourceline; + NODE *list = 0; + + newtok(); + while ((c = nextc()) != -1) { + if ((!in_brack && c == term) || nest > 0) { + goto regx_end; + } + + switch (c) { + case '\n': + ruby_sourceline++; + break; + case '[': + in_brack = 1; + break; + case ']': + in_brack = 0; + break; + + case '#': + list = rb_str_extend(list, term); + if (list == (NODE*)-1) return 0; + continue; + + case '\\': + switch (c = nextc()) { + case -1: + ruby_sourceline = re_start; + rb_compile_error("unterminated regexp meets end of file"); + return 0; + + case '\n': + ruby_sourceline++; + break; + + case '\\': + case '^': + case 's': + tokadd('\\'); + tokadd(c); + break; + + case '1': case '2': case '3': + case '4': case '5': case '6': + case '7': case '8': case '9': + case '0': case 'x': + tokadd('\\'); + tokadd(c); + break; + + case 'b': + if (!in_brack) { + tokadd('\\'); + tokadd('b'); + break; + } + /* fall through */ + default: + if (c == paren) nest++; + if (c == term) nest--; + if (c == '\n') { + ruby_sourceline++; + } + else if (c == term) { + tokadd(c); + } + else { + pushback(c); + tokadd('\\'); + tokadd(read_escape()); + } + } + continue; + + case -1: + rb_compile_error("unterminated regexp"); + return 0; + + default: + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + for (i = 0; i < len; i++) { + tokadd(c); + c = nextc(); + } + } + break; + + regx_end: + for (;;) { + switch (c = nextc()) { + case 'i': + options |= RE_OPTION_IGNORECASE; + break; + case 'x': + options |= RE_OPTION_EXTENDED; + break; + case 'o': + once = 1; + break; + case 'n': + kcode = 4; + break; + case 'e': + kcode = 8; + break; + case 's': + kcode = 12; + break; + case 'u': + kcode = 16; + break; + default: + pushback(c); + goto end_options; + } + } + + end_options: + tokfix(); + lex_state = EXPR_END; + if (list) { + if (toklen() > 0) { + VALUE ss = rb_str_new(tok(), toklen()); + list_append(list, NEW_STR(ss)); + } + nd_set_type(list, once?NODE_DREGX_ONCE:NODE_DREGX); + list->nd_cflag = options | kcode; + yylval.node = list; + return tDREGEXP; + } + else { + yylval.val = rb_reg_new(tok(), toklen(), options | kcode); + return tREGEXP; + } + } + tokadd(c); + } + rb_compile_error("unterminated regexp"); + return 0; +} + +static int parse_qstring _((int,int)); + +static int +parse_string(func, term, paren) + int func, term, paren; +{ + int c; + NODE *list = 0; + int strstart; + int nest = 0; + + if (func == '\'') { + return parse_qstring(term, paren); + } + if (func == 0) { /* read 1 line for heredoc */ + ruby_sourceline++; + /* -1 for chomp */ + yylval.val = rb_str_new(lex_pbeg, lex_pend - lex_pbeg - 1); + return tSTRING; + } + strstart = ruby_sourceline; + newtok(); + while ((c = nextc()) != term || nest > 0) { + if (c == -1) { + unterm_str: + ruby_sourceline = strstart; + rb_compile_error("unterminated string meets end of file"); + return 0; + } + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + for (i = 0; i < len; i++) { + tokadd(c); + c = nextc(); + } + } + else if (c == '\n') { + ruby_sourceline++; + } + else if (c == '#') { + list = rb_str_extend(list, term); + if (list == (NODE*)-1) goto unterm_str; + continue; + } + else if (c == '\\') { + c = nextc(); + if (c == '\n') { + ruby_sourceline++; + } + else if (c == term) { + tokadd(c); + } + else { + pushback(c); + if (func != '"') tokadd('\\'); + tokadd(read_escape()); + } + continue; + } + if (c == paren) nest++; + if (c == term) { + nest--; + if (nest == 0) break; + } + tokadd(c); + } + + tokfix(); + lex_state = EXPR_END; + if (list) { + if (toklen() > 0) { + VALUE ss = rb_str_new(tok(), toklen()); + list_append(list, NEW_STR(ss)); + } + yylval.node = list; + if (func == '`') { + nd_set_type(list, NODE_DXSTR); + return tDXSTRING; + } + else { + return tDSTRING; + } + } + else { + yylval.val = rb_str_new(tok(), toklen()); + return (func == '`') ? tXSTRING : tSTRING; + } +} + +static int +parse_qstring(term, paren) + int term, paren; +{ + int strstart; + int c; + int nest = 0; + + strstart = ruby_sourceline; + newtok(); + while ((c = nextc()) != term || nest > 0) { + if (c == -1) { + ruby_sourceline = strstart; + rb_compile_error("unterminated string meets end of file"); + return 0; + } + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + for (i = 0; i < len; i++) { + tokadd(c); + c = nextc(); + } + } + else if (c == '\n') { + ruby_sourceline++; + } + else if (c == '\\') { + c = nextc(); + switch (c) { + case '\n': + ruby_sourceline++; + continue; + + case '\\': + c = '\\'; + break; + + case '\'': + if (term == '\'') { + c = '\''; + break; + } + /* fall through */ + default: + tokadd('\\'); + } + } + if (c == paren) nest++; + if (c == term) { + nest--; + if (nest == 0) break; + } + tokadd(c); + } + + tokfix(); + yylval.val = rb_str_new(tok(), toklen()); + lex_state = EXPR_END; + return tSTRING; +} + +static int +parse_quotedword(term, paren) + int term, paren; +{ + if (parse_qstring(term, paren) == 0) return 0; + yylval.node = NEW_CALL(NEW_STR(yylval.val), rb_intern("split"), 0); + return tDSTRING; +} + +char *strdup(); + +static int +here_document(term, indent) + char term; + int indent; +{ + int c; + char *eos, *p; + int len; + VALUE str; + volatile VALUE line; + VALUE lastline_save; + int offset_save; + NODE *list = 0; + int linesave = ruby_sourceline; + + newtok(); + switch (term) { + case '\'': + case '"': + case '`': + while ((c = nextc()) != term) { + tokadd(c); + } + if (term == '\'') term = 0; + break; + + default: + c = term; + term = '"'; + if (!is_identchar(c)) { + rb_warn("Use of bare << to mean <<\"\" is deprecated"); + break; + } + while (is_identchar(c)) { + tokadd(c); + c = nextc(); + } + pushback(c); + break; + } + tokfix(); + lastline_save = lex_lastline; + offset_save = lex_p - lex_pbeg; + eos = strdup(tok()); + len = strlen(eos); + + str = rb_str_new(0,0); + for (;;) { + line = (*lex_gets)(lex_input); + if (NIL_P(line)) { + error: + ruby_sourceline = linesave; + rb_compile_error("can't find string \"%s\" anywhere before EOF", eos); + free(eos); + return 0; + } + normalize_newline(line); + ruby_sourceline++; + p = RSTRING(line)->ptr; + if (indent) { + while (*p && (*p == ' ' || *p == '\t')) { + p++; + } + } + if (strncmp(eos, p, len) == 0 && p[len] == '\n') { + break; + } + + lex_pbeg = lex_p = RSTRING(line)->ptr; + lex_pend = lex_p + RSTRING(line)->len; +#if 0 + if (indent) { + while (*lex_p && *lex_p == '\t') { + lex_p++; + } + } +#endif + switch (parse_string(term, '\n', '\n')) { + case tSTRING: + case tXSTRING: + rb_str_cat(yylval.val, "\n", 1); + if (!list) { + rb_str_cat(str, RSTRING(yylval.val)->ptr, RSTRING(yylval.val)->len); + } + else { + list_append(list, NEW_STR(yylval.val)); + } + break; + case tDSTRING: + case tDXSTRING: + list_append(yylval.node, NEW_STR(rb_str_new2("\n"))); + nd_set_type(yylval.node, NODE_STR); + if (!list) list = NEW_DSTR(str); + yylval.node = NEW_LIST(yylval.node); + yylval.node->nd_next = yylval.node->nd_head->nd_next; + list_concat(list, yylval.node); + break; + + case 0: + goto error; + } + } + free(eos); + lex_lastline = lastline_save; + lex_pbeg = RSTRING(lex_lastline)->ptr; + lex_pend = lex_pbeg + RSTRING(lex_lastline)->len; + lex_p = lex_pbeg + offset_save; + + lex_state = EXPR_END; + heredoc_end = ruby_sourceline; + ruby_sourceline = linesave; + + if (list) { + yylval.node = list; + } + switch (term) { + case '\0': + case '\'': + case '"': + if (list) return tDSTRING; + yylval.val = str; + return tSTRING; + case '`': + if (list) return tDXSTRING; + return tXSTRING; + } + return 0; +} + +#include "lex.c" + +static void +arg_ambiguous() +{ + rb_warning("ambiguous first argument; make sure"); +} + +#ifndef atof +double atof(); +#endif + +static int +yylex() +{ + register int c; + int space_seen = 0; + struct kwtable *kw; + + if (newline_seen) { + ruby_sourceline += newline_seen; + newline_seen = 0; + } + +retry: + switch (c = nextc()) { + case '\0': /* NUL */ + case '\004': /* ^D */ + case '\032': /* ^Z */ + case -1: /* end of script. */ + return 0; + + /* white spaces */ + case ' ': case '\t': case '\f': case '\r': + case '\13': /* '\v' */ + space_seen = 1; + goto retry; + + case '#': /* it's a comment */ + while ((c = nextc()) != '\n') { + if (c == -1) + return 0; + if (c == '\\') { /* skip a char */ + c = nextc(); + if (c == '\n') ruby_sourceline++; + } + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + for (i = 0; i < len; i++) { + c = nextc(); + if (c == '\n') { + ruby_sourceline++; + break; + } + } + } + } + /* fall through */ + case '\n': + switch (lex_state) { + case EXPR_BEG: + case EXPR_FNAME: + case EXPR_DOT: + ruby_sourceline++; + goto retry; + default: + break; + } + newline_seen++; + lex_state = EXPR_BEG; + return '\n'; + + case '*': + if ((c = nextc()) == '*') { + lex_state = EXPR_BEG; + if (nextc() == '=') { + yylval.id = tPOW; + return tOP_ASGN; + } + pushback(c); + return tPOW; + } + if (c == '=') { + yylval.id = '*'; + lex_state = EXPR_BEG; + return tOP_ASGN; + } + pushback(c); + if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)){ + arg_ambiguous(); + lex_state = EXPR_BEG; + return tSTAR; + } + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + lex_state = EXPR_BEG; + return tSTAR; + } + lex_state = EXPR_BEG; + return '*'; + + case '!': + lex_state = EXPR_BEG; + if ((c = nextc()) == '=') { + return tNEQ; + } + if (c == '~') { + return tNMATCH; + } + pushback(c); + return '!'; + + case '=': + if (lex_p == lex_pbeg + 1) { + /* skip embedded rd document */ + if (strncmp(lex_p, "begin", 5) == 0 && ISSPACE(lex_p[5])) { + for (;;) { + ruby_sourceline++; + lex_p = lex_pend; + c = nextc(); + if (c == -1) { + rb_compile_error("embedded document meets end of file"); + return 0; + } + if (c != '=') continue; + if (strncmp(lex_p, "end", 3) == 0 && ISSPACE(lex_p[3])) { + break; + } + } + ruby_sourceline++; + lex_p = lex_pend; + goto retry; + } + } + + lex_state = EXPR_BEG; + if ((c = nextc()) == '=') { + if ((c = nextc()) == '=') { + return tEQQ; + } + pushback(c); + return tEQ; + } + if (c == '~') { + return tMATCH; + } + else if (c == '>') { + return tASSOC; + } + pushback(c); + return '='; + + case '<': + c = nextc(); + if (c == '<' && + lex_state != EXPR_END && lex_state != EXPR_CLASS && + (lex_state != EXPR_ARG || space_seen)) { + int c2 = nextc(); + int indent = 0; + if (c2 == '-') { + indent = 1; + c2 = nextc(); + } + if (!ISSPACE(c2) && (strchr("\"'`", c2) || is_identchar(c2))) { + return here_document(c2, indent); + } + pushback(c2); + } + lex_state = EXPR_BEG; + if (c == '=') { + if ((c = nextc()) == '>') { + return tCMP; + } + pushback(c); + return tLEQ; + } + if (c == '<') { + if (nextc() == '=') { + yylval.id = tLSHFT; + return tOP_ASGN; + } + pushback(c); + return tLSHFT; + } + pushback(c); + return '<'; + + case '>': + lex_state = EXPR_BEG; + if ((c = nextc()) == '=') { + return tGEQ; + } + if (c == '>') { + if ((c = nextc()) == '=') { + yylval.id = tRSHFT; + return tOP_ASGN; + } + pushback(c); + return tRSHFT; + } + pushback(c); + return '>'; + + case '"': + return parse_string(c,c,c); + case '`': + if (lex_state == EXPR_FNAME) return c; + return parse_string(c,c,c); + + case '\'': + return parse_qstring(c,c); + + case '?': + if (lex_state == EXPR_END) { + lex_state = EXPR_BEG; + return '?'; + } + c = nextc(); + if (lex_state == EXPR_ARG && ISSPACE(c)){ + pushback(c); + arg_ambiguous(); + lex_state = EXPR_BEG; + return '?'; + } + if (c == '\\') { + c = read_escape(); + } + c &= 0xff; + yylval.val = INT2FIX(c); + lex_state = EXPR_END; + return tINTEGER; + + case '&': + if ((c = nextc()) == '&') { + lex_state = EXPR_BEG; + if ((c = nextc()) == '=') { + yylval.id = tANDOP; + return tOP_ASGN; + } + pushback(c); + return tANDOP; + } + else if (c == '=') { + yylval.id = '&'; + lex_state = EXPR_BEG; + return tOP_ASGN; + } + pushback(c); + if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)){ + arg_ambiguous(); + lex_state = EXPR_BEG; + return tAMPER; + } + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + lex_state = EXPR_BEG; + return tAMPER; + } + lex_state = EXPR_BEG; + return '&'; + + case '|': + lex_state = EXPR_BEG; + if ((c = nextc()) == '|') { + if ((c = nextc()) == '=') { + yylval.id = tOROP; + return tOP_ASGN; + } + pushback(c); + return tOROP; + } + else if (c == '=') { + yylval.id = '|'; + return tOP_ASGN; + } + pushback(c); + return '|'; + + case '+': + c = nextc(); + if (lex_state == EXPR_FNAME) { + if (c == '@') { + return tUPLUS; + } + pushback(c); + return '+'; + } + if (c == '=') { + lex_state = EXPR_BEG; + yylval.id = '+'; + return tOP_ASGN; + } + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + if (ISDIGIT(c)) { + goto start_num; + } + pushback(c); + lex_state = EXPR_BEG; + return tUPLUS; + } + lex_state = EXPR_BEG; + pushback(c); + return '+'; + + case '-': + c = nextc(); + if (lex_state == EXPR_FNAME) { + if (c == '@') { + return tUMINUS; + } + pushback(c); + return '-'; + } + if (c == '=') { + lex_state = EXPR_BEG; + yylval.id = '-'; + return tOP_ASGN; + } + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + if (ISDIGIT(c)) { + pushback(c); + c = '-'; + goto start_num; + } + lex_state = EXPR_BEG; + pushback(c); + return tUMINUS; + } + lex_state = EXPR_BEG; + pushback(c); + return '-'; + + case '.': + lex_state = EXPR_BEG; + if ((c = nextc()) == '.') { + if ((c = nextc()) == '.') { + return tDOT3; + } + pushback(c); + return tDOT2; + } + pushback(c); + if (!ISDIGIT(c)) { + lex_state = EXPR_DOT; + return '.'; + } + c = '.'; + /* fall through */ + + start_num: + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + int is_float, seen_point, seen_e; + + is_float = seen_point = seen_e = 0; + lex_state = EXPR_END; + newtok(); + if (c == '-' || c == '+') { + tokadd(c); + c = nextc(); + } + if (c == '0') { + c = nextc(); + if (c == 'x' || c == 'X') { + /* hexadecimal */ + while (c = nextc()) { + if (c == '_') continue; + if (!ISXDIGIT(c)) break; + tokadd(c); + } + pushback(c); + tokfix(); + yylval.val = rb_str2inum(tok(), 16); + return tINTEGER; + } + else if (c >= '0' && c <= '7') { + /* octal */ + do { + tokadd(c); + while ((c = nextc()) == '_') + ; + } while (c >= '0' && c <= '9'); + pushback(c); + tokfix(); + yylval.val = rb_str2inum(tok(), 8); + return tINTEGER; + } + else if (c > '7' && c <= '9') { + yyerror("Illegal octal digit"); + } + else if (c == '.') { + tokadd('0'); + } + else { + pushback(c); + yylval.val = INT2FIX(0); + return tINTEGER; + } + } + + for (;;) { + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + tokadd(c); + break; + + case '.': + if (seen_point || seen_e) { + goto decode_num; + } + else { + int c0 = nextc(); + if (!ISDIGIT(c0)) { + pushback(c0); + goto decode_num; + } + c = c0; + } + tokadd('.'); + tokadd(c); + is_float++; + seen_point++; + break; + + case 'e': + case 'E': + if (seen_e) { + goto decode_num; + } + tokadd(c); + seen_e++; + is_float++; + if ((c = nextc()) == '-' || c == '+') + tokadd(c); + else + continue; + break; + + case '_': /* `_' in decimal just ignored */ + break; + + default: + goto decode_num; + } + c = nextc(); + } + + decode_num: + pushback(c); + tokfix(); + if (is_float) { + yylval.val = rb_float_new(atof(tok())); + return tFLOAT; + } + yylval.val = rb_str2inum(tok(), 10); + return tINTEGER; + } + + case ']': + case '}': + case ')': + lex_state = EXPR_END; + return c; + + case ':': + c = nextc(); + if (c == ':') { + if (lex_state == EXPR_BEG) { + lex_state = EXPR_BEG; + return tCOLON3; + } + if (lex_state == EXPR_ARG && space_seen) { + arg_ambiguous(); + lex_state = EXPR_BEG; + return tCOLON3; + } + lex_state = EXPR_DOT; + return tCOLON2; + } + pushback(c); + if (lex_state == EXPR_END || ISSPACE(c)) { + lex_state = EXPR_BEG; + return ':'; + } + lex_state = EXPR_FNAME; + return tSYMBEG; + + case '/': + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + return parse_regx('/', '/'); + } + if ((c = nextc()) == '=') { + lex_state = EXPR_BEG; + yylval.id = '/'; + return tOP_ASGN; + } + if (lex_state == EXPR_ARG) { + if (space_seen && !ISSPACE(c)) { + pushback(c); + arg_ambiguous(); + return parse_regx('/', '/'); + } + } + lex_state = EXPR_BEG; + pushback(c); + return '/'; + + case '^': + lex_state = EXPR_BEG; + if (nextc() == '=') { + yylval.id = '^'; + return tOP_ASGN; + } + pushback(c); + return c; + + case ',': + case ';': + lex_state = EXPR_BEG; + return c; + + case '~': + if (lex_state == EXPR_FNAME) { + if ((c = nextc()) != '@') { + pushback(c); + } + } + lex_state = EXPR_BEG; + return '~'; + + case '(': + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + c = tLPAREN; + lex_state = EXPR_BEG; + } + else { + lex_state = EXPR_BEG; + } + return c; + + case '[': + if (lex_state == EXPR_FNAME) { + if ((c = nextc()) == ']') { + if ((c = nextc()) == '=') { + return tASET; + } + pushback(c); + return tAREF; + } + pushback(c); + return '['; + } + else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + c = tLBRACK; + } + else if (lex_state == EXPR_ARG && space_seen) { + arg_ambiguous(); + c = tLBRACK; + } + lex_state = EXPR_BEG; + return c; + + case '{': + if (lex_state != EXPR_END && lex_state != EXPR_ARG) + c = tLBRACE; + lex_state = EXPR_BEG; + return c; + + case '\\': + c = nextc(); + if (c == '\n') { + ruby_sourceline++; + space_seen = 1; + goto retry; /* skip \\n */ + } + pushback(c); + return '\\'; + + case '%': + if (lex_state == EXPR_BEG || lex_state == EXPR_MID) { + int term; + int paren; + + c = nextc(); + quotation: + if (!ISALNUM(c)) { + term = c; + c = 'Q'; + } + else { + term = nextc(); + } + if (c == -1 || term == -1) { + rb_compile_error("unterminated quoted string meets end of file"); + return 0; + } + paren = term; + if (term == '(') term = ')'; + else if (term == '[') term = ']'; + else if (term == '{') term = '}'; + else if (term == '<') term = '>'; + + switch (c) { + case 'Q': + return parse_string('"', term, paren); + + case 'q': + return parse_qstring(term, paren); + + case 'w': + return parse_quotedword(term, paren); + + case 'x': + return parse_string('`', term, paren); + + case 'r': + return parse_regx(term, paren); + + default: + yyerror("unknown type of %string"); + return 0; + } + } + if ((c = nextc()) == '=') { + yylval.id = '%'; + return tOP_ASGN; + } + 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 '~': /* $~: match-data */ + /* fall through */ + case '_': /* $_: last read line string */ + local_cnt(c); + /* fall through */ + case '*': /* $*: argv */ + case '$': /* $$: pid */ + case '?': /* $?: last status */ + case '!': /* $!: error string */ + case '@': /* $@: error position */ + case '/': /* $/: input record separator */ + case '\\': /* $\: output record separator */ + case ';': /* $;: field separator */ + case ',': /* $,: output field separator */ + case '.': /* $.: last read line number */ + case '=': /* $=: ignorecase */ + case ':': /* $:: load path */ + case '<': /* $<: reading filename */ + case '>': /* $>: default output handle */ + case '\"': /* $": already loaded files */ + tokadd('$'); + tokadd(c); + tokfix(); + yylval.id = rb_intern(tok()); + return tGVAR; + + case '-': + tokadd('$'); + tokadd(c); + c = nextc(); + tokadd(c); + tokfix(); + yylval.id = rb_intern(tok()); + return tGVAR; + + case '&': /* $&: last match */ + case '`': /* $`: string before last match */ + case '\'': /* $': string after last match */ + case '+': /* $+: string matches last paren. */ + yylval.node = NEW_BACK_REF(c); + return tBACK_REF; + + case '1': case '2': case '3': + case '4': case '5': case '6': + case '7': case '8': case '9': + while (ISDIGIT(c)) { + tokadd(c); + c = nextc(); + } + pushback(c); + tokfix(); + yylval.node = NEW_NTH_REF(atoi(tok())); + return tNTH_REF; + + default: + if (!is_identchar(c)) { + pushback(c); + return '$'; + } + case '0': + tokadd('$'); + } + break; + + case '@': + c = nextc(); + if (!is_identchar(c)) { + pushback(c); + return '@'; + } + newtok(); + tokadd('@'); + break; + + default: + if (c != '_' && !ISALPHA(c) && !ismbchar(c)) { + rb_compile_error("Invalid char '%c' in expression", c); + goto retry; + } + + newtok(); + break; + } + + while (is_identchar(c)) { + tokadd(c); + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + tokadd(c); + for (i = 0; i < len; i++) { + c = nextc(); + tokadd(c); + } + } + c = nextc(); + } + if ((c == '!' || c == '?') && is_identchar(tok()[0])) { + tokadd(c); + } + else { + pushback(c); + } + tokfix(); + + { + int result; + + switch (tok()[0]) { + case '$': + lex_state = EXPR_END; + result = tGVAR; + break; + case '@': + lex_state = EXPR_END; + result = tIVAR; + break; + default: + if (lex_state != EXPR_DOT) { + /* See if it is a reserved word. */ + kw = rb_reserved_word(tok(), toklen()); + if (kw) { + enum lex_state state = lex_state; + if (lex_state == EXPR_FNAME) { + yylval.id = rb_intern(kw->name); + } + lex_state = kw->state; + return kw->id[state != EXPR_BEG]; + } + } + + if (ISUPPER(tok()[0])) { + result = tCONSTANT; + } + else if (toklast() == '!' || toklast() == '?') { + result = tFID; + } else { + result = tIDENTIFIER; + if (lex_state == EXPR_FNAME) { + lex_state = EXPR_END; + if ((c = nextc()) == '=') { + tokadd(c); + } + else { + pushback(c); + } + } + } + if (lex_state == EXPR_BEG || + lex_state == EXPR_DOT || + lex_state == EXPR_ARG){ + lex_state = EXPR_ARG; + } + else { + lex_state = EXPR_END; + } + } + tokfix(); + yylval.id = rb_intern(tok()); + return result; + } +} + +static NODE* +rb_str_extend(list, term) + NODE *list; + char term; +{ + int c; + int brace = -1; + VALUE ss; + NODE *node; + int nest; + + c = nextc(); + switch (c) { + case '$': + case '@': + case '{': + break; + default: + tokadd('#'); + pushback(c); + return list; + } + + ss = rb_str_new(tok(), toklen()); + if (list == 0) { + list = NEW_DSTR(ss); + } + else if (toklen() > 0) { + list_append(list, NEW_STR(ss)); + } + newtok(); + + switch (c) { + case '$': + tokadd('$'); + c = nextc(); + if (c == -1) return (NODE*)-1; + switch (c) { + case '1': case '2': case '3': + case '4': case '5': case '6': + case '7': case '8': case '9': + while (ISDIGIT(c)) { + tokadd(c); + c = nextc(); + } + pushback(c); + goto fetch_id; + + 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(rb_str_new2("#$"))); + pushback(c); + newtok(); + 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 '@': + tokadd(c); + c = nextc(); + while (is_identchar(c)) { + tokadd(c); + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + tokadd(c); + for (i = 0; i < len; i++) { + c = nextc(); + tokadd(c); + } + } + c = nextc(); + } + pushback(c); + break; + + case '{': + if (c == '{') brace = '}'; + nest = 0; + do { + loop_again: + c = nextc(); + switch (c) { + case -1: + if (nest > 0) { + yyerror("bad substitution in string"); + newtok(); + return list; + } + return (NODE*)-1; + case '}': + if (c == brace) { + if (nest == 0) break; + nest--; + } + tokadd(c); + goto loop_again; + case '\\': + c = read_escape(); + tokadd(c); + goto loop_again; + case '{': + if (brace != -1) nest++; + case '\"': + case '/': + case '`': + if (c == term) { + pushback(c); + list_append(list, NEW_STR(rb_str_new2("#"))); + rb_warning("bad substitution in string"); + tokfix(); + list_append(list, NEW_STR(rb_str_new(tok(), toklen()))); + newtok(); + return list; + } + default: + tokadd(c); + break; + } + } while (c != brace); + } + + fetch_id: + tokfix(); + node = NEW_EVSTR(tok(),toklen()); + list_append(list, node); + newtok(); + + return list; +} + +NODE* +rb_node_newnode(type, a0, a1, a2) + enum node_type type; + NODE *a0, *a1, *a2; +{ + NODE *n = (NODE*)rb_newobj(); + + n->flags |= T_NODE; + nd_set_type(n, type); + nd_set_line(n, ruby_sourceline); + n->nd_file = ruby_sourcefile; + + n->u1.node = a0; + n->u2.node = a1; + n->u3.node = a2; + + return n; +} + +static enum node_type +nodetype(node) /* for debug */ + NODE *node; +{ + return (enum node_type)nd_type(node); +} + +static int +nodeline(node) + NODE *node; +{ + return nd_line(node); +} + +static NODE* +newline_node(node) + NODE *node; +{ + NODE *nl = 0; + if (node) { + nl = NEW_NEWLINE(node); + fixpos(nl, node); + nl->nd_nth = nd_line(node); + } + return nl; +} + +static void +fixpos(node, orig) + NODE *node, *orig; +{ + if (!node) return; + if (!orig) return; + node->nd_file = orig->nd_file; + nd_set_line(node, nd_line(orig)); +} + +static NODE* +block_append(head, tail) + NODE *head, *tail; +{ + NODE *end; + + if (tail == 0) return head; + if (head == 0) return tail; + + if (nd_type(head) != NODE_BLOCK) { + end = NEW_BLOCK(head); + end->nd_end = end; + fixpos(end, head); + head = end; + } + else { + end = head->nd_end; + } + + if (RTEST(rb_verbose)) { + NODE *nd = end->nd_head; + newline: + switch (nd_type(nd)) { + case NODE_RETURN: + case NODE_BREAK: + case NODE_NEXT: + case NODE_REDO: + case NODE_RETRY: + rb_warning("statement not reached"); + break; + + case NODE_NEWLINE: + nd = nd->nd_next; + goto newline; + + default: + break; + } + } + + if (nd_type(tail) != NODE_BLOCK) { + tail = NEW_BLOCK(tail); + tail->nd_end = tail; + } + end->nd_next = tail; + head->nd_end = tail->nd_end; + return head; +} + +static NODE* +list_append(head, tail) + NODE *head, *tail; +{ + NODE *last; + + if (head == 0) return NEW_LIST(tail); + + last = head; + while (last->nd_next) { + last = last->nd_next; + } + + last->nd_next = NEW_LIST(tail); + head->nd_alen += 1; + return head; +} + +static NODE* +list_concat(head, tail) + NODE *head, *tail; +{ + NODE *last; + + last = head; + while (last->nd_next) { + last = last->nd_next; + } + + last->nd_next = tail; + head->nd_alen += tail->nd_alen; + + return head; +} + +static NODE * +call_op(recv, id, narg, arg1) + NODE *recv; + ID id; + int narg; + NODE *arg1; +{ + value_expr(recv); + if (narg == 1) { + value_expr(arg1); + } + + return NEW_CALL(recv, id, narg==1?NEW_LIST(arg1):0); +} + +static NODE* +match_gen(node1, node2) + NODE *node1; + NODE *node2; +{ + local_cnt('~'); + + switch (nd_type(node1)) { + case NODE_DREGX: + case NODE_DREGX_ONCE: + return NEW_MATCH2(node1, node2); + + case NODE_LIT: + if (TYPE(node1->nd_lit) == T_REGEXP) { + return NEW_MATCH2(node1, node2); + } + } + + switch (nd_type(node2)) { + case NODE_DREGX: + case NODE_DREGX_ONCE: + return NEW_MATCH3(node2, node1); + + case NODE_LIT: + if (TYPE(node2->nd_lit) == T_REGEXP) { + return NEW_MATCH3(node2, node1); + } + } + + return NEW_CALL(node1, tMATCH, NEW_LIST(node2)); +} + +static NODE* +gettable(id) + ID id; +{ + if (id == kSELF) { + return NEW_SELF(); + } + else if (id == kNIL) { + return NEW_NIL(); + } + else if (id == kTRUE) { + return NEW_TRUE(); + } + else if (id == kFALSE) { + return NEW_FALSE(); + } + else if (id == k__FILE__) { + return NEW_STR(rb_str_new2(ruby_sourcefile)); + } + else if (id == k__LINE__) { + return NEW_LIT(INT2FIX(ruby_sourceline)); + } + else if (is_local_id(id)) { + if (dyna_in_block() && rb_dvar_defined(id)) return NEW_DVAR(id); + if (local_id(id)) return NEW_LVAR(id); + /* method call without arguments */ + return NEW_VCALL(id); + } + else if (is_global_id(id)) { + return NEW_GVAR(id); + } + else if (is_instance_id(id)) { + return NEW_IVAR(id); + } + else if (is_const_id(id)) { + return NEW_CVAR(id); + } + rb_bug("invalid id for gettable"); + return 0; +} + +static NODE* +assignable(id, val) + ID id; + NODE *val; +{ + NODE *lhs = 0; + + value_expr(val); + if (id == kSELF) { + yyerror("Can't change the value of self"); + } + else if (id == kNIL) { + yyerror("Can't assign to nil"); + } + else if (id == kTRUE) { + yyerror("Can't assign to true"); + } + else if (id == kFALSE) { + yyerror("Can't assign to false"); + } + else if (id == k__FILE__) { + yyerror("Can't assign to __FILE__"); + } + else if (id == k__LINE__) { + yyerror("Can't assign to __LINE__"); + } + else if (is_local_id(id)) { + if (rb_dvar_defined(id)) { + lhs = NEW_DASGN(id, val); + } + else if (local_id(id) || !dyna_in_block()) { + lhs = NEW_LASGN(id, val); + } + else{ + rb_dvar_push(id, 0); + lhs = NEW_DASGN_PUSH(id, val); + } + } + else if (is_global_id(id)) { + lhs = NEW_GASGN(id, val); + } + else if (is_instance_id(id)) { + lhs = NEW_IASGN(id, val); + } + else if (is_const_id(id)) { + if (cur_mid || in_single) + yyerror("dynamic constant assignment"); + lhs = NEW_CASGN(id, val); + } + else { + rb_bug("bad id for variable"); + } + return lhs; +} + +static NODE * +arg_add(node1, node2) + NODE *node1; + NODE *node2; +{ + return NEW_ARGSCAT(node1, node2); +} + +static NODE * +aryset(recv, idx, val) + NODE *recv, *idx, *val; +{ + value_expr(recv); + value_expr(val); + if (idx) { + if (nd_type(idx) == NODE_ARRAY) { + idx = list_append(idx, val); + } + else { + idx = arg_add(idx, val); + } + } + return NEW_CALL(recv, tASET, idx); +} + +ID +rb_id_attrset(id) + ID id; +{ + id &= ~ID_SCOPE_MASK; + id |= ID_ATTRSET; + return id; +} + +static NODE * +attrset(recv, id, val) + NODE *recv, *val; + ID id; +{ + value_expr(recv); + value_expr(val); + + return NEW_CALL(recv, rb_id_attrset(id), NEW_LIST(val)); +} + +static void +rb_backref_error(node) + NODE *node; +{ + switch (nd_type(node)) { + case NODE_NTH_REF: + rb_compile_error("Can't set variable $%d", node->nd_nth); + break; + case NODE_BACK_REF: + rb_compile_error("Can't set variable $%c", node->nd_nth); + break; + } +} + +static int +value_expr(node) + NODE *node; +{ + if (node == 0) return Qtrue; + + switch (nd_type(node)) { + case NODE_RETURN: + case NODE_BREAK: + case NODE_NEXT: + case NODE_REDO: + case NODE_RETRY: + case NODE_WHILE: + case NODE_UNTIL: + case NODE_CLASS: + case NODE_MODULE: + case NODE_DEFN: + case NODE_DEFS: + yyerror("void value expression"); + return Qfalse; + break; + + case NODE_BLOCK: + while (node->nd_next) { + node = node->nd_next; + } + return value_expr(node->nd_head); + + case NODE_IF: + return value_expr(node->nd_body) && value_expr(node->nd_else); + + case NODE_NEWLINE: + return value_expr(node->nd_next); + + default: + return Qtrue; + } +} + +static NODE *cond2(); + +static int +assign_in_cond(node) + NODE *node; +{ + switch (nd_type(node)) { + case NODE_MASGN: + yyerror("multiple assignment in conditional"); + return 1; + + case NODE_LASGN: + case NODE_DASGN: + case NODE_GASGN: + case NODE_IASGN: + case NODE_CASGN: + break; + + case NODE_NEWLINE: + default: + return 0; + } + + switch (nd_type(node->nd_value)) { + case NODE_LIT: + case NODE_STR: + case NODE_DSTR: + case NODE_XSTR: + case NODE_DXSTR: + case NODE_EVSTR: + case NODE_DREGX: + case NODE_NIL: + case NODE_TRUE: + case NODE_FALSE: + /* reports always */ + rb_warn("found = in conditional, should be =="); + return 1; + + default: + break; + } + if (assign_in_cond(node->nd_value) == 0) { + rb_warning("assignment in condition"); + } + return 1; +} + +static NODE* +cond0(node) + NODE *node; +{ + enum node_type type = nd_type(node); + + assign_in_cond(node); + switch (type) { + case NODE_DREGX: + case NODE_DREGX_ONCE: + local_cnt('_'); + local_cnt('~'); + return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_"))); + + 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); + node->nd_cnt = local_append(0); + return node; + + case NODE_LIT: + if (TYPE(node->nd_lit) == T_REGEXP) { + local_cnt('_'); + local_cnt('~'); + return NEW_MATCH(node); + } + if (TYPE(node->nd_lit) == T_STRING) { + local_cnt('_'); + local_cnt('~'); + return NEW_MATCH(rb_reg_new(RSTRING(node)->ptr,RSTRING(node)->len,0)); + } + default: + return node; + } +} + +static NODE* +cond(node) + NODE *node; +{ + if (node == 0) return 0; + if (nd_type(node) == NODE_NEWLINE){ + node->nd_next = cond0(node->nd_next); + return node; + } + return cond0(node); +} + +static NODE* +cond2(node) + NODE *node; +{ + enum node_type type; + + node = cond(node); + type = nd_type(node); + if (type == NODE_NEWLINE) node = node->nd_next; + if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) { + return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$."))); + } + return node; +} + +static NODE* +logop(type, left, right) + enum node_type type; + NODE *left, *right; +{ + value_expr(left); + return rb_node_newnode(type, cond(left), cond(right), 0); +} + +static NODE * +arg_blk_pass(node1, node2) + NODE *node1; + NODE *node2; +{ + if (node2) { + node2->nd_head = node1; + return node2; + } + return node1; +} + +static NODE* +new_call(r,m,a) + NODE *r; + ID m; + NODE *a; +{ + if (a && nd_type(a) == NODE_BLOCK_PASS) { + a->nd_iter = NEW_CALL(r,m,a->nd_head); + return a; + } + return NEW_CALL(r,m,a); +} + +static NODE* +new_fcall(m,a) + ID m; + NODE *a; +{ + if (a && nd_type(a) == NODE_BLOCK_PASS) { + a->nd_iter = NEW_FCALL(m,a->nd_head); + return a; + } + return NEW_FCALL(m,a); +} + +static struct local_vars { + ID *tbl; + int nofree; + int cnt; + int dlev; + struct local_vars *prev; +} *lvtbl; + +static void +local_push() +{ + struct local_vars *local; + + local = ALLOC(struct local_vars); + local->prev = lvtbl; + local->nofree = 0; + local->cnt = 0; + local->tbl = 0; + local->dlev = 0; + lvtbl = local; +} + +static void +local_pop() +{ + struct local_vars *local = lvtbl->prev; + + if (lvtbl->tbl) { + if (!lvtbl->nofree) free(lvtbl->tbl); + else lvtbl->tbl[0] = lvtbl->cnt; + } + free(lvtbl); + lvtbl = local; +} + +static ID* +local_tbl() +{ + lvtbl->nofree = 1; + return lvtbl->tbl; +} + +static int +local_append(id) + ID id; +{ + if (lvtbl->tbl == 0) { + lvtbl->tbl = ALLOC_N(ID, 4); + lvtbl->tbl[0] = 0; + lvtbl->tbl[1] = '_'; + lvtbl->tbl[2] = '~'; + lvtbl->cnt = 2; + if (id == '_') return 0; + if (id == '~') return 1; + } + else { + REALLOC_N(lvtbl->tbl, ID, lvtbl->cnt+2); + } + + lvtbl->tbl[lvtbl->cnt+1] = id; + return lvtbl->cnt++; +} + +static int +local_cnt(id) + ID id; +{ + int cnt, max; + + if (id == 0) return lvtbl->cnt; + + for (cnt=1, max=lvtbl->cnt+1; cnttbl[cnt] == id) return cnt-1; + } + return local_append(id); +} + +static int +local_id(id) + ID id; +{ + int i, max; + + if (lvtbl == 0) return Qfalse; + for (i=3, max=lvtbl->cnt+1; itbl[i] == id) return Qtrue; + } + return Qfalse; +} + +static void +top_local_init() +{ + local_push(); + lvtbl->cnt = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0; + if (lvtbl->cnt > 0) { + lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt+3); + MEMCPY(lvtbl->tbl, ruby_scope->local_tbl, ID, lvtbl->cnt+1); + } + else { + lvtbl->tbl = 0; + } + if (ruby_dyna_vars) + lvtbl->dlev = 1; + else + lvtbl->dlev = 0; +} + +static void +top_local_setup() +{ + int len = lvtbl->cnt; + int i; + + if (len > 0) { + i = lvtbl->tbl[0]; + + if (i < len) { + if (i == 0 || ruby_scope->flag == SCOPE_ALLOCA) { + VALUE *vars = ALLOC_N(VALUE, len+1); + if (ruby_scope->local_vars) { + *vars++ = ruby_scope->local_vars[-1]; + MEMCPY(vars, ruby_scope->local_vars, VALUE, i); + rb_mem_clear(vars+i, len-i); + } + else { + *vars++ = 0; + rb_mem_clear(vars, len); + } + ruby_scope->local_vars = vars; + ruby_scope->flag |= SCOPE_MALLOC; + } + else { + VALUE *vars = ruby_scope->local_vars-1; + REALLOC_N(vars, VALUE, len+1); + ruby_scope->local_vars = vars+1; + rb_mem_clear(ruby_scope->local_vars+i, len-i); + } + if (ruby_scope->local_tbl && ruby_scope->local_vars[-1] == 0) { + free(ruby_scope->local_tbl); + } + ruby_scope->local_vars[-1] = 0; + ruby_scope->local_tbl = local_tbl(); + } + } + local_pop(); +} + +static struct RVarmap* +dyna_push() +{ + lvtbl->dlev++; + return ruby_dyna_vars; +} + +static void +dyna_pop(vars) + struct RVarmap* vars; +{ + lvtbl->dlev--; + ruby_dyna_vars = vars; +} + +static int +dyna_in_block() +{ + return (lvtbl->dlev > 0); +} + +static void +cref_pop() +{ + cur_cref = cur_cref->nd_next; +} + +void +rb_parser_append_print() +{ + ruby_eval_tree = + block_append(ruby_eval_tree, + NEW_FCALL(rb_intern("print"), + NEW_ARRAY(NEW_GVAR(rb_intern("$_"))))); +} + +void +rb_parser_while_loop(chop, split) + int chop, split; +{ + if (split) { + ruby_eval_tree = + block_append(NEW_GASGN(rb_intern("$F"), + NEW_CALL(NEW_GVAR(rb_intern("$_")), + rb_intern("split"), 0)), + ruby_eval_tree); + } + if (chop) { + ruby_eval_tree = + block_append(NEW_CALL(NEW_GVAR(rb_intern("$_")), + rb_intern("chop!"), 0), ruby_eval_tree); + } + ruby_eval_tree = NEW_OPT_N(ruby_eval_tree); +} + +static struct { + ID token; + char *name; +} op_tbl[] = { + tDOT2, "..", + '+', "+", + '-', "-", + '+', "+(binary)", + '-', "-(binary)", + '*', "*", + '/', "/", + '%', "%", + tPOW, "**", + tUPLUS, "+@", + tUMINUS, "-@", + tUPLUS, "+(unary)", + tUMINUS, "-(unary)", + '|', "|", + '^', "^", + '&', "&", + tCMP, "<=>", + '>', ">", + tGEQ, ">=", + '<', "<", + tLEQ, "<=", + tEQ, "==", + tEQQ, "===", + tNEQ, "!=", + tMATCH, "=~", + tNMATCH, "!~", + '!', "!", + '~', "~", + '!', "!(unary)", + '~', "~(unary)", + '!', "!@", + '~', "~@", + tAREF, "[]", + tASET, "[]=", + tLSHFT, "<<", + tRSHFT, ">>", + tCOLON2, "::", + tCOLON3, "::", + '`', "`", + 0, 0, +}; + +char *rb_id2name(); +char *rb_class2name(); + +static st_table *sym_tbl; +static st_table *sym_rev_tbl; + +void +Init_sym() +{ + sym_tbl = st_init_strtable_with_size(200); + sym_rev_tbl = st_init_numtable_with_size(200); + rb_global_variable((VALUE*)&cur_cref); + rb_global_variable((VALUE*)&lex_lastline); +} + +ID +rb_intern(name) + char *name; +{ + static ID last_id = LAST_TOKEN; + int id; + int last; + + if (st_lookup(sym_tbl, name, &id)) + return id; + + id = 0; + switch (name[0]) { + case '$': + id |= ID_GLOBAL; + break; + case '@': + id |= ID_INSTANCE; + break; + default: + if (name[0] != '_' && !ISALPHA(name[0]) && !ismbchar(name[0])) { + /* operator */ + int i; + + for (i=0; op_tbl[i].token; i++) { + if (*op_tbl[i].name == *name && + strcmp(op_tbl[i].name, name) == 0) { + id = op_tbl[i].token; + goto id_regist; + } + } + } + + last = strlen(name)-1; + if (name[last] == '=') { + /* attribute assignment */ + char *buf = ALLOCA_N(char,last+1); + + strncpy(buf, name, last); + buf[last] = '\0'; + id = rb_intern(buf); + if (id > LAST_TOKEN) { + id = rb_id_attrset(id); + goto id_regist; + } + id |= ID_ATTRSET; + } + else if (ISUPPER(name[0])) { + id = ID_CONST; + } + else { + id = ID_LOCAL; + } + break; + } + id |= ++last_id << ID_SCOPE_SHIFT; + id_regist: + name = strdup(name); + st_add_direct(sym_tbl, name, id); + st_add_direct(sym_rev_tbl, id, name); + return id; +} + +char * +rb_id2name(id) + ID id; +{ + char *name; + + if (id < LAST_TOKEN) { + int i = 0; + + for (i=0; op_tbl[i].token; i++) { + if (op_tbl[i].token == id) + return op_tbl[i].name; + } + } + + if (st_lookup(sym_rev_tbl, id, &name)) + return name; + + if (is_attrset_id(id)) { + char *res; + ID id2; + + id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL; + res = rb_id2name(id2); + + if (res) { + char *buf = ALLOCA_N(char, strlen(res)+2); + + strcpy(buf, res); + strcat(buf, "="); + rb_intern(buf); + return rb_id2name(id); + } + } + return 0; +} + +int +rb_is_const_id(id) + ID id; +{ + if (is_const_id(id)) return Qtrue; + return Qfalse; +} + +int +rb_is_instance_id(id) + ID id; +{ + if (is_instance_id(id)) return Qtrue; + return Qfalse; +} + +static void +special_local_set(c, val) + char c; + VALUE val; +{ + int cnt; + + top_local_init(); + cnt = local_cnt(c); + top_local_setup(); + ruby_scope->local_vars[cnt] = val; +} + +VALUE +rb_backref_get() +{ + if (ruby_scope->local_vars) { + return ruby_scope->local_vars[1]; + } + return Qnil; +} + +void +rb_backref_set(val) + VALUE val; +{ + if (ruby_scope->local_vars) { + ruby_scope->local_vars[1] = val; + } + else { + special_local_set('~', val); + } +} + +VALUE +rb_lastline_get() +{ + if (ruby_scope->local_vars) { + return ruby_scope->local_vars[0]; + } + return Qnil; +} + +void +rb_lastline_set(val) + VALUE val; +{ + if (ruby_scope->local_vars) { + ruby_scope->local_vars[0] = val; + } + else { + special_local_set('_', val); + } +} diff --git a/sample/mine.rb b/sample/mine.rb new file mode 100644 index 0000000000..b9557d54a2 --- /dev/null +++ b/sample/mine.rb @@ -0,0 +1,173 @@ +class Board + def clr + print "\e[2J" + end + def pos(x,y) + printf "\e[%d;%dH", y+1, x*2+1 + end + def colorstr(id,s) + printf "\e[%dm%s\e[0m", id, s + end + def put(x, y, col, str) + pos(x,y); colorstr(43,str) + pos(0,@hi); print "$B;D$j(B:",@mc,"/",@total," " + pos(x,y) + end + private :clr, :pos, :colorstr, :put + CHR=["$B!&(B","$B#1(B","$B#2(B","$B#3(B","$B#4(B","$B#5(B","$B#6(B","$B#7(B","$B#8(B","$B!z(B","$B!|(B","@@"] + COL=[46,43,45] # default,opened,over + def initialize(h,w,m) + # $B%2!<%`HW$N@8@.(B(h:$B=D!$(Bw:$B2#!$(Bm:$BGzCF$N?t(B) + @hi=h; @wi=w; @m=m + reset + end + def reset + # $B%2!<%`HW$r(B($B:F(B)$B=i4|2=$9$k(B + srand() + @cx=0; @cy=0; @mc=@m + @over=false + @data=Array.new(@hi*@wi) + @state=Array.new(@hi*@wi) + @total=@hi*@wi + @total.times {|i| @data[i]=0} + @m.times do + loop do + j=rand(@total-1) + if @data[j] == 0 then + @data[j]=1 + break + end + end + end + clr; pos(0,0) + @hi.times{|y| pos(0,y); colorstr(COL[0],CHR[0]*@wi)} + pos(@cx,@cy) + end + def mark + # $B8=:_$N%+!<%=%k0LCV$K%^!<%/$r$D$1$k(B + if @state[@wi*@cy+@cx] != nil then return end + @state[@wi*@cy+@cx] = "MARK" + @mc=@mc-1; + @total=@total-1; + put(@cx, @cy, COL[1], CHR[9]) + end + def open(x=@cx,y=@cy) + # $B8=:_$N%+!<%=%k0LCV$r%*!<%W%s$K$9$k(B + # $BGzCF$,$"$l$P%2!<%`%*!<%P!<(B + if @state[@wi*y+x] =="OPEN" then return 0 end + if @state[@wi*y+x] == nil then @total=@total-1 end + if @state[@wi*y+x] =="MARK" then @mc=@mc+1 end + @state[@wi*y+x]="OPEN" + if fetch(x,y) == 1 then @over = 1; return end + c = count(x,y) + put(x, y, COL[1], CHR[c]) + return 0 if c != 0 + if x > 0 && y > 0 then open(x-1,y-1) end + if y > 0 then open(x, y-1) end + if x < @wi-1 && y > 0 then open(x+1,y-1) end + if x > 0 then open(x-1,y) end + if x < @wi-1 then open(x+1,y) end + if x > 0 && y < @hi-1 then open(x-1,y+1) end + if y < @hi -1 then open(x,y+1) end + if x < @wi-1 && y < @hi-1 then open(x+1,y+1) end + pos(@cx,@cy) + end + def fetch(x,y) + # (x,y)$B$N0LCV$NGzCF$N?t(B(0 or 1)$B$rJV$9(B + if x < 0 then 0 + elsif x >= @wi then 0 + elsif y < 0 then 0 + elsif y >= @hi then 0 + else + @data[x*@wi+y] + end + end + def count(x,y) + # (x,y)$B$KNY@\$9$kGzCF$N?t$rJV$9(B + fetch(x-1,y-1)+fetch(x,y-1)+fetch(x+1,y-1)+ + fetch(x-1,y) + fetch(x+1,y)+ + fetch(x-1,y+1)+fetch(x,y+1)+fetch(x+1,y+1) + end + def over(win) + # $B%2!<%`$N=*N;(B + quit + unless win + pos(@cx,@cy); print CHR[11] + end + pos(0,@hi) + if win then print "*** YOU WIN !! ***" + else print "*** GAME OVER ***" + end + end + def over? + # $B%2!<%`$N=*N;%A%'%C%/(B + # $B=*N;=hM}$b8F$S=P$9(B + remain = (@mc+@total == 0) + if @over || remain + over(remain) + true + else + false + end + end + def quit + # $B%2!<%`$NCfCG(B($B$^$?$O=*N;(B) + # $BHWLL$rA4$F8+$;$k(B + @hi.times do|y| + pos(0,y) + @wi.times do|x| + colorstr(if @state[y*@wi+x] == "MARK" then COL[1] else COL[2] end, + if fetch(x,y)==1 then CHR[10] else CHR[count(x,y)] end) + end + end + end + def down + # $B%+!<%=%k$r2<$K(B + if @cy < @hi-1 then @cy=@cy+1; pos(@cx, @cy) end + end + def up + # $B%+!<%=%k$r>e$K(B + if @cy > 0 then @cy=@cy-1; pos(@cx, @cy) end + end + def left + # $B%+!<%=%k$r:8$K(B + if @cx > 0 then @cx=@cx-1; pos(@cx, @cy) end + end + def right + # $B%+!<%=%k$r1&$K(B + if @cx < @wi-1 then @cx=@cx+1; pos(@cx, @cy) end + end +end + +bd=Board.new(10,10,10) +system("stty raw -echo") +begin + loop do + case getc + when ?n # new game + bd.reset + when ?m # mark + bd.mark + when ?j + bd.down + when ?k + bd.up + when ?h + bd.left + when ?l + bd.right + when ?\s + bd.open + when ?q,?\C-c # quit game + bd.quit + break + end + if bd.over? + if getc == ?q then break end + bd.reset + end + end +ensure + system("stty -raw echo") +end +print "\n" diff --git a/sample/rename.rb b/sample/rename.rb new file mode 100644 index 0000000000..9abea7e327 --- /dev/null +++ b/sample/rename.rb @@ -0,0 +1,297 @@ +#! /usr/local/bin/ruby -p +gsub!(/\bary_aref\b/,"rb_ary_aref") +gsub!(/\bary_assoc\b/,"rb_ary_assoc") +gsub!(/\bary_concat\b/,"rb_ary_concat") +gsub!(/\bary_delete\b/,"rb_ary_delete") +gsub!(/\bary_delete_at\b/,"rb_ary_delete_at") +gsub!(/\bary_each\b/,"rb_ary_each") +gsub!(/\bary_entry\b/,"rb_ary_entry") +gsub!(/\bary_freeze\b/,"rb_ary_freeze") +gsub!(/\bary_includes\b/,"rb_ary_includes") +gsub!(/\bary_join\b/,"rb_ary_join") +gsub!(/\bary_new([234])?\b/,"rb_ary_new\\1") +gsub!(/\bary_plus\b/,"rb_ary_plus") +gsub!(/\bary_pop\b/,"rb_ary_pop") +gsub!(/\bary_push\b/,"rb_ary_push") +gsub!(/\bary_rassoc\b/,"rb_ary_rassoc") +gsub!(/\bary_reverse\b/,"rb_ary_reverse") +gsub!(/\bary_shift\b/,"rb_ary_shift") +gsub!(/\bary_sort\b/,"rb_ary_sort") +gsub!(/\bary_store\b/,"rb_ary_store") +gsub!(/\bary_to_s\b/,"rb_ary_to_s") +gsub!(/\bary_unshift\b/,"rb_ary_unshift") +gsub!(/\bassoc_new\b/,"rb_assoc_new") +gsub!(/\bcArray\b/,"rb_cArray") +gsub!(/\bmemclear\b/,"rb_mem_clear") +gsub!(/\bbig2dbl\b/,"rb_big2dbl") +gsub!(/\bbig2long\b/,"rb_big2long") +gsub!(/\bbig2str\b/,"rb_big2str") +gsub!(/\bbig2ulong\b/,"rb_big2ulong") +gsub!(/\bbig_2comp\b/,"rb_big_2comp") +gsub!(/\bbig_and\b/,"rb_big_and") +gsub!(/\bbig_clone\b/,"rb_big_clone") +gsub!(/\bbig_lshift\b/,"rb_big_lshift") +gsub!(/\bbig_minus\b/,"rb_big_minus") +gsub!(/\bbig_mul\b/,"rb_big_mul") +gsub!(/\bbig_norm\b/,"rb_big_norm") +gsub!(/\bbig_or\b/,"rb_big_or") +gsub!(/\bbig_plus\b/,"rb_big_plus") +gsub!(/\bbig_pow\b/,"rb_big_pow") +gsub!(/\bbig_rand\b/,"rb_big_rand") +gsub!(/\bbig_xor\b/,"rb_big_xor") +gsub!(/\bcBignum\b/,"rb_cBignum") +gsub!(/\bdbl2big\b/,"rb_dbl2big") +gsub!(/\bint2big\b/,"rb_int2big") +gsub!(/\bint2inum\b/,"rb_int2inum") +gsub!(/\bstr2inum\b/,"rb_str2inum") +gsub!(/\buint2big\b/,"rb_uint2big") +gsub!(/\buint2inum\b/,"rb_uint2inum") +gsub!(/\bclass_instance_methods\b/,"rb_class_instance_methods") +gsub!(/\bclass_new\b/,"rb_class_new") +gsub!(/\bclass_private_instance_methods\b/,"rb_class_private_instance_methods") +gsub!(/\bclass_protected_instance_methods\b/,"rb_class_protected_instance_methods") +gsub!(/\bmod_ancestors\b/,"rb_mod_ancestors") +gsub!(/\bmod_included_modules\b/,"rb_mod_included_modules") +gsub!(/\bmodule_new\b/,"rb_module_new") +gsub!(/\bobj_singleton_methods\b/,"rb_obj_singleton_methods") +gsub!(/\bsingleton_class\b/,"rb_singleton_class") +gsub!(/\bmComparable\b/,"rb_mComparable") +gsub!(/\bcDir\b/,"rb_cDir") +gsub!(/\benum_length\b/,"rb_enum_length") +gsub!(/\bmEnumerable\b/,"rb_mEnumerable") +gsub!(/\bBug\b/,"rb_bug") +gsub!(/\brb_check_type\b/,"rb_check_type") +gsub!(/\beArgError\b/,"rb_eArgError") +gsub!(/\beException\b/,"rb_eException") +gsub!(/\beFatal\b/,"rb_eFatal") +gsub!(/\beIndexError\b/,"rb_eIndexError") +gsub!(/\beInterrupt\b/,"rb_eInterrupt") +gsub!(/\beLoadError\b/,"rb_eLoadError") +gsub!(/\beNameError\b/,"rb_eNameError") +gsub!(/\beNotImpError\b/,"rb_eNotImpError") +gsub!(/\beRuntimeError\b/,"rb_eRuntimeError") +gsub!(/\beSecurityError\b/,"rb_eSecurityError") +gsub!(/\beStandardError\b/,"rb_eStandardError") +gsub!(/\beSyntaxError\b/,"rb_eSyntaxError") +gsub!(/\beSystemCallError\b/,"rb_eSystemCallError") +gsub!(/\beSystemExit\b/,"rb_eSystemExit") +gsub!(/\beTypeError\b/,"rb_eTypeError") +gsub!(/\bexc_new([23]?)\b/,"rb_exc_new\\1") +gsub!(/\bFatal\b/,"rb_fatal") +gsub!(/\bLoadError\b/,"rb_loaderror") +gsub!(/\bmErrno\b/,"rb_mErrno") +gsub!(/\bRaise\b/,"rb_raise") +gsub!(/\bWarn(ing)?\b/,"rb_warn\\1") +gsub!(/\bnerrs\b/,"ruby_nerrs") +gsub!(/\bcProc\b/,"rb_cProc") +gsub!(/\bcThread\b/,"rb_cThread") +gsub!(/\brb_check_safe_str\b/,"rb_check_safe_str") +gsub!(/\bclass_new_instance\b/,"rb_class_new_instance") +gsub!(/\bdyna_var_asgn\b/,"rb_dvar_asgn") +gsub!(/\bdyna_var_defined\b/,"rb_dvar_defined") +gsub!(/\bdyna_var_push\b/,"rb_dvar_push") +gsub!(/\bdyna_var_ref\b/,"rb_dvar_ref") +gsub!(/\bf_lambda\b/,"rb_f_lambda") +gsub!(/\bf_load\b/,";xxx_need_modify;rb_load") +gsub!(/\bf_require\b/,"rb_f_require") +gsub!(/\bgc_mark_threads\b/,"rb_gc_mark_threads") +gsub!(/\biterator_p\b/,"rb_iterator_p") +gsub!(/\bobj_call_init\b/,"rb_obj_call_init") +gsub!(/\brb_set_end_proc\b/,"rb_set_end_proc") +gsub!(/\brb_set_safe_level\b/,"rb_set_safe_level") +gsub!(/\bthread_alone\b/,"rb_thread_alone") +gsub!(/\bthread_create\b/,"rb_thread_create") +gsub!(/\bthread_critical\b/,"rb_thread_critical") +gsub!(/\bthread_fd_writable\b/,"rb_thread_fd_writable") +gsub!(/\bthread_interrupt\b/,"rb_thread_interrupt") +gsub!(/\bthread_schedule\b/,"rb_thread_schedule") +gsub!(/\bthread_select\b/,"rb_thread_select") +gsub!(/\bthread_sleep\b/,"rb_thread_sleep") +gsub!(/\bthread_sleep_forever\b/,"rb_thread_sleep_forever") +gsub!(/\bthread_trap_eval\b/,"rb_thread_trap_eval") +gsub!(/\bthread_wait_fd\b/,"rb_thread_wait_fd") +gsub!(/\bthread_wait_for\b/,"rb_thread_wait_for") +gsub!(/\bthe_class\b/,"ruby_class") +gsub!(/\bthe_dyna_vars\b/,"ruby_dyna_vars") +gsub!(/\bthe_frame\b/,"ruby_frame") +gsub!(/\bthe_init\b/,"ruby_init") +gsub!(/\bthe_scope\b/,"ruby_scope") +gsub!(/\bcFile\b/,"rb_cFile") +gsub!(/\bfile_open\b/,"rb_file_open") +gsub!(/\bfile_s_expand_path\b/,"rb_file_s_expand_path") +gsub!(/\bmFileTest\b/,"rb_mFileTest") +gsub!(/\bdata_object_alloc\b/,"rb_data_object_alloc") +gsub!(/\bgc_call_finalizer_at_exit\b/,"rb_gc_call_finalizer_at_exit") +gsub!(/\bgc_force_recycle\b/,"rb_gc_force_recycle") +gsub!(/\bgc_gc\b/,"rb_gc") +gsub!(/\bgc_mark\b/,"rb_gc_mark") +gsub!(/\bgc_stack_start\b/,"rb_gc_stack_start") +gsub!(/\bmGC\b/,"rb_mGC") +gsub!(/\bcHash\b/,"rb_cHash") +gsub!(/\benv_path_tainted\b/,"rb_env_path_tainted") +gsub!(/\bhash_aref\b/,"rb_hash_aref") +gsub!(/\bhash_aset\b/,"rb_hash_aset") +gsub!(/\bhash_freeze\b/,"rb_hash_freeze") +gsub!(/\bhash_new\b/,"rb_hash_new") +gsub!(/\bcIO\b/,"rb_cIO") +gsub!(/\beEOFError\b/,"rb_eEOFError") +gsub!(/\beIOError\b/,"rb_eIOError") +gsub!(/\beof_error\b/,"rb_eof_error") +gsub!(/\bf_gets\b/,"rb_f_gets") +gsub!(/\bio_binmode\b/,"rb_io_binmode") +gsub!(/\bio_check_closed\b/,"rb_io_check_closed") +gsub!(/\bio_check_readable\b/,"rb_io_check_readable") +gsub!(/\bio_check_writable\b/,"rb_io_check_writable") +gsub!(/\bio_close\b/,"rb_io_close") +gsub!(/\bio_fptr_finalize\b/,"rb_io_fptr_finalize") +gsub!(/\bio_getc\b/,"rb_io_getc") +gsub!(/\bio_gets\b/,"rb_io_gets") +gsub!(/\bio_gets_method\b/,"rb_io_gets_method") +gsub!(/\bio_mode_flags\b/,"rb_io_mode_flags") +gsub!(/\bio_reopen\b/,"rb_io_reopen") +gsub!(/\bio_unbuffered\b/,"rb_io_unbuffered") +gsub!(/\bio_ungetc\b/,"rb_io_ungetc") +gsub!(/\bio_write\b/,"rb_io_write") +gsub!(/\bRS_default\b/,"ruby_default_rs") +gsub!(/\bOFS\b/,"ruby_output_fs") +gsub!(/\bORS\b/,"ruby_output_rs") +gsub!(/\bFS\b/,"ruby_fs") +gsub!(/\bRS\b/,"ruby_rs") +gsub!(/\bmMath\b/,"rb_mMath") +gsub!(/\bcFixnum\b/,"rb_cFixnum") +gsub!(/\bcFloat\b/,"rb_cFloat") +gsub!(/\bcInteger\b/,"rb_cInteger") +gsub!(/\bcNumeric\b/,"rb_cNumeric") +gsub!(/\beZeroDiv\b/,"rb_eZeroDiv") +gsub!(/\bfix2int\b/,"rb_fix2int") +gsub!(/\bfix2str\b/,"rb_fix2str") +gsub!(/\bfix_upto\b/,"rb_fix_upto") +gsub!(/\bfloat_new\b/,"rb_float_new") +gsub!(/\bnum2fix\b/,"rb_num2fix") +gsub!(/\bnum2int\b/,"rb_num2int") +gsub!(/\bnum2long\b/,"rb_num2long") +gsub!(/\bnum2ulong\b/,"rb_num2ulong") +gsub!(/\bnum_coerce_bin\b/,"rb_num_coerce_bin") +gsub!(/\bnum_zerodiv\b/,"rb_num_zerodiv") +gsub!(/\bany_to_s\b/,"rb_any_to_s") +gsub!(/\bcClass\b/,"rb_cClass") +gsub!(/\bcData\b/,"rb_cData") +gsub!(/\bcFalseClass\b/,"rb_cFalseClass") +gsub!(/\bcModule\b/,"rb_cModule") +gsub!(/\bcNilClass\b/,"rb_cNilClass") +gsub!(/\bcObject\b/,"rb_cObject") +gsub!(/\bcTrueClass\b/,"rb_cTrueClass") +gsub!(/\bmKernel\b/,"rb_mKernel") +gsub!(/\bnum2dbl\b/,"rb_num2dbl") +gsub!(/\bobj_alloc\b/,"rb_obj_alloc") +gsub!(/\bobj_equal\b/,"rb_obj_equal") +gsub!(/\bobj_is_instance_of\b/,"rb_obj_is_instance_of") +gsub!(/\bobj_is_kind_of\b/,"rb_obj_is_kind_of") +gsub!(/\bstr2cstr\b/,"rb_str2cstr") +gsub!(/\bTopSelf\b/,"rb_top_self") +gsub!(/\bbackref_get\b/,"rb_backref_get") +gsub!(/\bbackref_set\b/,"rb_backref_set") +gsub!(/\bcompile_file\b/,"rb_compile_file") +gsub!(/\bcompile_string\b/,"rb_compile_string") +gsub!(/\bid_attrset\b/,"rb_id_attrset") +gsub!(/\bis_const_id\b/,"rb_is_const_id") +gsub!(/\bis_instance_id\b/,"rb_is_instance_id") +gsub!(/\blastline_get\b/,"rb_lastline_get") +gsub!(/\blastline_set\b/,"rb_lastline_set") +gsub!(/\bnode_newnode\b/,"rb_node_newnode") +gsub!(/\byyappend_print\b/,"rb_parser_append_print") +gsub!(/\byywhile_loop\b/,"rb_parser_while_loop") +gsub!(/\brb_reserved_word\b/,"rb_reserved_word") +gsub!(/\bsourcefile\b/,"ruby_sourcefile") +gsub!(/\bsourceline\b/,"ruby_sourceline") +gsub!(/\bmProcess\b/,"rb_mProcess") +gsub!(/\bcRange\b/,"rb_cRange") +gsub!(/\brange_beg_end\b/,"rb_range_beg_end") +gsub!(/\brange_new\b/,"rb_range_new") +gsub!(/\bcRegexp\b/,"rb_cRegexp") +gsub!(/\bignorecase\b/,"rb_ignorecase") +gsub!(/\breg_free\b/,"rb_reg_free") +gsub!(/\breg_last_match\b/,"rb_reg_last_match") +gsub!(/\breg_match\b/,"rb_reg_match") +gsub!(/\breg_new\b/,"rb_reg_new") +gsub!(/\breg_nth_defined\b/,"rb_reg_nth_defined") +gsub!(/\breg_nth_match\b/,"rb_reg_nth_match") +gsub!(/\breg_options\b/,"rb_reg_options") +gsub!(/\breg_prepare_re\b/,"rb_reg_prepare_re") +gsub!(/\breg_regcomp\b/,"rb_reg_regcomp") +gsub!(/\breg_regsub\b/,"rb_reg_regsub") +gsub!(/\breg_search\b/,"rb_reg_search") +gsub!(/\bstr_cicmp\b/,"rb_str_cicmp") +gsub!(/\bf_kill\b/,"rb_f_kill") +gsub!(/\bgc_mark_trap_list\b/,"rb_gc_mark_trap_list") +gsub!(/\bprohibit_interrupt\b/,"rb_prohibit_interrupt") +gsub!(/\btrap_exec\b/,"rb_trap_exec") +gsub!(/\btrap_exit\b/,"rb_trap_exit") +gsub!(/\btrap_immediate\b/,"rb_trap_immediate") +gsub!(/\btrap_pending\b/,"rb_trap_pending") +gsub!(/\btrap_restore_mask\b/,"rb_trap_restore_mask") +gsub!(/\bposix_signal\b/,"ruby_posix_signal") +gsub!(/\bf_sprintf\b/,"rb_f_sprintf") +gsub!(/\bcString\b/,"rb_cString") +gsub!(/\bobj_as_string\b/,"rb_obj_as_string") +gsub!(/\bstr_cat\b/,"rb_str_cat") +gsub!(/\bstr_cmp\b/,"rb_str_cmp") +gsub!(/\bstr_concat\b/,"rb_str_concat") +gsub!(/\bstr_dup\b/,"rb_str_dup") +gsub!(/\bstr_dup_frozen\b/,"rb_str_dup_frozen") +gsub!(/\bstr_freeze\b/,"rb_str_freeze") +gsub!(/\bstr_hash\b/,"rb_str_hash") +gsub!(/\bstr_inspect\b/,"rb_str_inspect") +gsub!(/\bstr_modify\b/,"rb_str_modify") +gsub!(/\bstr_new([234]?)\b/,"rb_str_new\\1") +gsub!(/\bstr_plus\b/,"rb_str_plus") +gsub!(/\bstr_resize\b/,"rb_str_resize") +gsub!(/\bstr_split\b/,"rb_str_split") +gsub!(/\bstr_substr\b/,"rb_str_substr") +gsub!(/\bstr_taint\b/,"rb_str_taint") +gsub!(/\bstr_tainted\b/,"rb_str_tainted") +gsub!(/\bstr_times\b/,"rb_str_times") +gsub!(/\bstr_to_str\b/,"rb_str_to_str") +gsub!(/\bstr_upto\b/,"rb_str_upto") +gsub!(/\bcStruct\b/,"rb_cStruct") +gsub!(/\bstruct_alloc\b/,"rb_struct_alloc") +gsub!(/\bstruct_aref\b/,"rb_struct_aref") +gsub!(/\bstruct_aset\b/,"rb_struct_aset") +gsub!(/\bstruct_define\b/,"rb_struct_define") +gsub!(/\bstruct_getmember\b/,"rb_struct_getmember") +gsub!(/\bstruct_new\b/,"rb_struct_new") +gsub!(/\bcTime\b/,"rb_cTime") +gsub!(/\btime_new\b/,"rb_time_new") +gsub!(/\btime_timeval\b/,"rb_time_timeval") +gsub!(/\bscan_hex\b/,"ruby_scan_hex") +gsub!(/\bscan_oct\b/,"ruby_scan_oct") +gsub!(/\bconst_defined\b/,"rb_const_defined") +gsub!(/\bconst_defined_at\b/,"rb_const_defined_at") +gsub!(/\bconst_get\b/,"rb_const_get") +gsub!(/\bconst_get_at\b/,"rb_const_get_at") +gsub!(/\bconst_set\b/,"rb_const_set") +gsub!(/\bf_autoload\b/,"rb_f_autoload") +gsub!(/\bf_global_variables\b/,"rb_f_global_variables") +gsub!(/\bf_trace_var\b/,"rb_f_trace_var") +gsub!(/\bf_untrace_var\b/,"rb_f_untrace_var") +gsub!(/\bmod_const_at\b/,"rb_mod_const_at") +gsub!(/\bmod_const_of\b/,"rb_mod_const_of") +gsub!(/\bmod_constants\b/,"rb_mod_constants") +gsub!(/\bmod_name\b/,"rb_mod_name") +gsub!(/\bmod_remove_const\b/,"rb_mod_remove_const") +gsub!(/\bobj_instance_variables\b/,"rb_obj_instance_variables") +gsub!(/\bobj_remove_instance_variable\b/,"rb_obj_remove_instance_variable") +gsub!(/\bshow_copyright\b/,"ruby_show_copyright") +gsub!(/\bshow_version\b/,"ruby_show_version") +gsub!(/\bdebug\b/,"rb_debug") +gsub!(/\bverbose\b/,"rb_verbose") +gsub!(/\bFail\(/,"rb_raise(rb_eRuntimeError, ") +gsub!(/\bArgError\(/,"rb_raise(rb_eArgError, ") +gsub!(/\bTypeError\(/,"rb_raise(rb_eTypeError, ") +gsub!(/\bNameError\(/,"rb_raise(rb_eNameError, ") +gsub!(/\bIndexError\(/,"rb_raise(rb_eIndexError, ") +gsub!(/\bError\b/,"rb_compile_error") +gsub!(/\bErrorAppend\b/,"rb_compile_error_append") +gsub!(/\bTRUE\b/,"Qtrue") +gsub!(/\bFALSE\b/,"Qfalse") +gsub!(/\berrinfo\b/,"rb_errinfo") diff --git a/win32/win32.c b/win32/win32.c new file mode 100644 index 0000000000..46489c4e08 --- /dev/null +++ b/win32/win32.c @@ -0,0 +1,2206 @@ +/* + * Copyright (c) 1993, Intergraph Corporation + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the perl README file. + * + * Various Unix compatibility functions and NT specific functions. + * + * Some of this code was derived from the MSDOS port(s) and the OS/2 port. + * + */ + +#include "ruby.h" +#include +#include +#include +/* #include */ +#include +#include +#include +#include + +#include +#include +#include +#include "nt.h" +#include "dir.h" +#ifndef index +#define index(x, y) strchr((x), (y)) +#endif + +#ifndef bool +#define bool int +#endif + +bool NtSyncProcess = TRUE; +#if 0 // declared in header file +extern char **environ; +#define environ _environ +#endif + +static bool NtHasRedirection (char *); +static int valid_filename(char *s); +static void StartSockets (); +static char *str_grow(struct RString *str, size_t new_size); + +char *NTLoginName; + +DWORD Win32System = (DWORD)-1; + +static DWORD +IdOS(void) +{ + static OSVERSIONINFO osver; + + if (osver.dwPlatformId != Win32System) { + memset(&osver, 0, sizeof(OSVERSIONINFO)); + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osver); + Win32System = osver.dwPlatformId; + } + return (Win32System); +} + +static int +IsWin95(void) { + return (IdOS() == VER_PLATFORM_WIN32_WINDOWS); +} + +static int +IsWinNT(void) { + return (IdOS() == VER_PLATFORM_WIN32_NT); +} + + +/* simulate flock by locking a range on the file */ + + +#define LK_ERR(f,i) ((f) ? (i = 0) : (errno = GetLastError())) +#define LK_LEN 0xffff0000 + +int +flock(int fd, int oper) +{ + OVERLAPPED o; + int i = -1; + HANDLE fh; + + fh = (HANDLE)_get_osfhandle(fd); + memset(&o, 0, sizeof(o)); + + if(IsWinNT()) { + switch(oper) { + case LOCK_SH: /* shared lock */ + LK_ERR(LockFileEx(fh, 0, 0, LK_LEN, 0, &o),i); + break; + case LOCK_EX: /* exclusive lock */ + LK_ERR(LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0, LK_LEN, 0, &o),i); + break; + case LOCK_SH|LOCK_NB: /* non-blocking shared lock */ + LK_ERR(LockFileEx(fh, LOCKFILE_FAIL_IMMEDIATELY, 0, LK_LEN, 0, &o),i); + break; + case LOCK_EX|LOCK_NB: /* non-blocking exclusive lock */ + LK_ERR(LockFileEx(fh, + LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, + 0, LK_LEN, 0, &o),i); + if(errno == EDOM) errno = EWOULDBLOCK; + break; + case LOCK_UN: /* unlock lock */ + if (UnlockFileEx(fh, 0, LK_LEN, 0, &o)) { + i = 0; + } + else { + /* GetLastError() must returns `ERROR_NOT_LOCKED' */ + errno = EWOULDBLOCK; + } + if(errno == EDOM) errno = EWOULDBLOCK; + break; + default: /* unknown */ + errno = EINVAL; + break; + } + } + else if(IsWin95()) { + switch(oper) { + case LOCK_EX: + while(i == -1) { + LK_ERR(LockFile(fh, 0, 0, LK_LEN, 0), i); + if(errno != EDOM && i == -1) break; + } + break; + case LOCK_EX | LOCK_NB: + LK_ERR(LockFile(fh, 0, 0, LK_LEN, 0), i); + if(errno == EDOM) errno = EWOULDBLOCK; + break; + case LOCK_UN: + LK_ERR(UnlockFile(fh, 0, 0, LK_LEN, 0), i); + if(errno == EDOM) errno = EWOULDBLOCK; + break; + default: + errno = EINVAL; + break; + } + } + return i; +} + +#undef LK_ERR +#undef LK_LEN + + +//#undef const +//FILE *fdopen(int, const char *); + +#if 0 +void +sleep(unsigned int len) +{ + time_t end; + + end = time((time_t *)0) + len; + while (time((time_t *)0) < end) + ; +} +#endif + +// +// Initialization stuff +// +void +NtInitialize(int *argc, char ***argv) { + + WORD version; + int ret; + + // + // subvert cmd.exe\'s feeble attempt at command line parsing + // + *argc = NtMakeCmdVector((char *)GetCommandLine(), argv, TRUE); + + // + // Now set up the correct time stuff + // + + tzset(); + + // Initialize Winsock + StartSockets(); +} + + +char *getlogin() +{ + char buffer[200]; + int len = 200; + extern char *NTLoginName; + + if (NTLoginName == NULL) { + if (GetUserName(buffer, &len)) { + NTLoginName = ALLOC_N(char, len+1); + strncpy(NTLoginName, buffer, len); + NTLoginName[len] = '\0'; + } + else { + NTLoginName = ""; + } + } + return NTLoginName; +} + + + +#if 1 +// popen stuff + +// +// use these so I can remember which index is which +// + +#define NtPipeRead 0 // index of pipe read descriptor +#define NtPipeWrite 1 // index of pipe write descriptor + +#define NtPipeSize 1024 // size of pipe buffer + +#define MYPOPENSIZE 256 // size of book keeping structure + +struct { + int inuse; + int pid; + HANDLE oshandle; + FILE *pipe; +} MyPopenRecord[MYPOPENSIZE]; + +int SafeFree(char **vec, int vecc) +{ + // vec + // | + // V ^---------------------V + // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + // | | | .... | NULL | | ..... |\0 | | ..... |\0 |... + // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + // |- elements+1 -| ^ 1st element ^ 2nd element + + char *p; + + p = (char *)vec; + free(p); + + return 0; +} + + +static char *szInternalCmds[] = { + "append", + "break", + "call", + "cd", + "chdir", + "cls", + "copy", + "date", + "del", + "dir", + "echo", + "erase", + "label", + "md", + "mkdir", + "path", + "pause", + "rd", + "rem", + "ren", + "rename", + "rmdir", + "set", + "start", + "time", + "type", + "ver", + "vol", + NULL +}; + +int +isInternalCmd(char *cmd) +{ + int i, fRet=0; + char **vec; + int vecc = NtMakeCmdVector(cmd, &vec, FALSE); + + for( i = 0; szInternalCmds[i] ; i++){ + if(!strcmp(szInternalCmds[i], vec[0])){ + fRet = 1; + break; + } + } + + SafeFree (vec, vecc); + + return fRet; +} + + +FILE * +mypopen (char *cmd, char *mode) +{ + FILE *fp; + int saved, reading; + int pipemode; + int pipes[2]; + int pid; + int slot; + static initialized = 0; + + // + // if first time through, intialize our book keeping structure + // + + if (!initialized++) { + for (slot = 0; slot < MYPOPENSIZE; slot++) + MyPopenRecord[slot].inuse = FALSE; + } + + //printf("mypopen %s\n", cmd); + + // + // find a free popen slot + // + + for (slot = 0; slot < MYPOPENSIZE && MyPopenRecord[slot].inuse; slot++) + ; + + if (slot > MYPOPENSIZE) { + return NULL; + } + + // + // Figure out what we\'re doing... + // + + reading = (*mode == 'r') ? TRUE : FALSE; + pipemode = (*(mode+1) == 'b') ? O_BINARY : O_TEXT; + + // + // Now get a pipe + // + +#if 0 + if (_pipe(pipes, NtPipeSize, pipemode) == -1) { + return NULL; + } + + if (reading) { + + // + // we\'re reading from the pipe, so we must hook up the + // write end of the pipe to the new processes stdout. + // To do this we must save our file handle from stdout + // by _dup\'ing it, then setting our stdout to be the pipe\'s + // write descriptor. We must also make the write handle + // inheritable so the new process can use it. + + if ((saved = _dup(fileno(stdout))) == -1) { + _close(pipes[NtPipeRead]); + _close(pipes[NtPipeWrite]); + return NULL; + } + if (_dup2 (pipes[NtPipeWrite], fileno(stdout)) == -1) { + _close(pipes[NtPipeRead]); + _close(pipes[NtPipeWrite]); + return NULL; + } + } + else { + // + // must be writing to the new process. Do the opposite of + // the above, i.e. hook up the processes stdin to the read + // end of the pipe. + // + + if ((saved = _dup(fileno(stdin))) == -1) { + _close(pipes[NtPipeRead]); + _close(pipes[NtPipeWrite]); + return NULL; + } + if (_dup2(pipes[NtPipeRead], fileno(stdin)) == -1) { + _close(pipes[NtPipeRead]); + _close(pipes[NtPipeWrite]); + return NULL; + } + } + + // + // Start the new process. Must set _fileinfo to non-zero value + // for file descriptors to be inherited. Reset after the process + // is started. + // + + if (NtHasRedirection(cmd)) { + docmd: + pid = spawnlpe(_P_NOWAIT, "cmd.exe", "/c", cmd, 0, environ); + if (pid == -1) { + _close(pipes[NtPipeRead]); + _close(pipes[NtPipeWrite]); + return NULL; + } + } + else { + char **vec; + int vecc = NtMakeCmdVector(cmd, &vec, FALSE); + + //pid = spawnvpe (_P_NOWAIT, vec[0], vec, environ); + pid = spawnvpe (_P_WAIT, vec[0], vec, environ); + if (pid == -1) { + goto docmd; + } + Safefree (vec, vecc); + } + + if (reading) { + + // + // We need to close our instance of the inherited pipe write + // handle now that it's been inherited so that it will actually close + // when the child process ends. + // + + if (_close(pipes[NtPipeWrite]) == -1) { + _close(pipes[NtPipeRead]); + return NULL; + } + if (_dup2 (saved, fileno(stdout)) == -1) { + _close(pipes[NtPipeRead]); + return NULL; + } + _close(saved); + + // + // Now get a stream pointer to return to the calling program. + // + + if ((fp = (FILE *) fdopen(pipes[NtPipeRead], mode)) == NULL) { + return NULL; + } + } + else { + + // + // need to close our read end of the pipe so that it will go + // away when the write end is closed. + // + + if (_close(pipes[NtPipeRead]) == -1) { + _close(pipes[NtPipeWrite]); + return NULL; + } + if (_dup2 (saved, fileno(stdin)) == -1) { + _close(pipes[NtPipeWrite]); + return NULL; + } + _close(saved); + + // + // Now get a stream pointer to return to the calling program. + // + + if ((fp = (FILE *) fdopen(pipes[NtPipeWrite], mode)) == NULL) { + _close(pipes[NtPipeWrite]); + return NULL; + } + } + + // + // do the book keeping + // + + MyPopenRecord[slot].inuse = TRUE; + MyPopenRecord[slot].pipe = fp; + MyPopenRecord[slot].pid = pid; + + return fp; +#else + { + int p[2]; + + BOOL fRet; + HANDLE hInFile, hOutFile, hStdin, hStdout; + LPCSTR lpApplicationName = NULL; + LPTSTR lpCommandLine; + LPTSTR lpCmd2 = NULL; + DWORD dwCreationFlags; + STARTUPINFO aStartupInfo; + PROCESS_INFORMATION aProcessInformation; + SECURITY_ATTRIBUTES sa; + int fd; + + sa.nLength = sizeof (SECURITY_ATTRIBUTES); + sa.lpSecurityDescriptor = NULL; + sa.bInheritHandle = TRUE; + + if (!reading) { + FILE *fp; + + fp = (_popen)(cmd, mode); + + MyPopenRecord[slot].inuse = TRUE; + MyPopenRecord[slot].pipe = fp; + MyPopenRecord[slot].pid = -1; + + if (!fp) + rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno)); + return fp; + } + + fRet = CreatePipe(&hInFile, &hOutFile, &sa, 2048L); + if (!fRet) + rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno)); + + memset(&aStartupInfo, 0, sizeof (STARTUPINFO)); + memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION)); + aStartupInfo.cb = sizeof (STARTUPINFO); + aStartupInfo.dwFlags = STARTF_USESTDHANDLES; + + if (reading) { + aStartupInfo.hStdInput = GetStdHandle(STD_OUTPUT_HANDLE);//hStdin; + aStartupInfo.hStdError = INVALID_HANDLE_VALUE; + //for save + DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE), + GetCurrentProcess(), &hStdout, + 0, FALSE, DUPLICATE_SAME_ACCESS + ); + //for redirect + DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), + GetCurrentProcess(), &hStdin, + 0, TRUE, DUPLICATE_SAME_ACCESS + ); + aStartupInfo.hStdOutput = hOutFile; + } + else { + aStartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); //hStdout; + aStartupInfo.hStdError = INVALID_HANDLE_VALUE; + // for save + DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE), + GetCurrentProcess(), &hStdin, + 0, FALSE, DUPLICATE_SAME_ACCESS + ); + //for redirect + DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE), + GetCurrentProcess(), &hStdout, + 0, TRUE, DUPLICATE_SAME_ACCESS + ); + aStartupInfo.hStdInput = hInFile; + } + + dwCreationFlags = (NORMAL_PRIORITY_CLASS); + + lpCommandLine = cmd; + if (NtHasRedirection(cmd) || isInternalCmd(cmd)) { + lpApplicationName = getenv("COMSPEC"); + lpCmd2 = malloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c ")); + if (lpCmd2 == NULL) + rb_fatal("Mypopen: malloc failed"); + sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd); + lpCommandLine = lpCmd2; + } + + fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa, + sa.bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation); + + if (!fRet) { + CloseHandle(hInFile); + CloseHandle(hOutFile); + rb_fatal("cannot fork for \"%s\" (%s)", cmd, strerror(errno)); + } + + CloseHandle(aProcessInformation.hThread); + + if (reading) { + HANDLE hDummy; + + fd = _open_osfhandle((long)hInFile, (_O_RDONLY | pipemode)); + CloseHandle(hOutFile); + DuplicateHandle(GetCurrentProcess(), hStdout, + GetCurrentProcess(), &hDummy, + 0, TRUE, (DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE) + ); + } + else { + HANDLE hDummy; + + fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode)); + CloseHandle(hInFile); + DuplicateHandle(GetCurrentProcess(), hStdin, + GetCurrentProcess(), &hDummy, + 0, TRUE, (DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE) + ); + } + + if (fd == -1) + rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno)); + + + if ((fp = (FILE *) fdopen(fd, mode)) == NULL) + return NULL; + + if (lpCmd2) + free(lpCmd2); + + MyPopenRecord[slot].inuse = TRUE; + MyPopenRecord[slot].pipe = fp; + MyPopenRecord[slot].oshandle = (reading ? hInFile : hOutFile); + MyPopenRecord[slot].pid = (int)aProcessInformation.hProcess; + return fp; + } +#endif +} + +int +mypclose(FILE *fp) +{ + int i; + int exitcode; + + Sleep(100); + for (i = 0; i < MYPOPENSIZE; i++) { + if (MyPopenRecord[i].inuse && MyPopenRecord[i].pipe == fp) + break; + } + if (i >= MYPOPENSIZE) { + rb_fatal("Invalid file pointer passed to mypclose!\n"); + } + + // + // get the return status of the process + // + +#if 0 + if (_cwait(&exitcode, MyPopenRecord[i].pid, WAIT_CHILD) == -1) { + if (errno == ECHILD) { + fprintf(stderr, "mypclose: nosuch child as pid %x\n", + MyPopenRecord[i].pid); + } + } +#else + for (;;) { + if (GetExitCodeProcess((HANDLE)MyPopenRecord[i].pid, &exitcode)) { + if (exitcode == STILL_ACTIVE) { + //printf("Process is Active.\n"); + Sleep(100); + TerminateProcess((HANDLE)MyPopenRecord[i].pid, 0); // ugly... + continue; + } + else if (exitcode == 0) { + //printf("done.\n"); + break; + } + else { + //printf("never.\n"); + break; + } + } + } +#endif + + + // + // close the pipe + // + CloseHandle(MyPopenRecord[i].oshandle); + fflush(fp); + fclose(fp); + + // + // free this slot + // + + MyPopenRecord[i].inuse = FALSE; + MyPopenRecord[i].pipe = NULL; + MyPopenRecord[i].pid = 0; + + return exitcode; +} +#endif + +#if 1 + + +typedef char* CHARP; +/* + * The following code is based on the do_exec and do_aexec functions + * in file doio.c + */ + +int +do_spawn(cmd) +char *cmd; +{ + register char **a; + register char *s; + char **argv; + int status; + char *shell, *cmd2; + int mode = NtSyncProcess ? P_WAIT : P_NOWAIT; + + /* save an extra exec if possible */ + if ((shell = getenv("RUBYSHELL")) != 0) { + if (NtHasRedirection(cmd)) { + int i; + char *p; + char *argv[4]; + char *cmdline = ALLOC_N(char, (strlen(cmd) * 2 + 1)); + + p=cmdline; + *p++ = '"'; + for (s=cmd; *s;) { + if (*s == '"') + *p++ = '\\'; /* Escape d-quote */ + *p++ = *s++; + } + *p++ = '"'; + *p = '\0'; + + /* fprintf(stderr, "do_spawn: %s %s\n", shell, cmdline); */ + argv[0] = shell; + argv[1] = "-c"; + argv[2] = cmdline; + argv[4] = NULL; + status = spawnvpe(mode, argv[0], argv, environ); + /* return spawnle(mode, shell, shell, "-c", cmd, (char*)0, environ); */ + free(cmdline); + return status; + } + } + else if ((shell = getenv("COMSPEC")) != 0) { + if (NtHasRedirection(cmd) /* || isInternalCmd(cmd) */) { + do_comspec_shell: + return spawnle(mode, shell, shell, "/c", cmd, (char*)0, environ); + } + } + + argv = ALLOC_N(CHARP, (strlen(cmd) / 2 + 2)); + cmd2 = ALLOC_N(char, (strlen(cmd) + 1)); + strcpy(cmd2, cmd); + a = argv; + for (s = cmd2; *s;) { + while (*s && isspace(*s)) s++; + if (*s) + *(a++) = s; + while (*s && !isspace(*s)) s++; + if (*s) + *s++ = '\0'; + } + *a = NULL; + if (argv[0]) { + if ((status = spawnvpe(mode, argv[0], argv, environ)) == -1) { + free(argv); + free(cmd2); + return -1; + } + } + free(cmd2); + free(argv); + return status; +} + +#endif + +typedef struct _NtCmdLineElement { + struct _NtCmdLineElement *next, *prev; + char *str; + int len; + int flags; +} NtCmdLineElement; + +// +// Possible values for flags +// + +#define NTGLOB 0x1 // element contains a wildcard +#define NTMALLOC 0x2 // string in element was malloc'ed +#define NTSTRING 0x4 // element contains a quoted string + +NtCmdLineElement *NtCmdHead = NULL, *NtCmdTail = NULL; + +void +NtFreeCmdLine(void) +{ + NtCmdLineElement *ptr; + + while(NtCmdHead) { + ptr = NtCmdHead; + NtCmdHead = NtCmdHead->next; + free(ptr); + } + NtCmdHead = NtCmdTail = NULL; +} + +// +// This function expands wild card characters that were spotted +// during the parse phase. The idea here is to call FindFirstFile and +// FindNextFile with the wildcard pattern specified, and splice in the +// resulting list of new names. If the wildcard pattern doesn\'t match +// any existing files, just leave it in the list. +// + +void +NtCmdGlob (NtCmdLineElement *patt) +{ + WIN32_FIND_DATA fd; + HANDLE fh; + char buffer[512]; + NtCmdLineElement *tmphead, *tmptail, *tmpcurr; + + strncpy(buffer, patt->str, patt->len); + buffer[patt->len] = '\0'; + if ((fh = FindFirstFile (buffer, &fd)) == INVALID_HANDLE_VALUE) { + return; + } + tmphead = tmptail = NULL; + do { + tmpcurr = ALLOC(NtCmdLineElement); + if (tmpcurr == NULL) { + fprintf(stderr, "Out of Memory in globbing!\n"); + while (tmphead) { + tmpcurr = tmphead; + tmphead = tmphead->next; + free(tmpcurr->str); + free(tmpcurr); + } + return; + } + memset (tmpcurr, 0, sizeof(*tmpcurr)); + tmpcurr->len = strlen(fd.cFileName); + tmpcurr->str = ALLOC_N(char, tmpcurr->len+1); + if (tmpcurr->str == NULL) { + fprintf(stderr, "Out of Memory in globbing!\n"); + while (tmphead) { + tmpcurr = tmphead; + tmphead = tmphead->next; + free(tmpcurr->str); + free(tmpcurr); + } + return; + } + strcpy(tmpcurr->str, fd.cFileName); + tmpcurr->flags |= NTMALLOC; + if (tmptail) { + tmptail->next = tmpcurr; + tmpcurr->prev = tmptail; + tmptail = tmpcurr; + } + else { + tmptail = tmphead = tmpcurr; + } + } while(FindNextFile(fh, &fd)); + + // + // ok, now we\'ve got a list of files that matched the wildcard + // specification. Put it in place of the pattern structure. + // + + tmphead->prev = patt->prev; + tmptail->next = patt->next; + + if (tmphead->prev) + tmphead->prev->next = tmphead; + + if (tmptail->next) + tmptail->next->prev = tmptail; + + // + // Now get rid of the pattern structure + // + + if (patt->flags & NTMALLOC) + free(patt->str); + // free(patt); //TODO: memory leak occures here. we have to fix it. +} + +// +// Check a command string to determine if it has I/O redirection +// characters that require it to be executed by a command interpreter +// + +static bool +NtHasRedirection (char *cmd) +{ + int inquote = 0; + char quote = '\0'; + char *ptr ; + + // + // Scan the string, looking for redirection (< or >) or pipe + // characters (|) that are not in a quoted string + // + + for (ptr = cmd; *ptr; ptr++) { + + switch (*ptr) { + + case '\'': + case '\"': + if (inquote) { + if (quote == *ptr) { + inquote = 0; + quote = '\0'; + } + } + else { + quote = *ptr; + inquote++; + } + break; + + case '>': + case '<': + + if (!inquote) + return TRUE; + } + } + return FALSE; +} + + +int +NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd) +{ + int cmdlen = strlen(cmdline); + int done, instring, globbing, quoted, len; + int newline, need_free = 0, i; + int elements, strsz; + int slashes = 0; + char *ptr, *base, *buffer; + char **vptr; + char quote; + NtCmdLineElement *curr; + + // + // just return if we don\'t have a command line + // + + if (cmdlen == 0) { + *vec = NULL; + return 0; + } + + // + // strip trailing white space + // + + ptr = cmdline+(cmdlen - 1); + while(ptr >= cmdline && isspace(*ptr)) + --ptr; + *++ptr = '\0'; + + // + // check for newlines and formfeeds. If we find any, make a new + // command string that replaces them with escaped sequences (\n or \f) + // + + for (ptr = cmdline, newline = 0; *ptr; ptr++) { + if (*ptr == '\n' || *ptr == '\f') + newline++; + } + + if (newline) { + base = ALLOC_N(char, strlen(cmdline) + 1 + newline + slashes); + if (base == NULL) { + fprintf(stderr, "malloc failed!\n"); + return 0; + } + for (i = 0, ptr = base; (unsigned) i < strlen(cmdline); i++) { + switch (cmdline[i]) { + case '\n': + *ptr++ = '\\'; + *ptr++ = 'n'; + break; + default: + *ptr++ = cmdline[i]; + } + } + *ptr = '\0'; + cmdline = base; + need_free++; + } + + // + // Ok, parse the command line, building a list of CmdLineElements. + // When we\'ve finished, and it\'s an input command (meaning that it\'s + // the processes argv), we\'ll do globing and then build the argument + // vector. + // The outer loop does one interation for each element seen. + // The inner loop does one interation for each character in the element. + // + + for (done = 0, ptr = cmdline; *ptr;) { + + // + // zap any leading whitespace + // + + while(isspace(*ptr)) + ptr++; + base = ptr; + + for (done = newline = globbing = instring = quoted = 0; + *ptr && !done; ptr++) { + + // + // Switch on the current character. We only care about the + // white-space characters, the wild-card characters, and the + // quote characters. + // + + switch (*ptr) { + case ' ': + case '\t': +#if 0 + case '/': // have to do this for NT/DOS option strings + + // + // check to see if we\'re parsing an option switch + // + + if (*ptr == '/' && base == ptr) + continue; +#endif + // + // if we\'re not in a string, then we\'re finished with this + // element + // + + if (!instring) + done++; + break; + + case '*': + case '?': + + // + // record the fact that this element has a wildcard character + // N.B. Don\'t glob if inside a single quoted string + // + + if (!(instring && quote == '\'')) + globbing++; + break; + + case '\n': + + // + // If this string contains a newline, mark it as such so + // we can replace it with the two character sequence "\n" + // (cmd.exe doesn\'t like raw newlines in strings...sigh). + // + + newline++; + break; + + case '\'': + case '\"': + + // + // if we\'re already in a string, see if this is the + // terminating close-quote. If it is, we\'re finished with + // the string, but not neccessarily with the element. + // If we\'re not already in a string, start one. + // + + if (instring) { + if (quote == *ptr) { + instring = 0; + quote = '\0'; + } + } + else { + instring++; + quote = *ptr; + quoted++; + } + break; + } + } + + // + // need to back up ptr by one due to last increment of for loop + // (if we got out by seeing white space) + // + + if (*ptr) + ptr--; + + // + // when we get here, we\'ve got a pair of pointers to the element, + // base and ptr. Base points to the start of the element while ptr + // points to the character following the element. + // + + curr = ALLOC(NtCmdLineElement); + if (curr == NULL) { + NtFreeCmdLine(); + fprintf(stderr, "Out of memory!!\n"); + *vec = NULL; + return 0; + } + memset (curr, 0, sizeof(*curr)); + + len = ptr - base; + + // + // if it\'s an input vector element and it\'s enclosed by quotes, + // we can remove them. + // + + if (InputCmd && + ((base[0] == '\"' && base[len-1] == '\"') || + (base[0] == '\'' && base[len-1] == '\''))) { + base++; + len -= 2; + } + + curr->str = base; + curr->len = len; + curr->flags |= (globbing ? NTGLOB : 0); + + // + // Now put it in the list of elements + // + if (NtCmdTail) { + NtCmdTail->next = curr; + curr->prev = NtCmdTail; + NtCmdTail = curr; + } + else { + NtCmdHead = NtCmdTail = curr; + } + } + + if (InputCmd) { + + // + // When we get here we\'ve finished parsing the command line. Now + // we need to run the list, expanding any globbing patterns. + // + + for(curr = NtCmdHead; curr; curr = curr->next) { + if (curr->flags & NTGLOB) { + NtCmdGlob(curr); + } + } + } + + // + // Almost done! + // Count up the elements, then allocate space for a vector of pointers + // (argv) and a string table for the elements. + // + + for (elements = 0, strsz = 0, curr = NtCmdHead; curr; curr = curr->next) { + elements++; + strsz += (curr->len + 1); + } + + len = (elements+1)*sizeof(char *) + strsz; + buffer = ALLOC_N(char, len); + if (buffer == NULL) { + fprintf(stderr, "Out of memory!!\n"); + NtFreeCmdLine(); + *vec = NULL; + return 0; + } + + memset (buffer, 0, len); + + // + // make vptr point to the start of the buffer + // and ptr point to the area we\'ll consider the string table. + // + // buffer (*vec) + // | + // V ^---------------------V + // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + // | | | .... | NULL | | ..... |\0 | | ..... |\0 |... + // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + // |- elements+1 -| ^ 1st element ^ 2nd element + + vptr = (char **) buffer; + + ptr = buffer + (elements+1) * sizeof(char *); + + for (curr = NtCmdHead; curr; curr = curr->next) { + strncpy (ptr, curr->str, curr->len); + ptr[curr->len] = '\0'; + *vptr++ = ptr; + ptr += curr->len + 1; + } + NtFreeCmdLine(); + *vec = (char **) buffer; + return elements; +} + + +#if 1 +// +// UNIX compatible directory access functions for NT +// + +// +// File names are converted to lowercase if the +// CONVERT_TO_LOWER_CASE variable is defined. +// + +#define CONVERT_TO_LOWER_CASE +#define PATHLEN 1024 + +// +// The idea here is to read all the directory names into a string table +// (separated by nulls) and when one of the other dir functions is called +// return the pointer to the current file name. +// + +DIR * +opendir(char *filename) +{ + DIR *p; + long len; + long idx; + char scannamespc[PATHLEN]; + char *scanname = scannamespc; + struct stat sbuf; + WIN32_FIND_DATA FindData; + HANDLE fh; + char root[PATHLEN]; + char volname[PATHLEN]; + DWORD serial, maxname, flags; + BOOL downcase; + char *dummy; + + // + // check to see if we\'ve got a directory + // + + if (stat (filename, &sbuf) < 0 || + sbuf.st_mode & _S_IFDIR == 0) { + return NULL; + } + + // + // check out the file system characteristics + // + if (GetFullPathName(filename, PATHLEN, root, &dummy)) { + if (dummy = strchr(root, '\\')) + *++dummy = '\0'; + if (GetVolumeInformation(root, volname, PATHLEN, + &serial, &maxname, &flags, 0, 0)) { + downcase = !(flags & FS_CASE_SENSITIVE); + } + } + else { + downcase = TRUE; + } + + // + // Get us a DIR structure + // + + p = xcalloc(sizeof(DIR), 1); + if (p == NULL) + return NULL; + + // + // Create the search pattern + // + + strcpy(scanname, filename); + + if (index("/\\", *(scanname + strlen(scanname) - 1)) == NULL) + strcat(scanname, "/*"); + else + strcat(scanname, "*"); + + // + // do the FindFirstFile call + // + + fh = FindFirstFile (scanname, &FindData); + if (fh == INVALID_HANDLE_VALUE) { + return NULL; + } + + // + // now allocate the first part of the string table for the + // filenames that we find. + // + + idx = strlen(FindData.cFileName)+1; + p->start = ALLOC_N(char, idx); + strcpy (p->start, FindData.cFileName); + if (downcase) + strlwr(p->start); + p->nfiles++; + + // + // loop finding all the files that match the wildcard + // (which should be all of them in this directory!). + // the variable idx should point one past the null terminator + // of the previous string found. + // + while (FindNextFile(fh, &FindData)) { + len = strlen (FindData.cFileName); + + // + // bump the string table size by enough for the + // new name and it's null terminator + // + + #define Renew(x, y, z) (x = (z *)realloc(x, y)) + + Renew (p->start, idx+len+1, char); + if (p->start == NULL) { + rb_fatal ("opendir: malloc failed!\n"); + } + strcpy(&p->start[idx], FindData.cFileName); + if (downcase) + strlwr(&p->start[idx]); + p->nfiles++; + idx += len+1; + } + FindClose(fh); + p->size = idx; + p->curr = p->start; + return p; +} + + +// +// Readdir just returns the current string pointer and bumps the +// string pointer to the next entry. +// + +struct direct * +readdir(DIR *dirp) +{ + int len; + static int dummy = 0; + + if (dirp->curr) { + + // + // first set up the structure to return + // + + len = strlen(dirp->curr); + strcpy(dirp->dirstr.d_name, dirp->curr); + dirp->dirstr.d_namlen = len; + + // + // Fake inode + // + dirp->dirstr.d_ino = dummy++; + + // + // Now set up for the next call to readdir + // + + dirp->curr += len + 1; + if (dirp->curr >= (dirp->start + dirp->size)) { + dirp->curr = NULL; + } + + return &(dirp->dirstr); + + } else + return NULL; +} + +// +// Telldir returns the current string pointer position +// + +long +telldir(DIR *dirp) +{ + return (long) dirp->curr; /* ouch! pointer to long cast */ +} + +// +// Seekdir moves the string pointer to a previously saved position +// (Saved by telldir). + +void +seekdir(DIR *dirp, long loc) +{ + dirp->curr = (char *) loc; /* ouch! long to pointer cast */ +} + +// +// Rewinddir resets the string pointer to the start +// + +void +rewinddir(DIR *dirp) +{ + dirp->curr = dirp->start; +} + +// +// This just free\'s the memory allocated by opendir +// + +void +closedir(DIR *dirp) +{ + free(dirp->start); + free(dirp); +} +#endif + + +// +// 98.2% of this code was lifted from the OS2 port. (JCW) +// + +#if 0 +// add_suffix is in util.c too. +/* + * Suffix appending for in-place editing under MS-DOS and OS/2 (and now NT!). + * + * Here are the rules: + * + * Style 0: Append the suffix exactly as standard perl would do it. + * If the filesystem groks it, use it. (HPFS will always + * grok it. So will NTFS. FAT will rarely accept it.) + * + * Style 1: The suffix begins with a '.'. The extension is replaced. + * If the name matches the original name, use the fallback method. + * + * Style 2: The suffix is a single character, not a '.'. Try to add the + * suffix to the following places, using the first one that works. + * [1] Append to extension. + * [2] Append to filename, + * [3] Replace end of extension, + * [4] Replace end of filename. + * If the name matches the original name, use the fallback method. + * + * Style 3: Any other case: Ignore the suffix completely and use the + * fallback method. + * + * Fallback method: Change the extension to ".$$$". If that matches the + * original name, then change the extension to ".~~~". + * + * If filename is more than 1000 characters long, we die a horrible + * death. Sorry. + * + * The filename restriction is a cheat so that we can use buf[] to store + * assorted temporary goo. + * + * Examples, assuming style 0 failed. + * + * suffix = ".bak" (style 1) + * foo.bar => foo.bak + * foo.bak => foo.$$$ (fallback) + * foo.$$$ => foo.~~~ (fallback) + * makefile => makefile.bak + * + * suffix = "~" (style 2) + * foo.c => foo.c~ + * foo.c~ => foo.c~~ + * foo.c~~ => foo~.c~~ + * foo~.c~~ => foo~~.c~~ + * foo~~~~~.c~~ => foo~~~~~.$$$ (fallback) + * + * foo.pas => foo~.pas + * makefile => makefile.~ + * longname.fil => longname.fi~ + * longname.fi~ => longnam~.fi~ + * longnam~.fi~ => longnam~.$$$ + * + */ + + +static char suffix1[] = ".$$$"; +static char suffix2[] = ".~~~"; + +#define ext (&buf[1000]) + +#define strEQ(s1,s2) (strcmp(s1,s2) == 0) + +void +add_suffix(struct RString *str, char *suffix) +{ + int baselen; + int extlen = strlen(suffix); + char *s, *t, *p; + int slen; + char buf[1024]; + + if (str->len > 1000) + rb_fatal("Cannot do inplace edit on long filename (%d characters)", str->len); + + /* Style 0 */ + slen = str->len; + str_cat(str, suffix, extlen); + if (valid_filename(str->ptr)) return; + + /* Fooey, style 0 failed. Fix str before continuing. */ + str->ptr[str->len = slen] = '\0'; + + slen = extlen; + t = buf; baselen = 0; s = str->ptr; + while ( (*t = *s) && *s != '.') { + baselen++; + if (*s == '\\' || *s == '/') baselen = 0; + s++; t++; + } + p = t; + + t = ext; extlen = 0; + while (*t++ = *s++) extlen++; + if (extlen == 0) { ext[0] = '.'; ext[1] = 0; extlen++; } + + if (*suffix == '.') { /* Style 1 */ + if (strEQ(ext, suffix)) goto fallback; + strcpy(p, suffix); + } else if (suffix[1] == '\0') { /* Style 2 */ + if (extlen < 4) { + ext[extlen] = *suffix; + ext[++extlen] = '\0'; + } else if (baselen < 8) { + *p++ = *suffix; + } else if (ext[3] != *suffix) { + ext[3] = *suffix; + } else if (buf[7] != *suffix) { + buf[7] = *suffix; + } else goto fallback; + strcpy(p, ext); + } else { /* Style 3: Panic */ +fallback: + (void)memcpy(p, strEQ(ext, suffix1) ? suffix2 : suffix1, 5); + } + str_grow(str, strlen(buf)); + memcpy(str->ptr, buf, str->len); +} +#endif + +static int +valid_filename(char *s) +{ + int fd; + + // + // if the file exists, then it\'s a valid filename! + // + + if (_access(s, 0) == 0) { + return 1; + } + + // + // It doesn\'t exist, so see if we can open it. + // + + if ((fd = _open(s, _O_CREAT, 0666)) >= 0) { + close(fd); + _unlink (s); // don\'t leave it laying around + return 1; + } + return 0; +} + + +// +// This is a clone of fdopen so that we can handle the +// brain damaged version of sockets that NT gets to use. +// +// The problem is that sockets are not real file handles and +// cannot be fdopen\'ed. This causes problems in the do_socket +// routine in doio.c, since it tries to create two file pointers +// for the socket just created. We\'ll fake out an fdopen and see +// if we can prevent perl from trying to do stdio on sockets. +// + +FILE * +myfdopen (int fd, const char *mode) +{ + FILE *fp; + char sockbuf[80]; + int optlen; + int retval; + extern int errno; + + //fprintf(stderr, "myfdopen()\n"); + + retval = getsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, sockbuf, &optlen); + if (retval == SOCKET_ERROR) { + int iRet; + + iRet = WSAGetLastError(); + if (iRet == WSAENOTSOCK || iRet == WSANOTINITIALISED) + return (_fdopen(fd, mode)); + } + + // + // If we get here, then fd is actually a socket. + // + fp = xcalloc(sizeof(FILE), 1); +#if _MSC_VER < 800 + fileno(fp) = fd; +#else + fp->_file = fd; +#endif + if (*mode == 'r') + fp->_flag = _IOREAD; + else + fp->_flag = _IOWRT; + return fp; +} + + +// +// Since the errors returned by the socket error function +// WSAGetLastError() are not known by the library routine strerror +// we have to roll our own. +// + +#undef strerror + +char * +mystrerror(int e) +{ + static char buffer[512]; + extern int sys_nerr; + DWORD source = 0; + + if (e < 0 || e > sys_nerr) { + if (e < 0) + e = GetLastError(); + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, &source, e, 0, + buffer, 512, NULL) == 0) { + strcpy (buffer, "Unknown Error"); + } + return buffer; + } + return strerror(e); + +} + +// +// various stubs +// + + +// Ownership +// +// Just pretend that everyone is a superuser. NT will let us know if +// we don\'t really have permission to do something. +// + +#define ROOT_UID 0 +#define ROOT_GID 0 + +UIDTYPE +getuid(void) +{ + return ROOT_UID; +} + +UIDTYPE +geteuid(void) +{ + return ROOT_UID; +} + +GIDTYPE +getgid(void) +{ + return ROOT_GID; +} + +GIDTYPE +getegid(void) +{ + return ROOT_GID; +} + +int +setuid(int uid) +{ + return (uid == ROOT_UID ? 0 : -1); +} + +int +setgid(int gid) +{ + return (gid == ROOT_GID ? 0 : -1); +} + +// +// File system stuff +// + +int +/* ioctl(int i, unsigned int u, char *data) */ +ioctl(int i, unsigned int u, long data) +{ + return -1; +} + + +// +// Networking trampolines +// These are used to avoid socket startup/shutdown overhead in case +// the socket routines aren\'t used. +// + +#undef select + +static int NtSocketsInitialized = 0; + +long +myselect (int nfds, fd_set *rd, fd_set *wr, fd_set *ex, + struct timeval *timeout) +{ + long r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = select (nfds, rd, wr, ex, timeout)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +static void +StartSockets () { + WORD version; + WSADATA retdata; + int ret; + + // + // initalize the winsock interface and insure that it\'s + // cleaned up at exit. + // + version = MAKEWORD(1, 1); + if (ret = WSAStartup(version, &retdata)) + rb_fatal ("Unable to locate winsock library!\n"); + if (LOBYTE(retdata.wVersion) != 1) + rb_fatal("could not find version 1 of winsock dll\n"); + + if (HIBYTE(retdata.wVersion) != 1) + rb_fatal("could not find version 1 of winsock dll\n"); + + atexit((void (*)(void)) WSACleanup); +} + +#undef accept + +SOCKET +myaccept (SOCKET s, struct sockaddr *addr, int *addrlen) +{ + SOCKET r; + + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = accept (s, addr, addrlen)) == INVALID_SOCKET) + errno = WSAGetLastError(); + return r; +} + +#undef bind + +int +mybind (SOCKET s, struct sockaddr *addr, int addrlen) +{ + int r; + + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = bind (s, addr, addrlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef connect + +int +myconnect (SOCKET s, struct sockaddr *addr, int addrlen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = connect (s, addr, addrlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + + +#undef getpeername + +int +mygetpeername (SOCKET s, struct sockaddr *addr, int *addrlen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getpeername (s, addr, addrlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef getsockname + +int +mygetsockname (SOCKET s, struct sockaddr *addr, int *addrlen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getsockname (s, addr, addrlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef getsockopt + +int +mygetsockopt (SOCKET s, int level, int optname, char *optval, int *optlen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getsockopt (s, level, optname, optval, optlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef ioctlsocket + +int +myioctlsocket (SOCKET s, long cmd, u_long *argp) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = ioctlsocket (s, cmd, argp)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef listen + +int +mylisten (SOCKET s, int backlog) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = listen (s, backlog)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef recv + +int +myrecv (SOCKET s, char *buf, int len, int flags) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = recv (s, buf, len, flags)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef recvfrom + +int +myrecvfrom (SOCKET s, char *buf, int len, int flags, + struct sockaddr *from, int *fromlen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = recvfrom (s, buf, len, flags, from, fromlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef send + +int +mysend (SOCKET s, char *buf, int len, int flags) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = send (s, buf, len, flags)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef sendto + +int +mysendto (SOCKET s, char *buf, int len, int flags, + struct sockaddr *to, int tolen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = sendto (s, buf, len, flags, to, tolen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef setsockopt + +int +mysetsockopt (SOCKET s, int level, int optname, char *optval, int optlen) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = setsockopt (s, level, optname, optval, optlen)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef shutdown + +int +myshutdown (SOCKET s, int how) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = shutdown (s, how)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef socket + +SOCKET +mysocket (int af, int type, int protocol) +{ + SOCKET s; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((s = socket (af, type, protocol)) == INVALID_SOCKET) { + errno = WSAGetLastError(); + //fprintf(stderr, "socket fail (%d)", WSAGetLastError()); + } + return s; +} + +#undef gethostbyaddr + +struct hostent * +mygethostbyaddr (char *addr, int len, int type) +{ + struct hostent *r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = gethostbyaddr (addr, len, type)) == NULL) + errno = WSAGetLastError(); + return r; +} + +#undef gethostbyname + +struct hostent * +mygethostbyname (char *name) +{ + struct hostent *r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = gethostbyname (name)) == NULL) + errno = WSAGetLastError(); + return r; +} + +#undef gethostname + +int +mygethostname (char *name, int len) +{ + int r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = gethostname (name, len)) == SOCKET_ERROR) + errno = WSAGetLastError(); + return r; +} + +#undef getprotobyname + +struct protoent * +mygetprotobyname (char *name) +{ + struct protoent *r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getprotobyname (name)) == NULL) + errno = WSAGetLastError(); + return r; +} + +#undef getprotobynumber + +struct protoent * +mygetprotobynumber (int num) +{ + struct protoent *r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getprotobynumber (num)) == NULL) + errno = WSAGetLastError(); + return r; +} + +#undef getservbyname + +struct servent * +mygetservbyname (char *name, char *proto) +{ + struct servent *r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getservbyname (name, proto)) == NULL) + errno = WSAGetLastError(); + return r; +} + +#undef getservbyport + +struct servent * +mygetservbyport (int port, char *proto) +{ + struct servent *r; + if (!NtSocketsInitialized++) { + StartSockets(); + } + if ((r = getservbyport (port, proto)) == NULL) + errno = WSAGetLastError(); + return r; +} + +// +// Networking stubs +// + +void endhostent() {} +void endnetent() {} +void endprotoent() {} +void endservent() {} + +struct netent *getnetent (void) {return (struct netent *) NULL;} + +struct netent *getnetbyaddr(char *name) {return (struct netent *)NULL;} + +struct netent *getnetbyname(long net, int type) {return (struct netent *)NULL;} + +struct protoent *getprotoent (void) {return (struct protoent *) NULL;} + +struct servent *getservent (void) {return (struct servent *) NULL;} + +void sethostent (int stayopen) {} + +void setnetent (int stayopen) {} + +void setprotoent (int stayopen) {} + +void setservent (int stayopen) {} + + +#ifndef WNOHANG +#define WNOHANG -1 +#endif + +pid_t +waitpid (pid_t pid, int *stat_loc, int options) +{ + DWORD timeout; + + if (options == WNOHANG) { + timeout = 0; + } else { + timeout = INFINITE; + } + if (WaitForSingleObject((HANDLE) pid, timeout) == WAIT_OBJECT_0) { + pid = _cwait(stat_loc, pid, 0); + return pid; + } + return 0; +} + +#include + +void _cdecl +gettimeofday(struct timeval *tv, struct timezone *tz) +{ + struct timeb tb; + + ftime(&tb); + tv->tv_sec = tb.time; + tv->tv_usec = tb.millitm * 1000; +} + +char * +getcwd(buffer, size) + char *buffer; + int size; +{ + int length; + char *bp; + + if (_getcwd(buffer, size) == NULL) { + return NULL; + } + length = strlen(buffer); + if (length >= size) { + return NULL; + } + + for (bp = buffer; *bp != '\0'; bp++) { + if (*bp == '\\') { + *bp = '/'; + } + } + return buffer; +} + +static char * +str_grow(struct RString *str, size_t new_size) +{ + char *p; + + p = realloc(str->ptr, new_size); + if (p == NULL) + rb_fatal("cannot grow string\n"); + + str->len = new_size; + str->ptr = p; + + return p; +} + +int +chown(char *path, int owner, int group) +{ + return 0; +} + +int +kill(int pid, int sig) +{ +#if 1 + if (pid == GetCurrentProcessId()) + return raise(sig); + + if (sig == 2 && pid > 0) + if (GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid)) + return 0; + + return -1; +#else + return 0; +#endif +} + +int +link(char *from, char *to) +{ + return -1; +} + +int +wait() +{ + return 0; +} + diff --git a/win32/win32.h b/win32/win32.h new file mode 100644 index 0000000000..a3d1f21aa5 --- /dev/null +++ b/win32/win32.h @@ -0,0 +1,358 @@ +#ifndef EXT_NT_H +#define EXT_NT_H + +/* + * Copyright (c) 1993, Intergraph Corporation + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the perl README file. + * + */ + +#if defined(IMPORT) +#define EXTERN extern __declspec(dllimport) +#elif defined(EXPORT) +#define EXTERN extern __declspec(dllexport) +#endif + +// +// Definitions for NT port of Perl +// + +// +// GRRRR!!!! Windows Nonsense. +// Define the following so we don't get tons of extra stuff +// when we include windows.h +// +#if 0 +#define NOGDICAPMASKS +#define NOVIRTUALKEYCODES +#define NOWINMESSAGES +#define NOWINSTYLES +#define NOSYSMETRICS +#define NOMENUS +#define NOICONS +#define NOKEYSTATES +#define NOSYSCOMMANDS +#define NORASTEROPS +#define NOSHOWWINDOW +#define OEMRESOURCE +#define NOATOM +#define NOCLIPBOARD +#define NOCOLOR +#define NOCTLMGR +#define NODRAWTEXT +#define NOGDI +//#define NOKERNEL +//#define NOUSER +#define NONLS +#define NOMB +#define NOMEMMGR +#define NOMETAFILE +#define NOMINMAX +#define NOMSG +#define NOOPENFILE +#define NOSCROLL +#define NOSERVICE +#define NOSOUND +#define NOTEXTMETRIC +#define NOWH +#define NOWINOFFSETS +#define NOCOMM +#define NOKANJI +#define NOHELP +#define NOPROFILER +#define NODEFERWINDOWPOS +#endif + +// +// Ok now we can include the normal include files. +// + +// #include conflict with varargs.h? +// There is function-name conflitct, so we rename it +#if !defined(IN) && !defined(FLOAT) +#define OpenFile WINAPI_OpenFile +#include +#include +#undef OpenFile +#endif +// +// We\'re not using Microsoft\'s "extensions" to C for +// Structured Exception Handling (SEH) so we can nuke these +// +#undef try +#undef except +#undef finally +#undef leave +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// +// Grrr... +// + +#define access _access +#define chmod _chmod +#define chsize _chsize +#define close _close +#define creat _creat +#define dup _dup +#define dup2 _dup2 +#define eof _eof +#define filelength _filelength +#define isatty _isatty +#define locking _locking +#define lseek _lseek +#define mktemp _mktemp +#define open _open +#define read _read +#define setmode _setmode +#define sopen _sopen +#define tell _tell +#define umask _umask +#define unlink _unlink +#define write _write +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execlpe _execlpe +#define execv _execv +#define execve _execve +#define execvp _execvp +#define execvpe _execvpe +#define getpid _getpid +#define spawnl _spawnl +#define spawnle _spawnle +#define spawnlp _spawnlp +#define spawnlpe _spawnlpe +#define spawnv _spawnv +#define spawnve _spawnve +#define spawnvp _spawnvp +#define spawnvpe _spawnvpe +#if _MSC_VER < 800 +#define fileno _fileno +#endif +#define utime _utime +//#define pipe _pipe +#define perror _perror + + +/* these are defined in nt.c */ + +extern int NtMakeCmdVector(char *, char ***, int); +/* extern void NtInitialize(int *, char ***); */ +extern char *NtGetLib(void); +extern char *NtGetBin(void); +extern FILE *mypopen(char *, char *); +extern int flock(int fd, int oper); +extern FILE * myfdopen(int, char*); +extern SOCKET myaccept(SOCKET, struct sockaddr *, int *); +extern int mybind(SOCKET, struct sockaddr *, int); +extern int myconnect(SOCKET, struct sockaddr *, int); +extern int mygetpeername(SOCKET, struct sockaddr *, int *); +extern int mygetsockname(SOCKET, struct sockaddr *, int *); +extern int mygetsockopt(SOCKET, int, int, char *, int *); +extern int myioctlsocket(SOCKET, long, u_long *); +extern int mylisten(SOCKET, int); +extern int myrecv(SOCKET, char *, int, int); +extern int myrecvfrom(SOCKET, char *, int, int, struct sockaddr *, int *); +extern int mysend(SOCKET, char *, int, int); +extern int mysendto(SOCKET, char *, int, int, struct sockaddr *, int); +extern int mysetsockopt(SOCKET, int, int, char *, int); +extern int myshutdown(SOCKET, int); +extern SOCKET mysocket(int, int, int); +extern struct hostent * mygethostbyaddr(char *, int, int); +extern struct hostent * mygethostbyname(char *); +extern int mygethostname(char *, int); +extern struct protoent * mygetprotobyname(char *); +extern struct protoent * mygetprotobynumber(int); +extern struct servent * mygetservbyname(char *, char *); +extern struct servent * mygetservbyport(int, char *); + +// +// define this so we can do inplace editing +// + +#define SUFFIX + +// +// stubs +// +// extern int ioctl (int, unsigned int, char *); +extern int ioctl (int, unsigned int, long); +#if 0 +extern void sleep (unsigned int); +#else +#define sleep(x) Sleep(x*1000) +#endif + +extern UIDTYPE getuid (void); +extern UIDTYPE geteuid (void); +extern GIDTYPE getgid (void); +extern GIDTYPE getegid (void); +extern int setuid (int); +extern int setgid (int); + + +#undef IN /* confict in parse.c */ + +#if 0 +extern int sys_nerr; +extern char *sys_errlist[]; +#endif +extern char *mystrerror(int); + +#define strerror(e) mystrerror(e) + +#define PIPE_BUF 1024 + +#define HAVE_STDLIB_H 1 +#define HAVE_GETLOGIN 1 +#define HAVE_WAITPID 1 +#define HAVE_GETCWD 1 + +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_NB 4 +#define LOCK_UN 8 +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 10035 /* EBASEERR + 35 (winsock.h) */ +#endif + +#define O_BINARY 0x8000 + +#ifdef popen +#undef popen +#define popen mypopen +#endif +#ifdef pclose +#undef pclose +#define pclose mypclose +#endif + +/* #undef va_start */ +/* #undef va_end */ + +#ifdef fdopen +#undef fdopen +#endif +#define fdopen myfdopen + +#ifdef accept +#undef accept +#endif +#define accept myaccept + +#ifdef bind +#undef bind +#endif +#define bind mybind + +#ifdef connect +#undef connect +#endif +#define connect myconnect + +#ifdef getpeername +#undef getpeername +#endif +#define getpeername mygetpeername + +#ifdef getsockname +#undef getsockname +#endif +#define getsockname mygetsockname + +#ifdef getsockopt +#undef getsockopt +#endif +#define getsockopt mygetsockopt + +#ifdef ioctlsocket +#undef ioctlsocket +#endif +#define ioctlsocket myioctlsocket + +#ifdef listen +#undef listen +#endif +#define listen mylisten + +#ifdef recv +#undef recv +#endif +#define recv myrecv + +#ifdef recvfrom +#undef recvfrom +#endif +#define recvfrom myrecvfrom + +#ifdef send +#undef send +#endif +#define send mysend + +#ifdef sendto +#undef sendto +#endif +#define sendto mysendto + +#ifdef setsockopt +#undef setsockopt +#endif +#define setsockopt mysetsockopt + +#ifdef shutdown +#undef shutdown +#endif +#define shutdown myshutdown + +#ifdef socket +#undef socket +#endif +#define socket mysocket + +#ifdef gethostbyaddr +#undef gethostbyaddr +#endif +#define gethostbyaddr mygethostbyaddr + +#ifdef gethostbyname +#undef gethostbyname +#endif +#define gethostbyname mygethostbyname + +#ifdef gethostname +#undef gethostname +#endif +#define gethostname mygethostname + +#ifdef getprotobyname +#undef getprotobyname +#endif +#define getprotobyname mygetprotobyname + +#ifdef getprotobynumber +#undef getprotobynumber +#endif +#define getprotobynumber mygetprotobynumber + +#ifdef getservbyname +#undef getservbyname +#endif +#define getservbyname mygetservbyname + +#ifdef getservbyport +#undef getservbyport +#endif +#define getservbyport mygetservbyport +#endif -- cgit v1.2.3