summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--C-IF35
-rw-r--r--ChangeLog86
-rw-r--r--MANIFEST67
-rw-r--r--Makefile.in4
-rw-r--r--ToDo6
-rw-r--r--array.c37
-rw-r--r--bignum.c2
-rw-r--r--class.c35
-rw-r--r--cons.c4
-rw-r--r--dbm.c9
-rw-r--r--dict.c36
-rw-r--r--dir.c6
-rw-r--r--dln.c8
-rw-r--r--enum.c11
-rw-r--r--error.c10
-rw-r--r--eval.c257
-rw-r--r--file.c6
-rw-r--r--gc.c166
-rw-r--r--getopt1.c2
-rw-r--r--io.c10
-rw-r--r--missing/MANIFEST10
-rw-r--r--node.h6
-rw-r--r--numeric.c14
-rw-r--r--object.c63
-rw-r--r--parse.y759
-rw-r--r--process.c2
-rw-r--r--range.c3
-rw-r--r--re.c37
-rw-r--r--ruby.c2
-rw-r--r--ruby.h28
-rw-r--r--sample/Artistic117
-rw-r--r--sample/MANIFEST63
-rw-r--r--sample/biorhythm.rb201
-rw-r--r--sample/blk.rb8
-rw-r--r--sample/clone.rb2
-rw-r--r--sample/dir.rb2
-rw-r--r--sample/evaldef.rb2
-rw-r--r--sample/export.rb6
-rw-r--r--sample/exyacc.rb22
-rw-r--r--sample/gctest2.rb71
-rw-r--r--sample/list.rb19
-rw-r--r--sample/list2.rb6
-rw-r--r--sample/list3.rb6
-rw-r--r--sample/rcs.awk33
-rw-r--r--sample/rcs.dat17
-rw-r--r--sample/rcs.rb49
-rw-r--r--sample/sieve.rb3
-rwxr-xr-xsample/uumerge.rb6
-rw-r--r--signal.c11
-rw-r--r--socket.c23
-rw-r--r--spec1109
-rw-r--r--sprintf.c2
-rw-r--r--st.c20
-rw-r--r--string.c10
-rw-r--r--struct.c2
-rw-r--r--time.c12
-rw-r--r--variable.c146
-rw-r--r--version.c4
-rw-r--r--version.h4
59 files changed, 2422 insertions, 1275 deletions
diff --git a/C-IF b/C-IF
index 05f6edb638..5c66a20ddc 100644
--- a/C-IF
+++ b/C-IF
@@ -24,9 +24,6 @@ Ruby-C ���󥿡��ե�����
�ѹ�������ϰʸ��self���ͤ��Τ�Τ��Ѥ�äƤ��ޤ��Τ�, ���̤ʻ���
���ʤ��¤��������ƤϤʤ�ʤ�.
- ����: �إå��ե�����"env.h"�򥤥󥯥롼�ɤ��Ƥ��ʤ��ե�����Ǥ�,
- Qself������Ǥ���, ������ʸˡ���顼�Ȥʤ�.
-
TRUE
���: t���֥�������(���Υǥե������)
@@ -43,7 +40,7 @@ Ruby-C ���󥿡��ե�����
VALUE rb_define_module(char *name)
- Ruby�⥸�塼����������.
+ ������Ruby�⥸�塼����������.
void rb_include_module(VALUE class, VALUE module)
@@ -67,8 +64,8 @@ Ruby-C ���󥿡��ե�����
void rb_global_variable(VALUE *var)
- GC�Τ���Ruby����ϥ�����������ʤ���, Ruby���֥������Ȥ�ޤ������
- ����ޡ�������.
+ GC�Τ��ᡤRuby�ץ�����फ��ϥ�����������ʤ���, Ruby���֥�������
+ ��ޤ�����ѿ���ޡ�������.
void rb_read_only_hook()
@@ -87,20 +84,21 @@ Ruby-C ���󥿡��ե�����
�᥽�åɤ��������. argc��self����������ο�. argc��-1�λ�, �ؿ���
�ϰ����ο�(self��ޤޤʤ�)����1����, �������������2�����Ȥ������
- ��Ϳ������. argc��-2�λ�, ������self, args(args�ϰ�����ޤ�ruby��
- ����)�Ȥ���������Ϳ������.
+ ��Ϳ������(��3������self). argc��-2�λ�, ������self, args(args��
+ ������ޤ�ruby������)�Ȥ���������Ϳ������.
rb_define_single_method(VALUE class, char *name, VALUE (*func)(), int argc)
�ðۥ᥽�åɤ��������. ������rb_define_method()��Ʊ��.
- rb_scan_args(VALUE args, char *fmt, ...)
+ rb_scan_args(int atgc, VALUE *argv, char *fmt, ...)
- args������Ϳ����줿������ʬ�򤹤�. fmt��ɬ�ܰ����ο�, �ղð����ο�,
- �Ĥ�ΰ��������뤫����ꤹ��ʸ�����, "��������*"�Ȥ��������Ǥ���.
- 2 ���ܤο�����"*"�Ϥ��줾���ά��ǽ�Ǥ���. ��3�����ʹߤ��ѿ��ؤΥ�
- ���󥿤�, �����������Ǥ������ѿ��˳�Ǽ�����. �ղð������б������
- ����Ϳ�����Ƥ��ʤ������ѿ���Qnil�����������.
+ argc,argv������Ϳ����줿������ʬ�򤹤�. fmt��ɬ�ܰ����ο�, �ղð�
+ ���ο�, �Ĥ�ΰ��������뤫����ꤹ��ʸ�����, "��������*"�Ȥ�������
+ �Ǥ���. 2 ���ܤο�����"*"�Ϥ��줾���ά��ǽ�Ǥ���. ɬ�ܰ��������
+ ��ʤ�����0����ꤹ�롥��3�����ʹߤ��ѿ��ؤΥݥ��󥿤�, ��������
+ ���Ǥ������ѿ��˳�Ǽ�����. �ղð������б����������Ϳ�����Ƥ���
+ �������ѿ���Qnil�����������.
Ruby�᥽�åɸƤӽФ�
@@ -108,12 +106,13 @@ Ruby�᥽�åɸƤӽФ�
�᥽�åɸƤӽФ�. ʸ���󤫤�mid�����뤿��ˤ�rb_intern()��Ȥ�.
- rb_call_super(VALUE args)
+ VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
+
+ �᥽�åɸƤӽФ�. ������argc,argv�������Ϥ���
- �����ѡ����饹�Υ᥽�åɤ�ƤӽФ�. args�ϰ����ꥹ�ȤȤʤ�����.
- args ��Qnil�λ��ϸ��ߤΥ᥽�åɤΰ����򤽤Τޤް����Ѥ�.
+ VALUE rb_eval_string(char *str)
-ʸ���� <-> ID�Ѵ�
+ ʸ�����ruby�ȥ�����ץȤ��ƥ���ѥ��롦�¹Ԥ��롥
ID rb_intern(char *name)
diff --git a/ChangeLog b/ChangeLog
index f6246f3a0d..35d02ea51e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,91 @@
+Wed Feb 1 19:48:24 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * string.c(str_replace): �֤�������ʸ�����Ĺ���������������ꥳ
+ �ԡ��򤷤ʤ���
+
+ * string.c(rindex): ��������
+
+Mon Jan 30 11:23:05 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * parse.y(value_expr): if�Υ����å����ɲá�
+
+ * gc.c(gc_mark): free cell�ΰ����˥Х���
+
+ * parse.y: ʸˡ���ѹ�(��ꥷ��ץ��)���㳰�򸺤餷����
+
+Thu Jan 26 00:52:55 1995 Yukihiro Matsumoto (matz@dyna)
+
+ * parse.y: �����Ȥ���Ϣ��������֤����Ȥ��Ǥ���褦�ˡ����ξ�硤
+ Ϣ�������ƥ�뤬�ǽ������Ȥʤ롥
+
+ * parse.y: ���󻲾Ȥ�`[]'�⤬���Ǥ�褤���Ȥˤ�����
+
+Tue Jan 24 14:45:15 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * class.c(rb_include_module): `-v'����ꤷ�����ˤ�include�����⥸�塼
+ ��ȥ��饹��������ͤ��Ƥ��ʤ��������å����롥
+
+Mon Jan 23 10:42:09 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * parse.y(rb_class2name): �᥿���饹�˴ؤ���bug fix.
+
+ * dict.c: Dict[..]�Ǽ���������������褦�ˡ�
+
+ * array.c: Array[..]������������������褦�ˡ�
+
+ * parse.y: �����ɽ���Ȥ���{a,b,..}�Ȥ�������������褦�ˡ�
+
+Fri Jan 20 10:28:38 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * re.c(Regexp.quote): ����ɽ���򥨥������פ���᥽�åɡ�
+
+ * ̵�̤�rb_intern()�򸺤餷����
+
+ * parse.y: `!', `!=', `!~'���ü�黻�Ҥˤ��롥��äƤ����Ϻ����
+ �Ǥ��ʤ��ʤä���
+
+Wed Jan 18 13:20:41 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * parse.y: ʸˡ������(unless,until��ʤ�����)��
+
+Tue Jan 17 11:11:27 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * eval.c: def�ǥ᥽�åɺ�������ˤϥ����ѡ����饹�Υ᥽�åɤβĻ�
+ ����Ѿ����롥�ǽ������λ��Ϻ��ޤǤ�Ʊ���ǥե����(�ȥåץ��
+ ��Ǵؿ�Ū�����饹�������̾�᥽�å�)��
+
+ * object.c(Class::new): ���֥������Ȥ��������˴ؿ�Ū��
+ ���å�init_object��ɬ���ƤФ��褦���ѹ���
+
+ * eval.c: ̤����Υ᥽�åɤ��Ф���unknown�᥽�åɤ��ƤФ��褦��
+ �ʤä������顼ɽ�������ޤǤ�Ʊ���ˤʤ�褦��env��Ĵ�ᤷ�Ƥ��롥
+
+Fri Jan 13 14:40:30 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * gc.c: gc��㴳�񤭴����������������������ޤ��Ѳ��Ϥʤ��ä��褦����
+
+ * parse.y(yylex): symbol��\sym����:sym���ѹ�������
+
+Thu Jan 12 01:39:28 1995 Yukihiro Matsumoto (matz@dyna)
+
+ * eval.c: �����ؿ� rb_eval_string()��
+
+ * gc.c: gc_mark()�������Ƶ�����
+
+ * variable.c(rb_ivar_{get,set}): ���󥹥����ѿ��Υ������������
+ �����å���­��ʤ��ä���
+
+ * variable.c: ���饹����ȥ��󥹥����ѿ��ǥϥå���ơ��֥��ͭ
+ ����褦�ˤ�����
+
+ * ruby.h: iv_tbl��RBasic����RObject��RClass�ذ�ư����������ˤ�ꡤ
+ Object��Class,Module�������󥹥����ѿ�����Ƥʤ��ʤ롥�������
+ ���Ψ�ϼ㴳���夹�롥
+
Tue Jan 10 00:58:20 1995 Yukihiro Matsumoto (matz@dyna)
+ * 0.64 released
+
* eval.c: �쥷���ФȰ����Ͼ��iter�ǤϤʤ���
* cons.c(aref,aset): negative offset���
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000000..429e921074
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,67 @@
+C-IF
+ChangeLog
+FAQ
+MANIFEST
+Makefile.in
+README
+ToDo
+array.c
+bignum.c
+class.c
+compar.c
+configure
+configure.in
+cons.c
+dbm.c
+defines.h
+dict.c
+dir.c
+dln.c
+dln.h
+enum.c
+env.h
+error.c
+etc.c
+eval.c
+file.c
+fnmatch.c
+fnmatch.h
+gc.c
+getopt.c
+getopt.h
+getopt1.c
+glob.c
+gnuglob.c
+ident.h
+inits.c
+io.c
+io.h
+main.c
+math.c
+node.h
+numeric.c
+object.c
+pack.c
+parse.y
+process.c
+random.c
+range.c
+re.c
+re.h
+regex.c
+regex.h
+ruby.1
+ruby.c
+ruby.h
+signal.c
+socket.c
+spec
+sprintf.c
+st.c
+st.h
+string.c
+struct.c
+time.c
+variable.c
+version.c
+version.h
diff --git a/Makefile.in b/Makefile.in
index 477b4fdbd2..b0c6eb5ea9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -160,7 +160,7 @@ io.o: io.c ruby.h config.h defines.h io.h
main.o: main.c
math.o: math.c ruby.h config.h defines.h
numeric.o: numeric.c ruby.h config.h defines.h env.h
-object.o: object.c ruby.h config.h defines.h env.h node.h st.h
+object.o: object.c ruby.h config.h defines.h env.h st.h
pack.o: pack.c ruby.h config.h defines.h
process.o: process.c ruby.h config.h defines.h st.h
random.o: random.c ruby.h config.h defines.h
@@ -174,5 +174,5 @@ st.o: st.c st.h
string.o: string.c ruby.h config.h defines.h re.h regex.h
struct.o: struct.c ruby.h config.h defines.h env.h
time.o: time.c ruby.h config.h defines.h
-variable.o: variable.c ruby.h config.h defines.h env.h node.h ident.h st.h
+variable.o: variable.c ruby.h config.h defines.h env.h ident.h st.h
version.o: version.c ruby.h config.h defines.h version.h
diff --git a/ToDo b/ToDo
index 5422040f45..5dcb005f52 100644
--- a/ToDo
+++ b/ToDo
@@ -1,10 +1,12 @@
+* Process Class
+* ���饹�饤�֥��θ�ľ��(UNIX��¸�򸺤餹)
* format��ǽ
* here document
* perl�Τ褦��setuid check
* tr����BSD�����ɤ������(�ޤ���copyright��Ϥä��ꤵ����)
* Ŭ�ڤ�signal handling
-* dln��COFF�б�
+* dln��COFF�б�(�ޤ���dlopen�б�)
* ruby����������ѿ�hook�μ¸�
* write debugger for ruby
-* re-write regex code for speeding
+* re-write regex code for speed
* byte code interpretor
diff --git a/array.c b/array.c
index 5a8f040723..28d755b73f 100644
--- a/array.c
+++ b/array.c
@@ -77,32 +77,33 @@ ary_new4(n, elts)
return (VALUE)ary;
}
-#if 0
-VALUE
-assoc_new(elm1, elm2)
- VALUE elm1, elm2;
+static VALUE
+Sary_new(class)
+ VALUE class;
{
- struct RArray *ary;
+ NEWOBJ(ary, struct RArray);
+ OBJSETUP(ary, class, T_ARRAY);
- ary = (struct RArray*)ary_new2(2);
- ary->ptr[0] = elm1;
- ary->ptr[1] = elm2;
- ary->len = 2;
+ ary->len = 0;
+ ary->capa = ARY_DEFAULT_SIZE;
+ ary->ptr = ALLOC_N(VALUE, ARY_DEFAULT_SIZE);
return (VALUE)ary;
}
-#endif
static VALUE
-Sary_new(class)
+Sary_create(argc, argv, class)
+ int argc;
+ VALUE *argv;
VALUE class;
{
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, class, T_ARRAY);
- ary->len = 0;
- ary->capa = ARY_DEFAULT_SIZE;
- ary->ptr = ALLOC_N(VALUE, ARY_DEFAULT_SIZE);
+ ary->len = argc;
+ ary->capa = argc;
+ ary->ptr = ALLOC_N(VALUE, argc);
+ MEMCPY(ary->ptr, argv, VALUE, argc);
return (VALUE)ary;
}
@@ -648,7 +649,10 @@ static int
sort_2(a, b)
VALUE *a, *b;
{
- VALUE retval = rb_funcall(*a, cmp, 1, *b);
+ VALUE retval;
+
+ if (!cmp) cmp = rb_intern("<=>");
+ retval = rb_funcall(*a, cmp, 1, *b);
return NUM2INT(retval);
}
@@ -936,6 +940,7 @@ Init_Array()
rb_include_module(C_Array, M_Enumerable);
rb_define_single_method(C_Array, "new", Sary_new, 0);
+ rb_define_single_method(C_Array, "[]", Sary_create, -1);
rb_define_method(C_Array, "to_s", Fary_to_s, 0);
rb_define_method(C_Array, "_inspect", Fary_inspect, 0);
rb_define_method(C_Array, "to_a", Fary_to_a, 0);
@@ -976,6 +981,4 @@ Init_Array()
rb_define_method(C_Array, "-", Fary_diff, 1);
rb_define_method(C_Array, "&", Fary_and, 1);
rb_define_method(C_Array, "|", Fary_or, 1);
-
- cmp = rb_intern("<=>");
}
diff --git a/bignum.c b/bignum.c
index 59667faaca..ef76fc532d 100644
--- a/bignum.c
+++ b/bignum.c
@@ -88,7 +88,7 @@ bignorm(x)
while (len-- && !ds[len]) ;
x->len = ++len;
-
+
if (len*sizeof(USHORT) < sizeof(VALUE) ||
(len*sizeof(USHORT) == sizeof(VALUE) &&
ds[sizeof(VALUE)/sizeof(USHORT)-1] <= 0x3fff)) {
diff --git a/class.c b/class.c
index ba056a6283..6c790b79ee 100644
--- a/class.c
+++ b/class.c
@@ -3,7 +3,7 @@
class.c -
$Author: matz $
- $Date: 1995/01/10 10:42:21 $
+ $Date: 1995/01/12 08:54:44 $
created at: Tue Aug 10 15:05:44 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
@@ -29,7 +29,6 @@ class_new(super)
cls->super = super;
cls->m_tbl = new_idhash();
- cls->c_tbl = Qnil;
return (VALUE)cls;
}
@@ -69,13 +68,12 @@ single_class_clone(class)
clone->super = class->super;
clone->m_tbl = new_idhash();
st_foreach(class->m_tbl, clone_method, clone->m_tbl);
- clone->c_tbl = Qnil;
FL_SET(clone, FL_SINGLE);
return (VALUE)clone;
}
}
-VALUE
+VALUE
rb_define_class_id(id, super)
ID id;
struct RBasic *super;
@@ -90,7 +88,7 @@ rb_define_class_id(id, super)
return (VALUE)cls;
}
-VALUE
+VALUE
rb_define_class(name, super)
char *name;
VALUE super;
@@ -106,12 +104,11 @@ module_new()
mdl->super = Qnil;
mdl->m_tbl = new_idhash();
- mdl->c_tbl = Qnil;
return (VALUE)mdl;
}
-VALUE
+VALUE
rb_define_module_id(id)
ID id;
{
@@ -121,7 +118,7 @@ rb_define_module_id(id)
return (VALUE)mdl;
}
-VALUE
+VALUE
rb_define_module(name)
char *name;
{
@@ -138,7 +135,7 @@ include_class_new(module, super)
OBJSETUP(cls, C_Class, T_ICLASS);
cls->m_tbl = module->m_tbl;
- cls->c_tbl = module->c_tbl;
+ cls->iv_tbl = module->iv_tbl;
cls->super = super;
if (TYPE(module) == T_ICLASS) {
RBASIC(cls)->class = RBASIC(module)->class;
@@ -155,26 +152,30 @@ rb_include_module(class, module)
struct RClass *class, *module;
{
struct RClass *p;
- int added = FALSE;
+
+ if (!module) return;
Check_Type(module, T_MODULE);
+ if (BUILTIN_TYPE(class) == T_CLASS) {
+ rb_clear_cache2(class);
+ }
+
while (module) {
- /* ignore if module included already in superclasses */
+ /* ignore if the module included already in superclasses */
for (p = class->super; p; p = p->super) {
if (BUILTIN_TYPE(p) == T_ICLASS && p->m_tbl == module->m_tbl)
- goto ignore_module;
+ return;
+ }
+
+ if (verbose) {
+ rb_const_check(class, module);
}
class->super = include_class_new(module, class->super);
- added = TRUE;
class = class->super;
- ignore_module:
module = module->super;
}
- if (added) {
- rb_clear_cache2(class);
- }
}
void
diff --git a/cons.c b/cons.c
index ac562814ca..bf755865c9 100644
--- a/cons.c
+++ b/cons.c
@@ -3,7 +3,7 @@
cons.c -
$Author: matz $
- $Date: 1995/01/10 10:22:24 $
+ $Date: 1995/01/10 10:30:37 $
created at: Fri Jan 6 10:10:36 JST 1995
Copyright (C) 1994 Yukihiro Matsumoto
@@ -178,6 +178,7 @@ Fcons_hash(cons)
{
int key;
+ if (!hash) hash = rb_intern("hash");
key = rb_funcall(cons->car, hash, 0, 0);
key ^= rb_funcall(cons->cdr, hash, 0, 0);
return INT2FIX(key);
@@ -253,7 +254,6 @@ Init_Cons()
rb_define_method(C_Cons, "==", Fcons_equal, 1);
rb_define_method(C_Cons, "hash", Fcons_hash, 0);
- hash = rb_intern("hash");
rb_define_method(C_Cons, "length", Fcons_length, 0);
rb_define_method(C_Cons, "to_s", Fcons_to_s, 0);
diff --git a/dbm.c b/dbm.c
index c0fd514e59..ed605614a0 100644
--- a/dbm.c
+++ b/dbm.c
@@ -31,6 +31,7 @@ closeddbm()
#define GetDBM(obj, dbmp) {\
DBM **_dbm;\
+ if (!id_dbm) id_dbm = rb_intern("dbm");\
Get_Data_Struct(obj, id_dbm, DBM*, _dbm);\
dbmp = *_dbm;\
if (dbmp == Qnil) closeddbm();\
@@ -156,7 +157,7 @@ Fdbm_delete(obj, keystr)
Check_Type(keystr, T_STRING);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
-
+
GetDBM(obj, dbm);
if (dbm_delete(dbm, key)) {
Fail("dbm_delete failed");
@@ -338,7 +339,7 @@ Fdbm_has_key(obj, keystr)
Check_Type(keystr, T_STRING);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
-
+
GetDBM(obj, dbm);
val = dbm_fetch(dbm, key);
if (val.dptr) return TRUE;
@@ -355,7 +356,7 @@ Fdbm_has_value(obj, valstr)
Check_Type(valstr, T_STRING);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
-
+
GetDBM(obj, dbm);
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
@@ -412,7 +413,5 @@ Init_DBM()
rb_define_method(C_DBM, "has_value", Fdbm_has_value, 1);
rb_define_method(C_DBM, "to_a", Fdbm_to_a, 0);
-
- id_dbm = rb_intern("dbm");
}
#endif /* USE_DBM */
diff --git a/dict.c b/dict.c
index d6ccbca56e..fa4ffc04e3 100644
--- a/dict.c
+++ b/dict.c
@@ -41,7 +41,6 @@ static VALUE
Sdic_new(class)
VALUE class;
{
- int i, max;
NEWOBJ(dic, struct RDict);
OBJSETUP(dic, class, T_DICT);
@@ -50,6 +49,40 @@ Sdic_new(class)
return (VALUE)dic;
}
+static VALUE Fdic_clone();
+
+static VALUE
+Sdic_create(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ struct RDict *dic;
+ int i;
+
+ if (argc == 1 && TYPE(argv[0]) == T_DICT) {
+ if (class == CLASS_OF(argv[0])) return argv[0];
+ else {
+ NEWOBJ(dic, struct RDict);
+ OBJSETUP(dic, class, T_DICT);
+ dic->tbl = (st_table*)st_copy(RDICT(argv[0])->tbl);
+
+ return (VALUE)dic;
+ }
+ }
+
+ if (argc % 2 != 0) {
+ Fail("odd number args for Dict");
+ }
+ dic = (struct RDict*)Sdic_new(class);
+
+ for (i=0; i<argc; i+=2) {
+ st_insert(dic->tbl, argv[i], argv[i+1]);
+ }
+
+ return (VALUE)dic;
+}
+
VALUE
dic_new()
{
@@ -551,6 +584,7 @@ Init_Dict()
rb_include_module(C_Dict, M_Enumerable);
rb_define_single_method(C_Dict, "new", Sdic_new, 0);
+ rb_define_single_method(C_Dict, "[]", Sdic_create, -1);
rb_define_method(C_Dict,"clone", Fdic_clone, 0);
diff --git a/dir.c b/dir.c
index 0baa13fdd1..755290fa0c 100644
--- a/dir.c
+++ b/dir.c
@@ -55,11 +55,12 @@ Sdir_open(dir_class, dirname)
DIR *dirp, **d;
Check_Type(dirname, T_STRING);
-
+
dirp = opendir(dirname->ptr);
if (dirp == NULL) Fail("Can't open directory %s", dirname->ptr);
obj = obj_alloc(dir_class);
+ if (!id_dir) id_dir = rb_intern("dir");
Make_Data_Struct(obj, id_dir, DIR*, Qnil, free_dir, d);
*d = dirp;
@@ -74,6 +75,7 @@ closeddir()
#define GetDIR(obj, dirp) {\
DIR **_dp;\
+ if (!id_dir) id_dir = rb_intern("dir");\
Get_Data_Struct(obj, id_dir, DIR*, _dp);\
dirp = *_dp;\
if (dirp == NULL) closeddir();\
@@ -260,6 +262,4 @@ Init_Dir()
rb_define_single_method(C_Dir,"rmdir", Sdir_rmdir, 1);
rb_define_single_method(C_Dir,"delete", Sdir_rmdir, 1);
rb_define_single_method(C_Dir,"unlink", Sdir_rmdir, 1);
-
- id_dir = rb_intern("dir");
}
diff --git a/dln.c b/dln.c
index 44179ec3e9..2e1ff5aed5 100644
--- a/dln.c
+++ b/dln.c
@@ -238,7 +238,7 @@ dln_load_reloc(fd, hdrp, disp)
int size;
lseek(fd, disp + N_TXTOFF(*hdrp) + hdrp->a_text + hdrp->a_data, 0);
-
+
size = hdrp->a_trsize + hdrp->a_drsize;
reloc = (struct relocation_info*)xmalloc(size);
if (reloc == NULL) {
@@ -251,7 +251,7 @@ dln_load_reloc(fd, hdrp, disp)
free(reloc);
return NULL;
}
-
+
return reloc;
}
@@ -681,7 +681,7 @@ static int dln_load_1(fd, disp, need_init)
*/
{
struct relocation_info * rel = reloc;
- struct relocation_info * rel_beg = reloc +
+ struct relocation_info * rel_beg = reloc +
(hdr.a_trsize/sizeof(struct relocation_info));
struct relocation_info * rel_end = reloc +
(hdr.a_trsize+hdr.a_drsize)/sizeof(struct relocation_info);
@@ -772,7 +772,7 @@ static int dln_load_1(fd, disp, need_init)
while (sym < end) {
char *name = sym->n_un.n_name;
if (name[0] == '_' && sym->n_value >= block
- && ((bcmp (name, "_Init_", 6) == 0
+ && ((bcmp (name, "_Init_", 6) == 0
|| bcmp (name, "_init_", 6) == 0) && name[6] != '_')) {
init_p = 1;
((int (*)())sym->n_value)();
diff --git a/enum.c b/enum.c
index 5eaef855f1..a27c9860d2 100644
--- a/enum.c
+++ b/enum.c
@@ -19,6 +19,7 @@ void
rb_each(obj)
VALUE obj;
{
+ if (!id_each) id_each = rb_intern("each");
rb_funcall(obj, id_each, 0, Qnil);
}
@@ -26,6 +27,7 @@ static void
enum_grep(i, arg)
VALUE i, *arg;
{
+ if (!id_match) id_match = rb_intern("=~");
if (rb_funcall(arg[0], id_match, 1, i)) {
ary_push(arg[1], i);
}
@@ -35,6 +37,7 @@ static void
enum_grep2(i, pat)
VALUE i, pat;
{
+ if (!id_match) id_match = rb_intern("=~");
if (rb_funcall(pat, id_match, 1, i)) {
rb_yield(i);
}
@@ -150,7 +153,7 @@ enum_all(i, ary)
{
ary_push(ary, i);
}
-
+
static VALUE
Fenum_to_a(obj)
VALUE obj;
@@ -183,6 +186,7 @@ enum_min(i, min)
if (*min == Qnil)
*min = i;
else {
+ if (!id_cmp) id_cmp = rb_intern("<=>");
cmp = rb_funcall(i, id_cmp, 1, *min);
if (FIX2INT(cmp) < 0)
*min = i;
@@ -208,6 +212,7 @@ enum_max(i, max)
if (*max == Qnil)
*max = i;
else {
+ if (!id_cmp) id_cmp = rb_intern("<=>");
cmp = rb_funcall(i, id_cmp, 1, *max);
if (FIX2INT(cmp) > 0)
*max = i;
@@ -316,8 +321,4 @@ Init_Enumerable()
rb_define_method(M_Enumerable,"index", Fenum_index, 1);
rb_define_method(M_Enumerable,"includes", Fenum_includes, 1);
rb_define_method(M_Enumerable,"length", Fenum_length, 0);
-
- id_each = rb_intern("each");
- id_match = rb_intern("=~");
- id_cmp = rb_intern("<=>");
}
diff --git a/error.c b/error.c
index 437d0baef3..e9626165fb 100644
--- a/error.c
+++ b/error.c
@@ -82,7 +82,7 @@ Warning(fmt, va_alist)
char *fmt;
va_dcl
{
- char buf[BUFSIZ];
+ char buf[BUFSIZ];
va_list args;
sprintf(buf, "warning: %s", fmt);
@@ -108,7 +108,7 @@ Bug(fmt, va_alist)
char *fmt;
va_dcl
{
- char buf[BUFSIZ];
+ char buf[BUFSIZ];
va_list args;
sprintf(buf, "[BUG] %s", fmt);
@@ -124,7 +124,7 @@ Fail(fmt, va_alist)
va_dcl
{
va_list args;
- char buf[BUFSIZ];
+ char buf[BUFSIZ];
va_start(args);
vsprintf(buf, fmt, args);
@@ -132,7 +132,7 @@ Fail(fmt, va_alist)
rb_fail(str_new2(buf));
}
-
+
rb_sys_fail(mesg)
char *mesg;
{
@@ -164,8 +164,6 @@ static char *builtin_types[] = {
"Method",
"Struct",
"Bignum",
- "Node",
- "Scope",
"Cons",
"Data",
};
diff --git a/eval.c b/eval.c
index c54fa14e5e..1e00de909c 100644
--- a/eval.c
+++ b/eval.c
@@ -3,7 +3,7 @@
eval.c -
$Author: matz $
- $Date: 1995/01/10 10:42:34 $
+ $Date: 1995/01/12 08:54:45 $
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
@@ -52,7 +52,7 @@ search_method(class, id, origin)
if (class == Qnil) return Qnil;
}
- *origin = class;
+ if (origin) *origin = class;
return body;
}
@@ -389,6 +389,7 @@ ruby_init(argc, argv, envp)
static struct ENVIRON env;
the_env = top_env = &env;
+ init_heap();
PUSH_SCOPE();
the_scope->local_vars = Qnil;
the_scope->local_tbl = Qnil;
@@ -414,13 +415,14 @@ ruby_init(argc, argv, envp)
VALUE rb_readonly_hook();
static VALUE
-Eval(toplevel)
- int toplevel;
+Eval()
{
VALUE result;
NODE *tree;
int state;
+ if (!eval_tree) return Qnil;
+
tree = eval_tree;
eval_tree = Qnil;
sourcefile = tree->file;
@@ -441,7 +443,7 @@ ruby_run()
if (nerrs > 0) exit(nerrs);
- Init_stack();
+ init_stack();
rb_define_variable("$!", &errstr, Qnil, Qnil, 0);
errat = Qnil; /* clear for execution */
@@ -449,7 +451,7 @@ ruby_run()
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
the_class = (struct RClass*)C_Object;
- Eval(1);
+ Eval();
}
POP_ITER();
POP_TAG();
@@ -488,6 +490,38 @@ ruby_run()
exit(0);
}
+static void
+syntax_error()
+{
+ VALUE mesg;
+
+ mesg = errstr;
+ nerrs = 0;
+ errstr = str_new2("syntax error in eval():\n");
+ str_cat(errstr, RSTRING(mesg)->ptr, RSTRING(mesg)->len);
+ rb_fail(errstr);
+}
+
+VALUE
+rb_eval_string(str)
+ char *str;
+{
+ char *oldsrc = sourcefile;
+ VALUE result;
+
+ lex_setsrc("(eval)", str, strlen(str));
+ eval_tree = Qnil;
+ yyparse();
+ sourcefile = oldsrc;
+ if (nerrs == 0) {
+ return Eval();
+ }
+ else {
+ syntax_error();
+ }
+ return Qnil; /* not reached */
+}
+
void
rb_trap_eval(cmd)
VALUE cmd;
@@ -636,34 +670,9 @@ rb_eval(node)
return rb_eval(node);
}
node = node->nd_next;
- }
- }
- return Qnil;
-
- case NODE_EXNOT:
- {
- VALUE res;
-
- PUSH_TAG();
- switch (state = EXEC_TAG()) {
- case 0:
- res = rb_eval(node->nd_cond);
- go_out = 0;
- break;
-
- case TAG_FAIL:
- res = Qnil;
- go_out = 0;
- break;
-
- default:
- go_out = 1;
}
- POP_TAG();
- if (go_out) JUMP_TAG(state);
- if (res) return FALSE;
- return TRUE;
}
+ return Qnil;
case NODE_WHILE:
PUSH_TAG();
@@ -828,6 +837,10 @@ rb_eval(node)
node = node->nd_2nd;
goto again;
+ case NODE_NOT:
+ if (rb_eval(node->nd_body)) return FALSE;
+ return TRUE;
+
case NODE_DOT3:
if (node->nd_state == 0) {
if (rb_eval(node->nd_beg)) {
@@ -943,7 +956,8 @@ rb_eval(node)
val = rb_apply(recv, aref, args);
val = rb_funcall(val, node->nd_mid, 1, rb_eval(rval));
ary_push(args, val);
- return rb_apply(recv, aset, args);
+ rb_apply(recv, aset, args);
+ return val;
}
case NODE_OP_ASGN2:
@@ -957,7 +971,8 @@ rb_eval(node)
id |= ID_ATTRSET;
val = rb_eval(node->nd_value);
- return rb_funcall(recv, id, 1, val);
+ rb_funcall(recv, id, 1, val);
+ return val;
}
case NODE_MASGN:
@@ -1044,7 +1059,7 @@ rb_eval(node)
key = rb_eval(list->nd_head);
list = list->nd_next;
if (list == Qnil)
- Bug("odd number list for hash");
+ Bug("odd number list for Dict");
val = rb_eval(list->nd_head);
list = list->nd_next;
Fdic_aset(hash, key, val);
@@ -1122,39 +1137,42 @@ rb_eval(node)
return rb_ivar_set(node->nd_vid, the_env->argv[0]);
case NODE_DEFN:
- {
- if (node->nd_defn) {
- rb_add_method(the_class,node->nd_mid,node->nd_defn,
- node->nd_noex);
+ if (node->nd_defn) {
+ NODE *body;
+ VALUE origin;
+ int noex;
+
+ body = search_method(the_class, node->nd_mid, &origin);
+ if (verbose && origin != (VALUE)the_class
+ && body->nd_noex != node->nd_noex) {
+ Warning("change method %s's scope", rb_id2name(node->nd_mid));
}
+
+ if (body) noex = body->nd_noex;
+ else noex = node->nd_noex; /* default(1 for toplevel) */
+
+ rb_add_method(the_class, node->nd_mid, node->nd_defn, noex);
}
return Qnil;
case NODE_DEFS:
- {
- if (node->nd_defn) {
- VALUE recv = rb_eval(node->nd_recv);
+ if (node->nd_defn) {
+ VALUE recv = rb_eval(node->nd_recv);
- if (recv == Qnil) {
- Fail("Can't define method \"%s\" for nil",
- rb_id2name(node->nd_mid));
- }
- rb_add_method(rb_single_class(recv),
- node->nd_mid, node->nd_defn, 0);
+ if (recv == Qnil) {
+ Fail("Can't define method \"%s\" for nil",
+ rb_id2name(node->nd_mid));
}
+ rb_add_method(rb_single_class(recv),node->nd_mid,node->nd_defn,0);
}
return Qnil;
case NODE_UNDEF:
- {
- rb_add_method(the_class, node->nd_mid, Qnil, 0);
- }
+ rb_add_method(the_class, node->nd_mid, Qnil, 0);
return Qnil;
case NODE_ALIAS:
- {
- rb_alias(the_class, node->nd_new, node->nd_old);
- }
+ rb_alias(the_class, node->nd_new, node->nd_old);
return Qnil;
case NODE_CLASS:
@@ -1492,7 +1510,7 @@ asign(lhs, val)
break;
default:
- Bug("bug in iterator variable asignment");
+ Bug("bug in variable asignment");
break;
}
}
@@ -1614,28 +1632,62 @@ rb_ensure(b_proc, data1, e_proc, data2)
return result;
}
-struct st_table *new_idhash();
+static int last_noex;
-static void
-rb_undefined(obj, id, noex)
+static VALUE
+Funknown(argc, argv, obj)
+ int argc;
+ VALUE *argv;
VALUE obj;
- ID id;
- int noex;
{
- VALUE desc = obj_as_string(obj);
+ VALUE desc;
+ ID id;
char *format;
+ struct ENVIRON *env;
+
+ id = FIX2INT(argv[0]);
+ argc--; argv++;
+ desc = obj_as_string(obj);
if (RSTRING(desc)->len > 160) {
desc = Fkrn_to_s(obj);
}
- if (noex)
+ if (last_noex)
format = "method `%s' not available for \"%s\"(%s)";
else
format = "undefined method `%s' for \"%s\"(%s)";
+
+ /* fake environment */
+ PUSH_ENV();
+ env = the_env->prev;
+ MEMCPY(the_env, the_env->prev->prev, struct ENVIRON, 1);
+ the_env->prev = env;
+
Fail(format,
rb_id2name(id),
RSTRING(desc)->ptr,
rb_class2name(CLASS_OF(obj)));
+ POP_ENV();
+}
+
+static VALUE
+rb_undefined(obj, id, argc, argv, noex)
+ VALUE obj;
+ ID id;
+ int argc;
+ VALUE*argv;
+ int noex;
+{
+ VALUE *nargv;
+
+ argc;
+ nargv = ALLOCA_N(VALUE, argc+1);
+ nargv[0] = INT2FIX(id);
+ MEMCPY(nargv+1, argv, VALUE, argc);
+
+ last_noex = noex;
+
+ return rb_funcall2(obj, rb_intern("unknown"), argc+1, nargv);
}
static VALUE
@@ -1656,7 +1708,6 @@ rb_call(class, recv, mid, argc, argv, func)
/* is it in the method cache? */
ent = cache + EXPR1(class, mid);
if (ent->mid == mid && ent->class == class) {
- /* if (ent->method == Qnil) rb_undefined(recv, mid, 0); */
class = ent->origin;
mid = ent->mid;
body = ent->method;
@@ -1666,12 +1717,14 @@ rb_call(class, recv, mid, argc, argv, func)
ID id = mid;
if ((body = rb_get_method_body(&class, &id, &noex)) == Qnil) {
- rb_undefined(recv, mid, 0);
+ return rb_undefined(recv, mid, argc, argv, 0);
}
mid = id;
}
- if (!func && noex) rb_undefined(recv, mid, 1);
+ if (!func && noex) {
+ return rb_undefined(recv, mid, argc, argv, 1);
+ }
switch (iter->iter) {
case ITER_PRE:
@@ -1691,7 +1744,7 @@ rb_call(class, recv, mid, argc, argv, func)
the_env->argv = argv;
switch (nd_type(body)) {
- case NODE_CFUNC:
+ case NODE_CFUNC:
{
int len = body->nd_argc;
@@ -1806,6 +1859,8 @@ rb_call(class, recv, mid, argc, argv, func)
/* for attr get/set */
case NODE_ATTRSET:
case NODE_IVAR:
+ /* for exported method */
+ case NODE_ZSUPER:
return rb_eval(body);
default:
@@ -1915,17 +1970,19 @@ Fapply(argc, argv, recv)
VALUE *argv;
VALUE recv;
{
- VALUE vid, rest;
+ VALUE vid;
ID mid;
- rb_scan_args(argc, argv, "1*", &vid, &rest);
+ if (argc == 0) Fail("no method name given");
+
+ vid = argv[0]; argc--; argv++;
if (TYPE(vid) == T_STRING) {
mid = rb_intern(RSTRING(vid)->ptr);
}
else {
mid = NUM2INT(vid);
}
- return rb_apply(recv, mid, rest);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
#include <varargs.h>
@@ -1958,6 +2015,16 @@ rb_funcall(recv, mid, n, va_alist)
return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1);
}
+VALUE
+rb_funcall2(recv, mid, argc, argv)
+ VALUE recv;
+ ID mid;
+ int argc;
+ VALUE *argv;
+{
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
+}
+
int rb_in_eval = 0;
static VALUE
@@ -1995,13 +2062,7 @@ Feval(obj, src)
if (state) JUMP_TAG(state);
if (nerrs > 0) {
- VALUE mesg;
-
- mesg = errstr;
- nerrs = 0;
- errstr = str_new2("syntax error in eval():\n");
- str_cat(errstr, RSTRING(mesg)->ptr, RSTRING(mesg)->len);
- rb_fail(errstr);
+ syntax_error();
}
return result;
@@ -2151,6 +2212,24 @@ addpath(path)
extern VALUE C_Kernel;
+
+Init_eval()
+{
+ match = rb_intern("=~");
+ each = rb_intern("each");
+
+ aref = rb_intern("[]");
+ aset = rb_intern("[]=");
+
+ rb_global_variable(&top_scope);
+ rb_global_variable(&eval_tree);
+ rb_define_private_method(C_Kernel, "exit", Fexit, -1);
+ rb_define_private_method(C_Kernel, "eval", Feval, 1);
+ rb_define_private_method(C_Kernel, "iterator_p", Fiterator_p, 0);
+ rb_define_method(C_Kernel, "apply", Fapply, -1);
+ rb_define_method(C_Kernel, "unknown", Funknown, -1);
+}
+
Init_load()
{
char *path;
@@ -2169,22 +2248,6 @@ Init_load()
rb_define_private_method(C_Kernel, "require", Frequire, 1);
}
-Init_eval()
-{
- match = rb_intern("=~");
- each = rb_intern("each");
-
- aref = rb_intern("[]");
- aset = rb_intern("[]=");
-
- rb_global_variable(&top_scope);
- rb_global_variable(&eval_tree);
- rb_define_private_method(C_Kernel, "exit", Fexit, -1);
- rb_define_private_method(C_Kernel, "eval", Feval, 1);
- rb_define_private_method(C_Kernel, "iterator_p", Fiterator_p, 0);
- rb_define_method(C_Kernel, "apply", Fapply, -1);
-}
-
void
scope_dup(scope)
struct SCOPE *scope;
@@ -2239,11 +2302,12 @@ Sblk_new(class)
if (the_block->block) return the_block->block;
blk = obj_alloc(class);
+ if (!blkdata) blkdata = rb_intern("blk");
Make_Data_Struct(blk, blkdata, struct BLOCK, Qnil, blk_free, data);
MEMCPY(data, the_block, struct BLOCK, 1);
data->env.argv = ALLOC_N(VALUE, data->env.argc);
- MEMCPY(data->env.argv, the_block->env.argv, VALUE, data->env.argc);
+ MEMCPY(data->env.argv, the_block->env.argv, VALUE, data->env.argc);
scope_dup(data->scope);
@@ -2252,13 +2316,13 @@ Sblk_new(class)
}
VALUE
-blk_new()
+block_new()
{
return Sblk_new(C_Block);
}
static VALUE
-Fblk_do(blk, args)
+Fblk_call(blk, args)
VALUE blk, args;
{
struct BLOCK *data;
@@ -2318,6 +2382,5 @@ Init_Block()
rb_define_single_method(C_Block, "new", Sblk_new, 0);
- rb_define_method(C_Block, "do", Fblk_do, -2);
- blkdata = rb_intern("blk");
+ rb_define_method(C_Block, "call", Fblk_call, -2);
}
diff --git a/file.c b/file.c
index bae2c3140b..6f10099c33 100644
--- a/file.c
+++ b/file.c
@@ -225,7 +225,7 @@ stat_new(st)
"blksize", INT2FIX(0),
#endif
#ifdef HAVE_ST_BLOCKS
- "blocks", INT2FIX((int)st->st_blocks),
+ "blocks", INT2FIX((int)st->st_blocks),
#else
"blocks", INT2FIX(0),
#endif
@@ -721,7 +721,7 @@ Sfile_type(obj, fname)
t = "directory";
} else if (S_ISCHR(st.st_mode)) {
t = "characterSpecial";
- }
+ }
#ifdef S_ISBLK
else if (S_ISBLK(st.st_mode)) {
t = "blockSpecial";
@@ -730,7 +730,7 @@ Sfile_type(obj, fname)
#ifndef S_ISFIFO
else if (S_ISFIFO(st.st_mode)) {
t = "fifo";
- }
+ }
#endif
#ifdef S_ISLNK
else if (S_ISLNK(st.st_mode)) {
diff --git a/gc.c b/gc.c
index af6741f6ca..ec07c0fa95 100644
--- a/gc.c
+++ b/gc.c
@@ -3,7 +3,7 @@
gc.c -
$Author: matz $
- $Date: 1995/01/10 10:42:37 $
+ $Date: 1995/01/12 08:54:47 $
created at: Tue Oct 5 09:44:46 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
@@ -164,7 +164,7 @@ rb_global_variable(var)
Global_List = tmp;
}
-struct RVALUE {
+typedef struct RVALUE {
union {
struct {
UINT flag; /* always 0 for freed obj */
@@ -185,50 +185,53 @@ struct RVALUE {
struct RCons cons;
struct SCOPE scope;
} as;
-} *freelist = Qnil;
+} RVALUE;
-struct heap_block {
- struct heap_block *next;
- struct RVALUE *beg;
- struct RVALUE *end;
- struct RVALUE body[1];
-} *heap_link = Qnil;
+RVALUE *freelist = Qnil;
-#define SEG_SLOTS 10000
-#define SEG_SIZE (SEG_SLOTS*sizeof(struct RVALUE))
+#define HEAPS_INCREMENT 10
+static RVALUE **heaps;
+static int heaps_length = 0;
+static int heaps_used = 0;
+
+#define HEAP_SLOTS 10000
#define FREE_MIN 512
static void
add_heap()
{
- struct heap_block *block;
- struct RVALUE *p, *pend;
-
- block = (struct heap_block*)malloc(sizeof(*block) + SEG_SIZE);
- if (block == Qnil) Fatal("can't alloc memory");
- block->next = heap_link;
- block->beg = &block->body[0];
- block->end = block->beg + SEG_SLOTS;
- p = block->beg; pend = block->end;
+ RVALUE *p, *pend;
+
+ if (heaps_used == heaps_length) {
+ /* Realloc heaps */
+ heaps_length += HEAPS_INCREMENT;
+ heaps = (heaps_used)?
+ (RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE)):
+ (RVALUE**)malloc(heaps_length*sizeof(RVALUE));
+ if (heaps == Qnil) Fatal("can't alloc memory");
+ }
+
+ p = heaps[heaps_used++] = (RVALUE*)malloc(sizeof(RVALUE)*HEAP_SLOTS);
+ if (p == Qnil) Fatal("can't alloc memory");
+ pend = p + HEAP_SLOTS;
+
while (p < pend) {
p->as.free.flag = 0;
p->as.free.next = freelist;
freelist = p;
p++;
}
- heap_link = block;
}
struct RBasic *
newobj()
{
struct RBasic *obj;
- if (heap_link == Qnil) add_heap();
if (freelist) {
retry:
obj = (struct RBasic*)freelist;
freelist = freelist->as.free.next;
- memset(obj, 0, sizeof(struct RVALUE));
+ memset(obj, 0, sizeof(RVALUE));
return obj;
}
if (dont_gc) add_heap();
@@ -259,16 +262,17 @@ static VALUE *stack_start_ptr;
static long
looks_pointerp(p)
- struct RVALUE *p;
+ register RVALUE *p;
{
- struct heap_block *heap = heap_link;
-
- if (FIXNUM_P(p)) return FALSE;
- while (heap) {
- if (heap->beg <= p && p < heap->end
- && ((((char*)p)-((char*)heap->beg))%sizeof(struct RVALUE)) == 0)
+ register RVALUE *heap_org;
+ register long i, j, n;
+
+ /* if p looks as a SCM pointer mark location */
+ for (i=0; i < heaps_used; i++) {
+ heap_org = heaps[i];
+ if (heap_org <= p && p < heap_org + HEAP_SLOTS
+ && ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0)
return TRUE;
- heap = heap->next;
}
return FALSE;
}
@@ -349,11 +353,13 @@ gc_mark_maybe(obj)
void
gc_mark(obj)
- register struct RVALUE *obj;
+ register RVALUE *obj;
{
- if (obj == Qnil) return;
- if (FIXNUM_P(obj)) return;
- if (obj->as.basic.flags & FL_MARK) return;
+ Top:
+ if (obj == Qnil) return; /* nil not marked */
+ if (FIXNUM_P(obj)) return; /* fixnum not marked */
+ if (obj->as.basic.flags == 0) return; /* free cell */
+ if (obj->as.basic.flags & FL_MARK) return; /* marked */
obj->as.basic.flags |= FL_MARK;
@@ -362,21 +368,34 @@ gc_mark(obj)
case T_FIXNUM:
Bug("gc_mark() called for broken object");
break;
+
+ case T_NODE:
+ if (looks_pointerp(obj->as.node.u1.node)) {
+ gc_mark(obj->as.node.u1.node);
+ }
+ if (looks_pointerp(obj->as.node.u2.node)) {
+ gc_mark(obj->as.node.u2.node);
+ }
+ if (looks_pointerp(obj->as.node.u3.node)) {
+ obj = (RVALUE*)obj->as.node.u3.node;
+ goto Top;
+ }
+ return; /* no need to mark class. */
}
+ gc_mark(obj->as.basic.class);
switch (obj->as.basic.flags & T_MASK) {
case T_ICLASS:
gc_mark(obj->as.class.super);
- if (obj->as.class.c_tbl) mark_tbl(obj->as.class.c_tbl);
+ if (obj->as.class.iv_tbl) mark_tbl(obj->as.class.iv_tbl);
mark_tbl(obj->as.class.m_tbl);
break;
case T_CLASS:
gc_mark(obj->as.class.super);
case T_MODULE:
- if (obj->as.class.c_tbl) mark_tbl(obj->as.class.c_tbl);
mark_tbl(obj->as.class.m_tbl);
- gc_mark(obj->as.basic.class);
+ if (obj->as.class.iv_tbl) mark_tbl(obj->as.class.iv_tbl);
break;
case T_ARRAY:
@@ -402,6 +421,9 @@ gc_mark(obj)
break;
case T_OBJECT:
+ if (obj->as.object.iv_tbl) mark_tbl(obj->as.object.iv_tbl);
+ break;
+
case T_REGEXP:
case T_FLOAT:
case T_BIGNUM:
@@ -427,20 +449,12 @@ gc_mark(obj)
case T_CONS:
gc_mark(obj->as.cons.car);
- gc_mark(obj->as.cons.cdr);
- break;
-
- case T_NODE:
- gc_mark_maybe(obj->as.node.u1.node);
- gc_mark_maybe(obj->as.node.u2.node);
- gc_mark_maybe(obj->as.node.u3.node);
- return; /* no need to mark class & tbl */
+ obj = (RVALUE*)obj->as.cons.cdr;
+ goto Top;
default:
Bug("gc_mark(): unknown data type %d", obj->as.basic.flags & T_MASK);
}
- if (obj->as.basic.iv_tbl) mark_tbl(obj->as.basic.iv_tbl);
- gc_mark(obj->as.basic.class);
}
#define MIN_FREE_OBJ 512
@@ -450,19 +464,19 @@ static void obj_free();
static void
gc_sweep()
{
- struct heap_block *heap = heap_link;
int freed = 0;
+ int i;
freelist = Qnil;
- while (heap) {
- struct RVALUE *p, *pend;
- struct RVALUE *nfreelist;
+ for (i = 0; i < heaps_used; i++) {
+ RVALUE *p, *pend;
+ RVALUE *nfreelist;
int n = 0;
nfreelist = freelist;
- p = heap->beg; pend = heap->end;
+ p = heaps[i]; pend = p + HEAP_SLOTS;
+
while (p < pend) {
-
if (!(p->as.basic.flags & FL_MARK)) {
if (p->as.basic.flags) obj_free(p);
p->as.free.flag = 0;
@@ -470,31 +484,12 @@ gc_sweep()
nfreelist = p;
n++;
}
- RBASIC(p)->flags &= ~FL_MARK;
+ else
+ RBASIC(p)->flags &= ~FL_MARK;
p++;
}
- if (n == SEG_SLOTS) {
- struct heap_block *link = heap_link;
- if (heap != link) {
- while (link) {
- if (link->next && link->next == heap) {
- link->next = heap->next;
- break;
- }
- link = link->next;
- }
- if (link == Qnil) {
- Bug("non-existing heap at 0x%x", heap);
- }
- }
- free(heap);
- heap = link;
- }
- else {
- freed += n;
- freelist = nfreelist;
- }
- heap = heap->next;
+ freed += n;
+ freelist = nfreelist;
}
if (freed < FREE_MIN) {
add_heap();
@@ -503,7 +498,7 @@ gc_sweep()
static void
obj_free(obj)
- struct RVALUE *obj;
+ RVALUE *obj;
{
switch (obj->as.basic.flags & T_MASK) {
case T_NIL:
@@ -514,13 +509,13 @@ obj_free(obj)
switch (obj->as.basic.flags & T_MASK) {
case T_OBJECT:
+ if (obj->as.object.iv_tbl) st_free_table(obj->as.object.iv_tbl);
break;
case T_MODULE:
case T_CLASS:
rb_clear_cache2(obj);
st_free_table(obj->as.class.m_tbl);
- if (obj->as.class.c_tbl)
- st_free_table(obj->as.class.c_tbl);
+ if (obj->as.object.iv_tbl) st_free_table(obj->as.object.iv_tbl);
break;
case T_STRING:
if (obj->as.string.orig == Qnil) free(obj->as.string.ptr);
@@ -570,7 +565,6 @@ obj_free(obj)
default:
Bug("gc_sweep(): unknown data type %d", obj->as.basic.flags & T_MASK);
}
- if (obj->as.basic.iv_tbl) st_free_table(obj->as.basic.iv_tbl);
}
void
@@ -626,13 +620,21 @@ gc()
dont_gc--;
}
-Init_stack()
+void
+init_stack()
{
VALUE start;
stack_start_ptr = &start;
}
+void
+init_heap()
+{
+ init_stack();
+ add_heap();
+}
+
Init_GC()
{
M_GC = rb_define_module("GC");
diff --git a/getopt1.c b/getopt1.c
index 7f824232d7..7a2bbae344 100644
--- a/getopt1.c
+++ b/getopt1.c
@@ -56,7 +56,7 @@ getopt_long (argc, argv, options, long_options, opt_index)
but does match a short option, it is parsed as a short option
instead. */
-int
+int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
diff --git a/io.c b/io.c
index c0f246b60c..288e86d4d9 100644
--- a/io.c
+++ b/io.c
@@ -802,7 +802,7 @@ next_argv()
next_p = 0;
if (RARRAY(Argv)->len > 0) {
filename = ary_shift(Argv);
- fn = RSTRING(filename)->ptr;
+ fn = RSTRING(filename)->ptr;
if (RSTRING(filename)->len == 1 && fn[0] == '-') {
file = rb_stdin;
if (inplace) {
@@ -938,12 +938,12 @@ struct timeval *time_timeval();
#ifdef STDSTDIO
# define READ_PENDING(fp) ((fp)->_cnt != 0)
-#else
+#else
# ifdef __SLBF
# define READ_PENDING(fp) ((fp)->_r > 0)
# else
# ifdef __linux__
-# ifdef _other_gbase
+# ifdef _other_gbase
# define READ_PENDING(fp) ((fp)->_IO_read_ptr < (fp)->_IO_read_end)
# else
# define READ_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
@@ -1009,7 +1009,7 @@ Fselect(argc, argv, obj)
FD_SET(fileno(fptr->f), wp);
if (max > fileno(fptr->f)) max = fileno(fptr->f);
if (fptr->f2) {
- FD_SET(fileno(fptr->f2), wp);
+ FD_SET(fileno(fptr->f2), wp);
if (max < fileno(fptr->f2)) max = fileno(fptr->f2);
}
}
@@ -1026,7 +1026,7 @@ Fselect(argc, argv, obj)
FD_SET(fileno(fptr->f), ep);
if (max < fileno(fptr->f)) max = fileno(fptr->f);
if (fptr->f2) {
- FD_SET(fileno(fptr->f2), ep);
+ FD_SET(fileno(fptr->f2), ep);
if (max > fileno(fptr->f2)) max = fileno(fptr->f2);
}
}
diff --git a/missing/MANIFEST b/missing/MANIFEST
new file mode 100644
index 0000000000..52640c2720
--- /dev/null
+++ b/missing/MANIFEST
@@ -0,0 +1,10 @@
+MANIFEST
+alloca.c
+memmove.c
+mkdir.c
+strdup.c
+strerror.c
+strftime.c
+strstr.c
+strtol.c
+strtoul.c
diff --git a/node.h b/node.h
index 9322417fa2..8137995d71 100644
--- a/node.h
+++ b/node.h
@@ -24,12 +24,12 @@ enum node_type {
NODE_WHEN,
NODE_WHILE,
NODE_WHILE2,
- NODE_EXNOT,
NODE_ITER,
NODE_FOR,
NODE_PROT,
NODE_AND,
NODE_OR,
+ NODE_NOT,
NODE_MASGN,
NODE_LASGN,
NODE_GASGN,
@@ -181,13 +181,10 @@ typedef struct RNode {
#define NEW_BLOCK(a) newnode(NODE_BLOCK,a,1,Qnil)
#define NEW_IF(c,t,e) newnode(NODE_IF,c,t,e)
#define NEW_EXNOT(c) newnode(NODE_EXNOT,c,Qnil,Qnil)
-#define NEW_UNLESS(c,t,e) newnode(NODE_IF,NEW_EXNOT(c),t,e)
#define NEW_CASE(h,b) newnode(NODE_CASE,h,b,Qnil)
#define NEW_WHEN(c,t,e) newnode(NODE_WHEN,c,t,e)
#define NEW_WHILE(c,b) newnode(NODE_WHILE,c,b,Qnil)
-#define NEW_UNTIL(c,b) newnode(NODE_WHILE,NEW_EXNOT(c),b,Qnil)
#define NEW_WHILE2(c,b) newnode(NODE_WHILE2,c,b,Qnil)
-#define NEW_UNTIL2(c,b) newnode(NODE_WHILE2,NEW_EXNOT(c),b,Qnil)
#define NEW_FOR(v,i,b) newnode(NODE_FOR,v,b,i)
#define NEW_ITER(v,i,b) newnode(NODE_ITER,v,b,i)
#define NEW_PROT(b,ex,en) newnode(NODE_PROT,b,ex,en)
@@ -204,6 +201,7 @@ typedef struct RNode {
#define NEW_HASH(a) newnode(NODE_HASH,a,Qnil,Qnil)
#define NEW_AND(a,b) newnode(NODE_AND,a,b,Qnil)
#define NEW_OR(a,b) newnode(NODE_OR,a,b,Qnil)
+#define NEW_NOT(a) newnode(NODE_NOT,Qnil,a,Qnil)
#define NEW_MASGN(l,r) newnode(NODE_MASGN,l,r,Qnil)
#define NEW_GASGN(v,val) newnode(NODE_GASGN,v,val,rb_global_entry(v))
#define NEW_LASGN(v,val) newnode(NODE_LASGN,v,val,local_cnt(v))
diff --git a/numeric.c b/numeric.c
index 5b88a35454..cab3c69db3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -332,7 +332,7 @@ static VALUE
Fflo_eq(x, y)
struct RFloat *x, *y;
{
- switch (TYPE(y)) {
+ switch (TYPE(y)) {
case T_NIL:
return Qnil;
case T_FIXNUM:
@@ -676,7 +676,7 @@ Ffix_equal(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
- return (FIX2INT(x) == FIX2INT(y))?TRUE:FALSE;
+ return (FIX2INT(x) == FIX2INT(y))?TRUE:FALSE;
}
else if (NIL_P(y)) {
return Qnil;
@@ -692,7 +692,7 @@ Ffix_cmp(x, y)
{
if (FIXNUM_P(y)) {
int a = FIX2INT(x), b = FIX2INT(y);
-
+
if (a == b) return INT2FIX(0);
if (a > b) return INT2FIX(1);
return INT2FIX(-1);
@@ -708,7 +708,7 @@ Ffix_gt(x, y)
{
if (FIXNUM_P(y)) {
int a = FIX2INT(x), b = FIX2INT(y);
-
+
if (a > b) return TRUE;
return FALSE;
}
@@ -723,7 +723,7 @@ Ffix_ge(x, y)
{
if (FIXNUM_P(y)) {
int a = FIX2INT(x), b = FIX2INT(y);
-
+
if (a >= b) return TRUE;
return FALSE;
}
@@ -738,7 +738,7 @@ Ffix_lt(x, y)
{
if (FIXNUM_P(y)) {
int a = FIX2INT(x), b = FIX2INT(y);
-
+
if (a < b) return TRUE;
return FALSE;
}
@@ -753,7 +753,7 @@ Ffix_le(x, y)
{
if (FIXNUM_P(y)) {
int a = FIX2INT(x), b = FIX2INT(y);
-
+
if (a <= b) return TRUE;
return FALSE;
}
diff --git a/object.c b/object.c
index e71043fdde..a35e683cdd 100644
--- a/object.c
+++ b/object.c
@@ -3,7 +3,7 @@
object.c -
$Author: matz $
- $Date: 1995/01/10 10:42:44 $
+ $Date: 1995/01/12 08:54:49 $
created at: Thu Jul 15 12:01:24 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
@@ -12,7 +12,6 @@
#include "ruby.h"
#include "env.h"
-#include "node.h"
#include "st.h"
#include <stdio.h>
@@ -31,6 +30,7 @@ VALUE obj_responds_to();
VALUE obj_alloc();
static ID eq, match;
+static ID init_object;
static VALUE
P_true(obj)
@@ -76,26 +76,6 @@ Fkrn_id(obj)
}
static VALUE
-Fkrn_noteq(obj, other)
- VALUE obj, other;
-{
- if (rb_equal(obj, other)) {
- return FALSE;
- }
- return TRUE;
-}
-
-static VALUE
-Fkrn_nmatch(obj, other)
- VALUE obj, other;
-{
- if (rb_funcall(obj, match, 1, other)) {
- return FALSE;
- }
- return TRUE;
-}
-
-static VALUE
Fkrn_class(obj)
struct RBasic *obj;
{
@@ -145,7 +125,7 @@ obj_inspect(id, value, str)
static VALUE
Fobj_inspect(obj)
- struct RBasic *obj;
+ struct RObject *obj;
{
VALUE str;
char buf[256];
@@ -212,8 +192,8 @@ Fobj_clone(obj)
Check_Type(obj, T_OBJECT);
clone = obj_alloc(RBASIC(obj)->class);
- if (RBASIC(obj)->iv_tbl) {
- RBASIC(clone)->iv_tbl = st_copy(RBASIC(obj)->iv_tbl);
+ if (ROBJECT(obj)->iv_tbl) {
+ ROBJECT(clone)->iv_tbl = st_copy(ROBJECT(obj)->iv_tbl);
}
RBASIC(clone)->class = single_class_clone(RBASIC(obj)->class);
@@ -221,6 +201,13 @@ Fobj_clone(obj)
}
static VALUE
+Fobj_init_object(obj)
+ VALUE obj;
+{
+ return Qnil;
+}
+
+static VALUE
Fnil_to_s(obj)
VALUE obj;
{
@@ -282,7 +269,10 @@ Fcls_new(argc, argv, class)
VALUE *argv;
VALUE class;
{
- return obj_alloc(class);
+ VALUE obj = obj_alloc(class);
+
+ rb_funcall2(obj, init_object, argc, argv);
+ return obj;
}
static VALUE
@@ -377,6 +367,13 @@ Fdo()
return rb_yield(Qnil);
}
+Fforever()
+{
+ for (;;) {
+ rb_yield(Qnil);
+ }
+}
+
VALUE TopSelf;
VALUE TRUE = 1;
@@ -424,16 +421,14 @@ Init_Object()
* + All metaclasses are instances of the class `Class'.
*/
+
rb_define_method(C_Kernel, "is_nil", P_false, 0);
- rb_define_method(C_Kernel, "!", P_false, 0);
rb_define_method(C_Kernel, "==", Fkrn_equal, 1);
rb_define_alias(C_Kernel, "equal", "==");
rb_define_method(C_Kernel, "hash", Fkrn_id, 0);
rb_define_method(C_Kernel, "id", Fkrn_id, 0);
rb_define_method(C_Kernel, "class", Fkrn_class, 0);
- rb_define_method(C_Kernel, "!=", Fkrn_noteq, 1);
rb_define_alias(C_Kernel, "=~", "==");
- rb_define_method(C_Kernel, "!~", Fkrn_nmatch, 1);
rb_define_method(C_Kernel, "to_a", Fkrn_to_a, 0);
rb_define_method(C_Kernel, "to_s", Fkrn_to_s, 0);
@@ -443,8 +438,11 @@ Init_Object()
rb_define_alias(C_Kernel, "format", "sprintf");
rb_define_private_method(C_Kernel, "do", Fdo, 0);
+ rb_define_private_method(C_Kernel, "forever", Fforever, 0);
- rb_define_method(C_Object, "_inspect", Fobj_inspect, 0);
+ rb_define_private_method(C_Object, "init_object", Fobj_init_object, -1);
+
+ rb_define_method(C_Object, "clone", Fobj_clone, 0);
rb_define_method(C_Object, "responds_to", obj_responds_to, 1);
rb_define_method(C_Object, "is_member_of", obj_is_member_of, 1);
@@ -465,7 +463,6 @@ Init_Object()
rb_define_method(C_Nil, "class", Fnil_class, 0);
rb_define_method(C_Nil, "is_nil", P_true, 0);
- rb_define_method(C_Nil, "!", P_true, 0);
/* default addition */
rb_define_method(C_Nil, "+", Fnil_plus, 1);
@@ -475,7 +472,6 @@ Init_Object()
rb_define_method(C_Data, "class", Fdata_class, 0);
eq = rb_intern("==");
- match = rb_intern("=~");
Qself = TopSelf = obj_alloc(C_Object);
rb_define_single_method(TopSelf, "to_s", Fmain_to_s, 0);
@@ -484,5 +480,6 @@ Init_Object()
rb_define_single_method(TRUE, "to_s", Ftrue_to_s, 0);
rb_define_const(C_Kernel, "%TRUE", TRUE);
rb_define_const(C_Kernel, "%FALSE", FALSE);
-}
+ init_object = rb_intern("init_object");
+}
diff --git a/parse.y b/parse.y
index c4148d88d3..7c84221c8c 100644
--- a/parse.y
+++ b/parse.y
@@ -3,7 +3,7 @@
parse.y -
$Author: matz $
- $Date: 1995/01/10 10:42:45 $
+ $Date: 1995/01/12 08:54:50 $
created at: Fri May 28 18:02:42 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
@@ -50,7 +50,7 @@ static enum lex_state {
static ID cur_class = Qnil, cur_mid = Qnil;
static int in_module, in_single;
-static void value_expr();
+static int value_expr();
static NODE *cond();
static NODE *cond2();
@@ -96,8 +96,6 @@ static void setup_top_local();
ELSE
CASE
WHEN
- UNLESS
- UNTIL
WHILE
FOR
IN
@@ -120,9 +118,7 @@ static void setup_top_local();
_FILE_
_LINE_
IF_MOD
- UNLESS_MOD
WHILE_MOD
- UNTIL_MOD
ALIAS
%token <id> IDENTIFIER GVAR IVAR CONSTANT
@@ -131,14 +127,14 @@ static void setup_top_local();
%type <node> singleton inc_list
%type <val> literal numeric
-%type <node> compstmts stmts stmt stmt0 expr expr0 var_ref
+%type <node> compexpr exprs expr arg primary var_ref
%type <node> if_tail opt_else case_body cases resque ensure
-%type <node> call_args call_args0 args args2 array
+%type <node> call_args call_args0 args args2 opt_args
%type <node> f_arglist f_args assoc_list assocs assoc
%type <node> mlhs mlhs_head mlhs_tail lhs iter_var opt_iter_var
%type <id> superclass variable symbol
%type <id> fname op rest_arg
-%type <num> f_arg
+%type <num> f_arg
%token UPLUS /* unary+ */
%token UMINUS /* unary- */
%token POW /* ** */
@@ -156,11 +152,13 @@ static void setup_top_local();
%token <id> OP_ASGN /* +=, -= etc. */
%token ASSOC /* => */
%token LPAREN LBRACK LBRACE
+%token SYMBEG
/*
* precedence table
*/
+%left IF_MOD WHILE_MOD
%left OR
%left AND
%left YIELD RETURN FAIL
@@ -186,91 +184,74 @@ program : {
lex_state = EXPR_BEG;
init_top_local();
}
- compstmts
+ compexpr
{
eval_tree = block_append(eval_tree, $2);
setup_top_local();
}
-compstmts : stmts opt_term
+compexpr : exprs opt_term
-stmts : /* none */
+exprs : /* none */
{
$$ = Qnil;
}
- | stmt
- | stmts term stmt
+ | expr
+ | exprs term expr
{
$$ = block_append($1, $3);
}
- | stmts error
+ | exprs error
{
lex_state = EXPR_BEG;
}
- stmt
+ expr
{
yyerrok;
$$ = block_append($1, $4);
}
-stmt : CLASS IDENTIFIER superclass
+expr : mlhs '=' args2
{
- if (cur_class || cur_mid || in_single)
- Error("nested class definition");
- cur_class = $2;
- push_local();
+ value_expr($3);
+ $1->nd_value = $3;
+ $$ = $1;
}
- compstmts
- END
+ | assocs
{
- $$ = NEW_CLASS($2, $5, $3);
- pop_local();
- cur_class = Qnil;
+ $$ = NEW_HASH($1);
}
- | MODULE IDENTIFIER
+ | RETURN args2
{
- if (cur_class != Qnil)
- Error("nested module definition");
- cur_class = $2;
- in_module = 1;
- push_local();
+ value_expr($2);
+ if (!cur_mid && !in_single)
+ Error("return appeared outside of method");
+ $$ = NEW_RET($2);
}
- compstmts
- END
+ | FAIL args2
{
- $$ = NEW_MODULE($2, $4);
- pop_local();
- cur_class = Qnil;
- in_module = 0;
+ value_expr($2);
+ $$ = NEW_FAIL($2);
}
- | DEF fname
+ | YIELD args2
{
- if (cur_mid || in_single)
- Error("nested method definition");
- cur_mid = $2;
- push_local();
+ value_expr($2);
+ $$ = NEW_YIELD($2);
}
- f_arglist
- compstmts
- END
+ | IDENTIFIER call_args0
{
- $$ = NEW_DEFN($2, NEW_RFUNC($4, $5), cur_class?0:1);
- pop_local();
- cur_mid = Qnil;
+ $$ = NEW_CALL(Qnil, $1, $2);
}
- | DEF singleton '.' fname
+ | primary '.' IDENTIFIER call_args0
{
- value_expr($2);
- in_single++;
- push_local();
+ value_expr($1);
+ $$ = NEW_CALL($1, $3, $4);
}
- f_arglist
- compstmts
- END
+ | SUPER call_args0
{
- $$ = NEW_DEFS($2, $4, NEW_RFUNC($6, $7));
- pop_local();
- in_single--;
+ if (!cur_mid && !in_single)
+ Error("super called outside of method");
+ $$ = NEW_SUPER($2);
}
| UNDEF fname
{
@@ -286,100 +267,31 @@ stmt : CLASS IDENTIFIER superclass
Error("include appeared in method definition");
$$ = $2;
}
- | stmt0 IF_MOD stmt0
+ | expr IF_MOD expr
{
$$ = NEW_IF(cond($3), $1, Qnil);
}
- | stmt0 UNLESS_MOD stmt0
- {
- $$ = NEW_UNLESS(cond($3), $1, Qnil);
- }
- | stmt0 WHILE_MOD stmt0
+ | expr WHILE_MOD expr
{
$$ = NEW_WHILE2(cond($3), $1);
}
- | stmt0 UNTIL_MOD stmt0
- {
- $$ = NEW_UNTIL2(cond($3), $1);
- }
- | stmt AND stmt
+ | expr AND expr
{
$$ = NEW_AND(cond($1), cond($3));
}
- | stmt OR stmt
+ | expr OR expr
{
$$ = NEW_OR(cond($1), cond($3));
}
- | stmt0
-
-stmt0 : mlhs '=' args2
- {
- $1->nd_value = $3;
- $$ = $1;
- }
- | REDO
- {
- $$ = NEW_REDO();
- }
- | BREAK
- {
- $$ = NEW_BREAK();
- }
- | CONTINUE
- {
- $$ = NEW_CONT();
- }
- | RETRY
- {
- $$ = NEW_RETRY();
- }
- | RETURN args2
- {
- value_expr($2);
- if (!cur_mid && !in_single)
- Error("return appeared outside of method");
- $$ = NEW_RET($2);
- }
- | RETURN
- {
- if (!cur_mid && !in_single)
- Error("return appeared outside of method");
- $$ = NEW_RET(Qnil);
- }
- | FAIL args2
- {
- value_expr($2);
- $$ = NEW_FAIL($2);
- }
- | YIELD args2
- {
- value_expr($2);
- $$ = NEW_YIELD($2);
- }
- | IDENTIFIER call_args0
- {
- $$ = NEW_CALL(Qnil, $1, $2);
- }
- | expr0 '.' IDENTIFIER call_args0
- {
- value_expr($1);
- $$ = NEW_CALL($1, $3, $4);
- }
- | SUPER call_args0
- {
- if (!cur_mid && !in_single)
- Error("super called outside of method");
- $$ = NEW_SUPER($2);
- }
- | expr
+ | arg
mlhs : mlhs_head
{
- $$ = NEW_MASGN(NEW_LIST($1),Qnil);
+ $$ = NEW_MASGN(NEW_LIST($1), Qnil);
}
| mlhs_head '*' lhs
{
- $$ = NEW_MASGN(NEW_LIST($1),$3);
+ $$ = NEW_MASGN(NEW_LIST($1), $3);
}
| mlhs_head mlhs_tail
{
@@ -390,18 +302,7 @@ mlhs : mlhs_head
$$ = NEW_MASGN(list_concat(NEW_LIST($1),$2),$5);
}
-mlhs_head : variable comma
- {
- $$ = asignable($1, Qnil);
- }
- | expr0 '[' args rbracket comma
- {
- $$ = aryset($1, $3, Qnil);
- }
- | expr0 '.' IDENTIFIER comma
- {
- $$ = attrset($1, $3, Qnil);
- }
+mlhs_head : lhs comma
mlhs_tail : lhs
{
@@ -416,24 +317,15 @@ lhs : variable
{
$$ = asignable($1, Qnil);
}
- | expr0 '[' args rbracket
+ | primary '[' opt_args rbracket
{
$$ = aryset($1, $3, Qnil);
}
- | expr0 '.' IDENTIFIER
+ | primary '.' IDENTIFIER
{
$$ = attrset($1, $3, Qnil);
}
-superclass : /* none */
- {
- $$ = Qnil;
- }
- | ':' IDENTIFIER
- {
- $$ = $2;
- }
-
inc_list : IDENTIFIER
{
$$ = NEW_INC($1);
@@ -467,9 +359,7 @@ op : COLON2 { $$ = COLON2; }
| '&' { $$ = '&'; }
| CMP { $$ = CMP; }
| EQ { $$ = EQ; }
- | NEQ { $$ = NEQ; }
| MATCH { $$ = MATCH; }
- | NMATCH { $$ = NMATCH; }
| '>' { $$ = '>'; }
| GEQ { $$ = GEQ; }
| '<' { $$ = '<'; }
@@ -482,119 +372,26 @@ op : COLON2 { $$ = COLON2; }
| '/' { $$ = '/'; }
| '%' { $$ = '%'; }
| POW { $$ = POW; }
- | '!' { $$ = '!'; }
| '~' { $$ = '~'; }
| UPLUS { $$ = UMINUS; }
| UMINUS { $$ = UPLUS; }
| AREF { $$ = AREF; }
| ASET { $$ = ASET; }
-f_arglist : '(' f_args rparen
- {
- $$ = $2;
- }
- | term
- {
- $$ = NEW_ARGS(0, -1);
- }
-
-f_args : /* no arg */
- {
- $$ = NEW_ARGS(0, -1);
- }
- | f_arg
- {
- $$ = NEW_ARGS($1, -1);
- }
- | f_arg comma rest_arg
- {
- $$ = NEW_ARGS($1, $3);
- }
- | rest_arg
- {
- $$ = NEW_ARGS(Qnil, $1);
- }
- | f_arg error
- {
- lex_state = EXPR_BEG;
- $$ = NEW_ARGS($1, -1);
- }
- | error
- {
- lex_state = EXPR_BEG;
- $$ = NEW_ARGS(0, -1);
- }
-
-f_arg : IDENTIFIER
- {
- if (!is_local_id($1))
- Error("formal argument must be local variable");
- local_cnt($1);
- $$ = 1;
- }
- | f_arg comma IDENTIFIER
- {
- if (!is_local_id($3))
- Error("formal argument must be local variable");
- local_cnt($3);
- $$ += 1;
- }
-
-rest_arg : '*' IDENTIFIER
- {
- if (!is_local_id($2))
- Error("rest argument must be local variable");
- $$ = local_cnt($2);
- }
-
-singleton : var_ref
- {
- if (nd_type($1) == NODE_SELF) {
- $$ = NEW_SELF();
- }
- else if (nd_type($1) == NODE_NIL) {
- Error("Can't define single method for nil.");
- $$ = Qnil;
- }
- else {
- $$ = $1;
- }
- }
- | LPAREN compstmts rparen
- {
- switch (nd_type($2)) {
- case NODE_STR:
- case NODE_STR2:
- case NODE_XSTR:
- case NODE_XSTR2:
- case NODE_DREGX:
- case NODE_DGLOB:
- case NODE_LIT:
- case NODE_ARRAY:
- case NODE_ZARRAY:
- Error("Can't define single method for literals.");
- default:
- break;
- }
- $$ = $2;
- }
-
-expr : variable '=' expr
+arg : variable '=' arg
{
value_expr($3);
$$ = asignable($1, $3);
}
- | expr0 '[' args rbracket '=' expr
+ | primary '[' opt_args rbracket '=' arg
{
- value_expr($6);
$$ = aryset($1, $3, $6);
}
- | expr0 '.' IDENTIFIER '=' expr
+ | primary '.' IDENTIFIER '=' arg
{
- value_expr($5);
$$ = attrset($1, $3, $5);
}
- | variable OP_ASGN expr
+ | variable OP_ASGN arg
{
NODE *val;
@@ -613,27 +410,31 @@ expr : variable '=' expr
}
$$ = asignable($1, call_op(val, $2, 1, $3));
}
- | expr0 '[' args rbracket OP_ASGN expr
+ | primary '[' opt_args rbracket OP_ASGN arg
{
- $$ = NEW_OP_ASGN1($1,$5,list_concat(NEW_LIST($6),$3));
+ NODE *args = NEW_LIST($6);
+
+ if ($3) list_concat(args, $3);
+ $$ = NEW_OP_ASGN1($1, $5, args);
}
- | expr0 '.' IDENTIFIER OP_ASGN expr
+ | primary '.' IDENTIFIER OP_ASGN arg
{
$$ = NEW_OP_ASGN2($1, $4, $5);
}
- | expr DOT2 expr
+ | arg DOT2 arg
{
$$ = call_op($1, DOT2, 1, $3);
}
- | expr DOT3 expr
+ | arg DOT3 arg
{
$$ = NEW_DOT3(cond2($1), cond2($3));
}
- | expr '+' expr
+ | arg '+' arg
{
$$ = Qnil;
if ($1 && $3
- && (nd_type($3) == NODE_LIT || nd_type($3) == NODE_STR)
+ && (nd_type($3) == NODE_LIT
+ || nd_type($3) == NODE_STR)
&& nd_type($1) == NODE_CALL && $1->nd_mid == '+') {
if ($1->nd_args->nd_head == Qnil)
Bug("bad operand for `+'");
@@ -648,87 +449,87 @@ expr : variable '=' expr
$$ = call_op($1, '+', 1, $3);
}
}
- | expr '-' expr
+ | arg '-' arg
{
$$ = call_op($1, '-', 1, $3);
}
- | expr '*' expr
+ | arg '*' arg
{
$$ = call_op($1, '*', 1, $3);
}
- | expr '/' expr
+ | arg '/' arg
{
$$ = call_op($1, '/', 1, $3);
}
- | expr '%' expr
+ | arg '%' arg
{
$$ = call_op($1, '%', 1, $3);
}
- | expr POW expr
+ | arg POW arg
{
$$ = call_op($1, POW, 1, $3);
}
- | UPLUS expr
+ | UPLUS arg
{
$$ = call_op($2, UPLUS, 0);
}
- | UMINUS expr
+ | UMINUS arg
{
$$ = call_op($2, UMINUS, 0);
}
- | expr '|' expr
+ | arg '|' arg
{
$$ = call_op($1, '|', 1, $3);
}
- | expr '^' expr
+ | arg '^' arg
{
$$ = call_op($1, '^', 1, $3);
}
- | expr '&' expr
+ | arg '&' arg
{
$$ = call_op($1, '&', 1, $3);
}
- | expr CMP expr
+ | arg CMP arg
{
$$ = call_op($1, CMP, 1, $3);
}
- | expr '>' expr
+ | arg '>' arg
{
$$ = call_op($1, '>', 1, $3);
}
- | expr GEQ expr
+ | arg GEQ arg
{
$$ = call_op($1, GEQ, 1, $3);
}
- | expr '<' expr
+ | arg '<' arg
{
$$ = call_op($1, '<', 1, $3);
}
- | expr LEQ expr
+ | arg LEQ arg
{
$$ = call_op($1, LEQ, 1, $3);
}
- | expr EQ expr
+ | arg EQ arg
{
$$ = call_op($1, EQ, 1, $3);
}
- | expr NEQ expr
+ | arg NEQ arg
{
- $$ = call_op($1, NEQ, 1, $3);
+ $$ = NEW_NOT(call_op($1, EQ, 1, $3));
}
- | expr MATCH expr
+ | arg MATCH arg
{
$$ = NEW_CALL($1, MATCH, NEW_LIST($3));
}
- | expr NMATCH expr
+ | arg NMATCH arg
{
- $$ = NEW_CALL($1, NMATCH, NEW_LIST($3));
+ $$ = NEW_NOT(NEW_CALL($1, MATCH, NEW_LIST($3)));
}
- | '!' expr
+ | '!' arg
{
- $$ = call_op($2, '!', 0);
+ $$ = NEW_NOT(cond($2));
}
- | '~' expr
+ | '~' arg
{
if ($2
&& (nd_type($2) == NODE_STR
@@ -741,27 +542,27 @@ expr : variable '=' expr
$$ = call_op($2, '~', 0);
}
}
- | expr LSHFT expr
+ | arg LSHFT arg
{
$$ = call_op($1, LSHFT, 1, $3);
}
- | expr RSHFT expr
+ | arg RSHFT arg
{
$$ = call_op($1, RSHFT, 1, $3);
}
- | expr COLON2 expr
+ | arg COLON2 arg
{
$$ = call_op($1, COLON2, 1, $3);
}
- | expr ANDOP expr
+ | arg ANDOP arg
{
$$ = NEW_AND(cond($1), cond($3));
}
- | expr OROP expr
+ | arg OROP arg
{
$$ = NEW_OR(cond($1), cond($3));
}
- |expr0
+ | primary
{
$$ = $1;
}
@@ -771,23 +572,37 @@ call_args : /* none */
$$ = Qnil;
}
| call_args0
- | '*' expr
+ | '*' arg
{
$$ = $2;
}
call_args0 : args
- | args comma '*' expr
+ | assocs
+ {
+ $$ = NEW_LIST(NEW_HASH($1));
+ }
+ | args comma assocs
+ {
+ $$ = list_append($1, NEW_HASH($3));
+ }
+ | args comma '*' arg
{
$$ = call_op($1, '+', 1, $4);
}
-args : expr
+opt_args : /* none */
+ {
+ $$ = Qnil;
+ }
+ | args
+
+args : arg
{
value_expr($1);
$$ = NEW_LIST($1);
}
- | args comma expr
+ | args comma arg
{
value_expr($3);
$$ = list_append($1, $3);
@@ -803,7 +618,7 @@ args2 : args
}
}
-expr0 : literal
+primary : literal
{
$$ = NEW_LIT($1);
}
@@ -820,10 +635,6 @@ expr0 : literal
| DREGEXP
| DGLOB
| var_ref
- | IDENTIFIER '(' call_args rparen
- {
- $$ = NEW_CALL(Qnil, $1, $3);
- }
| SUPER '(' call_args rparen
{
if (!cur_mid && !in_single)
@@ -836,13 +647,12 @@ expr0 : literal
Error("super called outside of method");
$$ = NEW_ZSUPER();
}
-
- | expr0 '[' args rbracket
+ | primary '[' opt_args rbracket
{
value_expr($1);
$$ = NEW_CALL($1, AREF, $3);
}
- | LBRACK array rbracket
+ | LBRACK opt_args rbracket
{
if ($2 == Qnil)
$$ = NEW_ZARRAY(); /* zero length array*/
@@ -854,8 +664,33 @@ expr0 : literal
{
$$ = NEW_HASH($2);
}
+ | REDO
+ {
+ $$ = NEW_REDO();
+ }
+ | BREAK
+ {
+ $$ = NEW_BREAK();
+ }
+ | CONTINUE
+ {
+ $$ = NEW_CONT();
+ }
+ | RETRY
+ {
+ $$ = NEW_RETRY();
+ }
+ | RETURN
+ {
+ if (!cur_mid && !in_single)
+ Error("return appeared outside of method");
+ $$ = NEW_RET(Qnil);
+ }
| FAIL '(' args2 ')'
{
+ if (nd_type($3) == NODE_ARRAY) {
+ Error("wrong number of argument to fail(0 or 1)");
+ }
value_expr($3);
$$ = NEW_FAIL($3);
}
@@ -880,7 +715,7 @@ expr0 : literal
{
$$ = NEW_YIELD(Qnil);
}
- | expr0 '{' opt_iter_var '|' compstmts rbrace
+ | primary '{' opt_iter_var '|' compexpr rbrace
{
if (nd_type($1) == NODE_LVAR
|| nd_type($1) == NODE_MVAR) {
@@ -888,52 +723,47 @@ expr0 : literal
}
$$ = NEW_ITER($3, $1, $5);
}
- | expr0 '.' IDENTIFIER '(' call_args rparen
+ | IDENTIFIER '(' call_args rparen
+ {
+ $$ = NEW_CALL(Qnil, $1, $3);
+ }
+ | primary '.' IDENTIFIER '(' call_args rparen
{
value_expr($1);
$$ = NEW_CALL($1, $3, $5);
}
- | expr0 '.' IDENTIFIER
+ | primary '.' IDENTIFIER
{
value_expr($1);
$$ = NEW_CALL($1, $3, Qnil);
}
- | IF stmt0 then
- compstmts
+ | IF expr then
+ compexpr
if_tail
END
{
$$ = NEW_IF(cond($2), $4, $5);
}
- | UNLESS stmt0 then
- compstmts opt_else END
- {
- $$ = NEW_UNLESS(cond($2), $4, $5);
- }
- | WHILE stmt0 term compstmts END
+ | WHILE expr term compexpr END
{
$$ = NEW_WHILE(cond($2), $4);
}
- | UNTIL stmt0 term compstmts END
- {
- $$ = NEW_UNTIL(cond($2), $4);
- }
- | CASE compstmts
+ | CASE compexpr
case_body
END
{
value_expr($2);
$$ = NEW_CASE($2, $3);
}
- | FOR iter_var IN stmt0 term
- compstmts
+ | FOR iter_var IN expr term
+ compexpr
END
{
value_expr($4);
$$ = NEW_FOR($2, $4, $6);
}
| PROTECT
- compstmts
+ compexpr
resque
ensure
END
@@ -946,18 +776,77 @@ expr0 : literal
$$ = NEW_PROT($2, $3, $4);
}
}
- | LPAREN compstmts rparen
+ | LPAREN compexpr rparen
{
$$ = $2;
}
+ | CLASS IDENTIFIER superclass
+ {
+ if (cur_class || cur_mid || in_single)
+ Error("nested class definition");
+ cur_class = $2;
+ push_local();
+ }
+ compexpr
+ END
+ {
+ $$ = NEW_CLASS($2, $5, $3);
+ pop_local();
+ cur_class = Qnil;
+ }
+ | MODULE IDENTIFIER
+ {
+ if (cur_class != Qnil)
+ Error("nested module definition");
+ cur_class = $2;
+ in_module = 1;
+ push_local();
+ }
+ compexpr
+ END
+ {
+ $$ = NEW_MODULE($2, $4);
+ pop_local();
+ cur_class = Qnil;
+ in_module = 0;
+ }
+ | DEF fname
+ {
+ if (cur_mid || in_single)
+ Error("nested method definition");
+ cur_mid = $2;
+ push_local();
+ }
+ f_arglist
+ compexpr
+ END
+ {
+ $$ = NEW_DEFN($2, NEW_RFUNC($4, $5), cur_class?0:1);
+ pop_local();
+ cur_mid = Qnil;
+ }
+ | DEF singleton '.' fname
+ {
+ value_expr($2);
+ in_single++;
+ push_local();
+ }
+ f_arglist
+ compexpr
+ END
+ {
+ $$ = NEW_DEFS($2, $4, NEW_RFUNC($6, $7));
+ pop_local();
+ in_single--;
+ }
then : term
| THEN
| term THEN
if_tail : opt_else
- | ELSIF stmt0 then
- compstmts
+ | ELSIF expr then
+ compexpr
if_tail
{
$$ = NEW_IF(cond($2), $4, $5);
@@ -967,7 +856,7 @@ opt_else : /* none */
{
$$ = Qnil;
}
- | ELSE compstmts
+ | ELSE compexpr
{
$$ = $2;
}
@@ -982,7 +871,7 @@ opt_iter_var : /* none */
| iter_var
case_body : WHEN args then
- compstmts
+ compexpr
cases
{
$$ = NEW_WHEN($2, $4, $5);
@@ -990,7 +879,7 @@ case_body : WHEN args then
cases : opt_else
| WHEN args then
- compstmts
+ compexpr
cases
{
$$ = NEW_WHEN($2, $4, $5);
@@ -1000,7 +889,7 @@ resque : /* none */
{
$$ = Qnil;
}
- | RESQUE compstmts
+ | RESQUE compexpr
{
if ($2 == Qnil)
$$ = (NODE*)1;
@@ -1012,26 +901,19 @@ ensure : /* none */
{
$$ = Qnil;
}
- | ENSURE compstmts
+ | ENSURE compexpr
{
$$ = $2;
}
-array : /* none */
- {
- $$ = Qnil;
- }
- | args
-
literal : numeric
- | '\\' symbol
+ | SYMBEG symbol
{
$$ = INT2FIX($2);
}
| REGEXP
| GLOB
-
symbol : fname
| IVAR
| GVAR
@@ -1058,11 +940,121 @@ var_ref : variable
$$ = gettable($1);
}
+superclass : term
+ {
+ $$ = Qnil;
+ }
+ | colon
+ {
+ lex_state = EXPR_BEG;
+ }
+ IDENTIFIER
+ {
+ $$ = $3;
+ }
+
+f_arglist : '(' f_args rparen
+ {
+ $$ = $2;
+ }
+ | term
+ {
+ $$ = NEW_ARGS(0, -1);
+ }
+
+f_args : /* no arg */
+ {
+ $$ = NEW_ARGS(0, -1);
+ }
+ | f_arg
+ {
+ $$ = NEW_ARGS($1, -1);
+ }
+ | f_arg comma rest_arg
+ {
+ $$ = NEW_ARGS($1, $3);
+ }
+ | rest_arg
+ {
+ $$ = NEW_ARGS(Qnil, $1);
+ }
+ | f_arg error
+ {
+ lex_state = EXPR_BEG;
+ $$ = NEW_ARGS($1, -1);
+ }
+ | error
+ {
+ lex_state = EXPR_BEG;
+ $$ = NEW_ARGS(0, -1);
+ }
+
+f_arg : IDENTIFIER
+ {
+ if (!is_local_id($1))
+ Error("formal argument must be local variable");
+ local_cnt($1);
+ $$ = 1;
+ }
+ | f_arg comma IDENTIFIER
+ {
+ if (!is_local_id($3))
+ Error("formal argument must be local variable");
+ local_cnt($3);
+ $$ += 1;
+ }
+
+rest_arg : '*' IDENTIFIER
+ {
+ if (!is_local_id($2))
+ Error("rest argument must be local variable");
+ $$ = local_cnt($2);
+ }
+
+singleton : var_ref
+ {
+ if (nd_type($1) == NODE_SELF) {
+ $$ = NEW_SELF();
+ }
+ else if (nd_type($1) == NODE_NIL) {
+ Error("Can't define single method for nil.");
+ $$ = Qnil;
+ }
+ else {
+ $$ = $1;
+ }
+ }
+ | LPAREN compexpr rparen
+ {
+ switch (nd_type($2)) {
+ case NODE_STR:
+ case NODE_STR2:
+ case NODE_XSTR:
+ case NODE_XSTR2:
+ case NODE_DREGX:
+ case NODE_DGLOB:
+ case NODE_LIT:
+ case NODE_ARRAY:
+ case NODE_ZARRAY:
+ Error("Can't define single method for literals.");
+ default:
+ break;
+ }
+ $$ = $2;
+ }
+
assoc_list : /* none */
{
$$ = Qnil;
}
| assocs
+ | args
+ {
+ if ($1->nd_alen%2 != 0) {
+ Error("odd number list for Dict");
+ }
+ $$ = $1;
+ }
assocs : assoc
| assocs comma assoc
@@ -1070,12 +1062,11 @@ assocs : assoc
$$ = list_concat($1, $3);
}
-assoc : expr ASSOC expr
+assoc : arg ASSOC arg
{
$$ = list_append(NEW_LIST($1), $3);
}
-
opt_term : /* none */
| term
@@ -1085,6 +1076,9 @@ term : sc
sc : ';' { yyerrok; }
nl : '\n' { yyerrok; }
+colon : ':'
+ | SYMBEG
+
rparen : ')' { yyerrok; }
rbracket : ']' { yyerrok; }
rbrace : '}' { yyerrok; }
@@ -1196,10 +1190,6 @@ parse_regx()
else if (in_brack && c == 'b') {
tokadd('\b');
}
- else if (isdigit(c)) {
- tokadd('\\');
- tokadd(c);
- }
else {
pushback();
read_escape(LEAVE_BS);
@@ -1348,8 +1338,6 @@ static struct kwtable {
"super", SUPER, EXPR_END,
"then", THEN, EXPR_BEG,
"undef", UNDEF, EXPR_FNAME,
- "unless", UNLESS, EXPR_BEG,
- "until", UNTIL, EXPR_BEG,
"when", WHEN, EXPR_BEG,
"while", WHILE, EXPR_BEG,
"yield", YIELD, EXPR_END,
@@ -1406,13 +1394,6 @@ retry:
return '*';
case '!':
- if (lex_state == EXPR_FNAME) {
- if ((c = nextc()) == '@') {
- lex_state = EXPR_BEG;
- return '!';
- }
- pushback();
- }
lex_state = EXPR_BEG;
if ((c = nextc()) == '=') {
return NEQ;
@@ -1737,12 +1718,15 @@ retry:
return c;
case ':':
- lex_state = EXPR_BEG;
- if (nextc() == ':') {
+ c = nextc();
+ if (c == ':') {
+ lex_state = EXPR_BEG;
return COLON2;
}
pushback();
- return ':';
+ if (isspace(c))
+ return ':';
+ return SYMBEG;
case '/':
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
@@ -1786,7 +1770,6 @@ retry:
return c;
case '[':
-
if (lex_state == EXPR_BEG || lex_state == EXPR_MID)
c = LBRACK;
else if (lex_state == EXPR_FNAME) {
@@ -1811,8 +1794,10 @@ retry:
case '\\':
c = nextc();
- if (c == '\n') goto retry; /* skip \\n */
- lex_state = EXPR_FNAME;
+ if (c == '\n') {
+ sourceline++;
+ goto retry; /* skip \\n */
+ }
pushback();
return '\\';
@@ -1910,9 +1895,7 @@ retry:
lex_state = mid->state;
if (state != EXPR_BEG) {
if (mid->id == IF) return IF_MOD;
- if (mid->id == UNLESS) return UNLESS_MOD;
if (mid->id == WHILE) return WHILE_MOD;
- if (mid->id == UNTIL) return UNTIL_MOD;
}
return mid->id;
}
@@ -2444,6 +2427,7 @@ aryset(recv, idx, val)
NODE *recv, *idx, *val;
{
value_expr(recv);
+ value_expr(val);
return NEW_CALL(recv, ASET, list_append(idx, val));
}
@@ -2453,18 +2437,19 @@ attrset(recv, id, val)
ID id;
{
value_expr(recv);
+ value_expr(val);
id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
- return NEW_CALL(recv, id, NEW_ARRAY(val));
+ return NEW_CALL(recv, id, NEW_LIST(val));
}
-static void
+static int
value_expr(node)
NODE *node;
{
- if (node == Qnil) return;
+ if (node == Qnil) return TRUE;
switch (nd_type(node)) {
case NODE_RETURN:
@@ -2472,25 +2457,29 @@ value_expr(node)
case NODE_BREAK:
case NODE_REDO:
case NODE_RETRY:
+ case NODE_FAIL:
case NODE_WHILE:
case NODE_WHILE2:
case NODE_INC:
case NODE_CLASS:
case NODE_MODULE:
+ case NODE_DEFN:
+ case NODE_DEFS:
Error("void value expression");
+ return FALSE;
break;
case NODE_BLOCK:
while (node->nd_next) {
node = node->nd_next;
}
- if (node) {
- value_expr(node->nd_head);
- }
- break;
+ return value_expr(node->nd_head);
+
+ case NODE_IF:
+ return value_expr(node->nd_body) && value_expr(node->nd_else);
default:
- break;
+ return TRUE;
}
}
@@ -2635,8 +2624,8 @@ init_top_local()
lvtbl->cnt = 0;
}
if (lvtbl->cnt > 0) {
- lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt);
- MEMCPY(lvtbl->tbl, the_scope->local_tbl, VALUE, lvtbl->cnt);
+ lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt+1);
+ MEMCPY(lvtbl->tbl, the_scope->local_tbl, ID, lvtbl->cnt);
}
else {
lvtbl->tbl = Qnil;
@@ -2892,7 +2881,7 @@ rb_class2name(class)
Fail("0x%x is not a class/module", class);
}
- if (FL_TEST(class, FL_SINGLE)) {
+ while (FL_TEST(class, FL_SINGLE)) {
class = (struct RClass*)class->super;
}
@@ -2906,3 +2895,23 @@ rb_class2name(class)
}
Bug("class 0x%x not named", class);
}
+
+static int
+const_check(id, val, class)
+ ID id;
+ VALUE val;
+ struct RClass *class;
+{
+ if (is_const_id(id) && rb_const_bound(class, id)) {
+ Warning("constant redefined for %s", rb_class2name(class));
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
+}
+
+void
+rb_const_check(class, module)
+ struct RClass *class, *module;
+{
+ st_foreach(module->iv_tbl, const_check, class);
+}
diff --git a/process.c b/process.c
index f6de89d855..e8bcaaa3a6 100644
--- a/process.c
+++ b/process.c
@@ -507,7 +507,7 @@ Init_process()
rb_define_module_function(M_Process, "getpriority", Fproc_getpriority, 2);
rb_define_module_function(M_Process, "setpriority", Fproc_setpriority, 3);
-
+
rb_define_const(M_Process, "%PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
rb_define_const(M_Process, "%PRIO_PGRP", INT2FIX(PRIO_PGRP));
rb_define_const(M_Process, "%PRIO_USER", INT2FIX(PRIO_USER));
diff --git a/range.c b/range.c
index 6274170522..97e68bdf80 100644
--- a/range.c
+++ b/range.c
@@ -15,7 +15,7 @@
VALUE M_Comparable;
VALUE C_Range;
-static ID next, eq;
+static ID next;
static VALUE
Srng_new(class, start, end)
@@ -156,6 +156,5 @@ Init_Range()
rb_define_method(C_Range, "end", Frng_end, 0);
rb_define_method(C_Range, "to_s", Frng_to_s, 0);
- eq = rb_intern("==");
next = rb_intern("next");
}
diff --git a/re.c b/re.c
index cdff895aa2..d631d0c165 100644
--- a/re.c
+++ b/re.c
@@ -76,7 +76,7 @@ str_cicmp(str1, str2)
len = min(str1->len, str2->len);
p1 = str1->ptr; p2 = str2->ptr;
-
+
for (i = 0; i < len; i++, p1++, p2++) {
if (casetable[*p1] != casetable[*p2])
return casetable[*p1] - casetable[*p2];
@@ -97,7 +97,7 @@ int len;
/* Build a copy of the string (in dest) with the
escaped characters translated, and generate the regex
- from that.
+ from that.
*/
rp = ALLOC(Regexp);
@@ -194,7 +194,7 @@ re_match_post()
struct match *match;
if (last_match.regs.start[0] == -1) return Qnil;
- return str_new(last_match.ptr+last_match.regs.end[0],
+ return str_new(last_match.ptr+last_match.regs.end[0],
last_match.len-last_match.regs.end[0]);
}
@@ -401,6 +401,36 @@ Sreg_new(argc, argv, self)
}
static VALUE
+Sreg_quote(re, str)
+ VALUE re;
+ struct RString *str;
+{
+ char *s, *send, *t;
+ char *tmp;
+
+ Check_Type(str, T_STRING);
+
+ tmp = ALLOCA_N(char, str->len*2);
+
+ s = str->ptr; send = s + str->len;
+ t = tmp;
+
+ for (; s != send; s++) {
+ if (*s == '[' || *s == ']'
+ || *s == '{' || *s == '}'
+ || *s == '(' || *s == ')'
+ || *s == '*' || *s == '.' || *s == '\\'
+ || *s == '?' || *s == '+'
+ || *s == '^' || *s == '$') {
+ *t++ = '\\';
+ }
+ *t++ = *s;
+ }
+
+ return str_new(tmp, t - tmp);
+}
+
+static VALUE
Freg_clone(re)
struct RRegexp *re;
{
@@ -549,6 +579,7 @@ Init_Regexp()
C_Regexp = rb_define_class("Regexp", C_Object);
rb_define_single_method(C_Regexp, "new", Sreg_new, -1);
rb_define_single_method(C_Regexp, "compile", Sreg_new, -1);
+ rb_define_single_method(C_Regexp, "quote", Sreg_quote, 1);
rb_define_method(C_Regexp, "=~", Freg_match, 1);
rb_define_method(C_Regexp, "~", Freg_match2, 0);
diff --git a/ruby.c b/ruby.c
index e22f0b15ce..8029a3e026 100644
--- a/ruby.c
+++ b/ruby.c
@@ -262,7 +262,7 @@ readin(fd, fname)
if (xflag) {
char *s = p;
- *pend = '\0';
+ *pend = '\0';
xflag = FALSE;
while (p < pend) {
while (s < pend && *s != '\n') s++;
diff --git a/ruby.h b/ruby.h
index 086c112084..b52bd3c46d 100644
--- a/ruby.h
+++ b/ruby.h
@@ -1,13 +1,13 @@
/************************************************
-
+
ruby.h -
-
+
$Author: matz $
- $Date: 1995/01/10 10:42:52 $
+ $Date: 1995/01/12 08:54:52 $
created at: Thu Jun 10 14:26:32 JST 1993
-
+
Copyright (C) 1994 Yukihiro Matsumoto
-
+
*************************************************/
#ifndef RUBY_H
@@ -100,13 +100,12 @@ extern VALUE C_Data;
#define T_DICT 0x0a
#define T_STRUCT 0x0b
#define T_BIGNUM 0x0c
-
-#define T_NODE 0x0d
-#define T_SCOPE 0x0e
#define T_CONS 0x0f
-
#define T_DATA 0x10
+#define T_SCOPE 0xfe
+#define T_NODE 0xff
+
#define T_MASK 0xff
#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
@@ -128,17 +127,17 @@ int num2int();
struct RBasic {
UINT flags;
VALUE class;
- struct st_table *iv_tbl;
};
struct RObject {
struct RBasic basic;
+ struct st_table *iv_tbl;
};
struct RClass {
struct RBasic basic;
+ struct st_table *iv_tbl;
struct st_table *m_tbl;
- struct st_table *c_tbl;
struct RClass *super;
};
@@ -181,7 +180,7 @@ struct RData {
#define DATA_PTR(dta) (RDATA(dta)->data)
-VALUE data_new();
+VALUE data_new();
VALUE rb_ivar_get_1();
VALUE rb_ivar_set_1();
@@ -222,6 +221,9 @@ struct RCons {
VALUE car, cdr;
};
+#define CAR(c) (RCONS(c)->car)
+#define CDR(c) (RCONS(c)->cdr)
+
#define R_CAST(st) (struct st*)
#define RBASIC(obj) (R_CAST(RBasic)(obj))
#define ROBJECT(obj) (R_CAST(RObject)(obj))
@@ -291,7 +293,9 @@ void rb_define_attr();
ID rb_intern();
char *rb_id2name();
+VALUE rb_eval_string();
VALUE rb_funcall();
+VALUE rb_funcall2();
int rb_scan_args();
VALUE rb_yield();
diff --git a/sample/Artistic b/sample/Artistic
new file mode 100644
index 0000000000..fbf7989775
--- /dev/null
+++ b/sample/Artistic
@@ -0,0 +1,117 @@
+
+
+
+
+ The "Artistic License"
+
+ Preamble
+
+The intent of this document is to state the conditions under which a
+Package may be copied, such that the Copyright Holder maintains some
+semblance of artistic control over the development of the package,
+while giving the users of the package the right to use and distribute
+the Package in a more-or-less customary fashion, plus the right to make
+reasonable modifications.
+
+Definitions:
+
+ "Package" refers to the collection of files distributed by the
+ Copyright Holder, and derivatives of that collection of files
+ created through textual modification.
+
+ "Standard Version" refers to such a Package if it has not been
+ modified, or has been modified in accordance with the wishes
+ of the Copyright Holder.
+
+ "Copyright Holder" is whoever is named in the copyright or
+ copyrights for the package.
+
+ "You" is you, if you're thinking about copying or distributing
+ this Package.
+
+ "Reasonable copying fee" is whatever you can justify on the
+ basis of media cost, duplication charges, time of people involved,
+ and so on. (You will not be required to justify it to the
+ Copyright Holder, but only to the computing community at large
+ as a market that must bear the fee.)
+
+ "Freely Available" means that no fee is charged for the item
+ itself, though there may be fees involved in handling the item.
+ It also means that recipients of the item may redistribute it
+ under the same conditions they received it.
+
+1. You may make and give away verbatim copies of the source form of the
+Standard Version of this Package without restriction, provided that you
+duplicate all of the original copyright notices and associated disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications
+derived from the Public Domain or from the Copyright Holder. A Package
+modified in such a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided
+that you insert a prominent notice in each changed file stating how and
+when you changed that file, and provided that you do at least ONE of the
+following:
+
+ a) place your modifications in the Public Domain or otherwise make them
+ Freely Available, such as by posting said modifications to Usenet or
+ an equivalent medium, or placing the modifications on a major archive
+ site such as uunet.uu.net, or by allowing the Copyright Holder to include
+ your modifications in the Standard Version of the Package.
+
+ b) use the modified Package only within your corporation or organization.
+
+ c) rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided, and provide
+ a separate manual page for each non-standard executable that clearly
+ documents how it differs from the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or
+executable form, provided that you do at least ONE of the following:
+
+ a) distribute a Standard Version of the executables and library files,
+ together with instructions (in the manual page or equivalent) on where
+ to get the Standard Version.
+
+ b) accompany the distribution with the machine-readable source of
+ the Package with your modifications.
+
+ c) accompany any non-standard executables with their corresponding
+ Standard Version executables, giving the non-standard executables
+ non-standard names, and clearly documenting the differences in manual
+ pages (or equivalent), together with instructions on where to get
+ the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+Package. You may charge any fee you choose for support of this Package.
+You may not charge a fee for this Package itself. However,
+you may distribute this Package in aggregate with other (possibly
+commercial) programs as part of a larger (possibly commercial) software
+distribution provided that you do not advertise this Package as a
+product of your own.
+
+6. The scripts and library files supplied as input to or produced as
+output from the programs of this Package do not automatically fall
+under the copyright of this Package, but belong to whomever generated
+them, and may be sold commercially, and may be aggregated with this
+Package.
+
+7. C subroutines supplied by you and linked into this Package in order
+to emulate subroutines and variables of the language defined by this
+Package shall not be considered part of this Package, but are the
+equivalent of input as in Paragraph 6, provided these subroutines do
+not change the language in any way that would cause it to fail the
+regression tests for the language.
+
+8. The name of the Copyright Holder may not be used to endorse or promote
+products derived from this software without specific prior written permission.
+
+9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ The End
diff --git a/sample/MANIFEST b/sample/MANIFEST
new file mode 100644
index 0000000000..c54adf31ef
--- /dev/null
+++ b/sample/MANIFEST
@@ -0,0 +1,63 @@
+MANIFEST
+Artistic
+aset.rb
+attr.rb
+biorhythm.rb
+blk.rb
+case.rb
+cat.rb
+cat2.rb
+cbreak.rb
+clnt.rb
+clone.rb
+const.rb
+dbm.rb
+dir.rb
+evaldef.rb
+export.rb
+exyacc.rb
+fib.awk
+fib.pl
+fib.rb
+fib.scm
+freq.rb
+fullpath.pl
+fullpath.rb
+gctest.rb
+gctest2.rb
+getopts.rb
+getopts.test
+hash.rb
+io.rb
+less.rb
+list.rb
+list2.rb
+list3.rb
+math.rb
+mpart.rb
+occur.pl
+occur.rb
+occur2.rb
+opt_s.rb
+opt_x.rb
+parsearg.rb
+rcs.awk
+rcs.dat
+rcs.rb
+ruby-mode.el
+samp.rb
+sieve.rb
+split.rb
+struct.rb
+svr.rb
+system.rb
+t1.rb
+t2.rb
+test.rb
+time.rb
+trap.pl
+trap.rb
+trojan.pl
+trojan.rb
+tt.rb
+uumerge.rb
diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb
new file mode 100644
index 0000000000..eb14ca7365
--- /dev/null
+++ b/sample/biorhythm.rb
@@ -0,0 +1,201 @@
+#!/mp/free/bin/ruby
+#
+# biorhythm.rb -
+# $Release Version: $
+# $Revision: 1.6 $
+# $Date: 1994/02/24 10:23:34 $
+# by Yasuo OHBA(STAFS Development Room)
+#
+# --
+#
+#
+#
+
+$RCS_ID="$Header: /var/ohba/RCS/biorhythm.rb,v 1.6 1994/02/24 10:23:34 ohba Exp ohba $"
+
+include Math
+load("parsearg.rb")
+
+$wochentag = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
+monatstag1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+monatstag2 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+
+def usage()
+ print("Usage:\n")
+ print("biorhythm.rb [options]\n")
+ print(" options...\n")
+ print(" -D YYYYMMDD(birthday) : ���٤� default �ͤ�Ȥ�. \n")
+ print(" --sdate | --date YYYYMMDD : system date �⤷���ϻ��ꤷ�����դ�Ȥ�.\n")
+ print(" --birthday YYYYMMDD : �������λ���򤹤�. \n")
+ print(" -v | -g : Values or Graph ���. \n")
+ print(" --days DAYS : ���֤λ���򤹤�(Graph �λ��Τ�ͭ��). \n")
+ print(" --help : help\n")
+end
+$USAGE = 'usage'
+
+def leapyear(y)
+ ta = 0
+ if ((y % 4.0) == 0); ta = 1; end
+ if ((y % 100.0) == 0); ta = 0; end
+ if ((y % 400.0) == 0); ta = 1; end
+ return ta
+end
+
+def bcalc(tt, m, j)
+ ta = 0
+ if (m <= 2)
+ ta = (m - 1) * 31
+ else
+ ta = leapyear(j)
+ ta = ta + ((306 * m - 324) / 10.0).to_i
+ end
+ ta = ta + (j - 1) * 365 + ((j - 1) / 4.0).to_i
+ ta = ta - ((j - 1) / 100) + ((j - 1) / 400.0).to_i
+ ta = ta + tt
+ return ta
+end
+
+def printHeader(tg, mg, jg, gtag, tage)
+ print("\n")
+ print(" Biorhythm\n")
+ print(" =========\n")
+ print("\n")
+ printf("The birthday %04d.%02d.%02d is a %s\n", jg, mg, tg, $wochentag[gtag])
+ printf("Age in days: [%d]\n", tage)
+end
+
+def getPosition(z)
+ pi = 3.14159265
+ $phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i
+ $emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * pi / 180.0))).to_i
+ $geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * pi / 180.0))).to_i
+end
+
+#
+# main program
+#
+parseArgs(0, nil, "vg", "D:", "sdate", "date:", "birthday:", "days:")
+
+printf($stderr, "\n")
+printf($stderr, "Biorhythm (c) 1987-1994 V3.0\n")
+printf($stderr, "\n")
+if ($OPT_D)
+ dtmp = Time.now.strftime("%Y%m%d")
+ jh = dtmp[0,4].to_i
+ mh = dtmp[4,2].to_i
+ th = dtmp[6,2].to_i
+ dtmp = $OPT_D
+ jg = dtmp[0,4].to_i
+ mg = dtmp[4,2].to_i
+ tg = dtmp[6,2].to_i
+ gtag = bcalc(tg, mg, jg) % 7
+ ausgabeart = "g"
+else
+ if ($OPT_birthday)
+ dtmp = $OPT_birthday
+ else
+ printf($stderr, "Birthday (YYYYMMDD) : ")
+ dtmp = $stdin.gets.chop
+ end
+ if (dtmp.length != 8)
+ printf($stderr, "BAD Input Birthday!!\n")
+ exit()
+ end
+ jg = dtmp[0,4].to_i
+ mg = dtmp[4,2].to_i
+ tg = dtmp[6,2].to_i
+
+ gtag = bcalc(tg, mg, jg) % 7
+
+ if ($OPT_sdate)
+ dtmp = Time.now.strftime("%Y%m%d")
+ elsif ($OPT_date)
+ dtmp = $OPT_date
+ else
+ printf($stderr, "Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
+ dtmp = $stdin.gets.chop
+ end
+ if (dtmp.length != 8)
+ dtmp = Time.now.strftime("%Y%m%d")
+ end
+ jh = dtmp[0,4].to_i
+ mh = dtmp[4,2].to_i
+ th = dtmp[6,2].to_i
+
+ if ($OPT_v)
+ ausgabeart = "v"
+ elsif ($OPT_g)
+ ausgabeart = "g"
+ else
+ printf($stderr, "Values for today or Graph (v/g) [default g] : ")
+ ausgabeart = $stdin.gets.chop
+ end
+end
+if (ausgabeart == "v")
+ tag = bcalc(tg, mg, jg)
+ tah = bcalc(th, mh, jh)
+ tage = tah - tag
+ printHeader(tg, mg, jg, gtag, tage)
+ print("\n")
+
+ getPosition(tage)
+ printf("Biorhythm: %04d.%02d.%02d\n", jh, mh, th)
+ printf("Physical: %d%%\n", $phys)
+ printf("Emotional: %d%%\n", $emot)
+ printf("Mental: %d%%\n", $geist)
+ print("\n")
+else
+ if ($OPT_days)
+ ktage = $OPT_days.to_i
+ else
+ if ($OPT_D)
+ ktage = 9
+ else
+ printf($stderr, "Graph for how many days [default 10] : ")
+ ktage = $stdin.gets.chop
+ if (ktage == "")
+ ktage = 9
+ else
+ ktage = ktage.to_i - 1
+ end
+ end
+ end
+ tag = bcalc(tg, mg, jg)
+ tah = bcalc(th, mh, jh)
+ tage = tah - tag
+ printHeader(tg, mg, jg, gtag, tage)
+ print(" P=physical, E=emotional, M=mental\n")
+ print(" -------------------------+-------------------------\n")
+ print(" Bad Condition | Good Condition\n")
+ print(" -------------------------+-------------------------\n")
+
+ for z in tage..(tage + ktage)
+ getPosition(z)
+
+ printf("%04d.%02d.%02d : ", jh, mh, th)
+ p = ($phys / 2.0 + 0.5).to_i
+ e = ($emot / 2.0 + 0.5).to_i
+ g = ($geist / 2.0 + 0.5).to_i
+ graph = "." * 51
+ graph[25] = ?|
+ graph[p] = ?P
+ graph[e] = ?E
+ graph[g] = ?M
+ print(graph, "\n")
+ th = th + 1
+ if (leapyear(jh) == 0)
+ $MONATSTAG = monatstag1
+ else
+ $MONATSTAG = monatstag2
+ end
+ if (th > $MONATSTAG[mh - 1])
+ mh = mh + 1
+ th = 1
+ end
+ if (mh > 12)
+ jh = jh + 1
+ mh = 1
+ end
+ end
+ print(" -------------------------+-------------------------\n\n")
+end
diff --git a/sample/blk.rb b/sample/blk.rb
index 4e618bce2d..12d1038fd0 100644
--- a/sample/blk.rb
+++ b/sample/blk.rb
@@ -2,8 +2,8 @@ def foo()
$block = Block.new
end
-foo(){i | print "i = ", i, "\n"}
-$block.do(2)
+foo(){i| print "i = ", i, "\n"}
+$block.call(2)
-foo(){i | print "i*2 = ", i*2, "\n"}
-$block.do(2)
+foo(){i| print "i*2 = ", i*2, "\n"}
+$block.call(2)
diff --git a/sample/clone.rb b/sample/clone.rb
index 69d2f1d52b..e7d6b00a31 100644
--- a/sample/clone.rb
+++ b/sample/clone.rb
@@ -3,7 +3,7 @@
# test2
# test
# test
-# clone.rb:13: undefined method `test2' for "#<Object: 0xbfca4>"(Object)
+# clone.rb:18: undefined method `test2' for "#<Object: 0xbfca4>"(Object)
foo = Object.new
def foo.test
print("test\n")
diff --git a/sample/dir.rb b/sample/dir.rb
index f269c568ba..3349dc7b6d 100644
--- a/sample/dir.rb
+++ b/sample/dir.rb
@@ -3,7 +3,7 @@
dirp = Dir.open(".")
dirp.rewind
for f in dirp
- unless (~/^\./ || ~/~$/ || ~/\.o/)
+ if !(~/^\./ || ~/~$/ || ~/\.o/)
print f, "\n"
end
end
diff --git a/sample/evaldef.rb b/sample/evaldef.rb
index 021f65800a..1d77a3c008 100644
--- a/sample/evaldef.rb
+++ b/sample/evaldef.rb
@@ -1,7 +1,7 @@
# method definition by eval()
# output:
# bar
-# (eval):21: method `baz' not available for "#<foo: 0xbfc5c>"(foo)
+# (eval):26: method `baz' not available for "#<foo: 0xbfc5c>"(foo)
class foo
def foo
diff --git a/sample/export.rb b/sample/export.rb
index be7b6bc797..03b9492e5a 100644
--- a/sample/export.rb
+++ b/sample/export.rb
@@ -4,7 +4,7 @@
# foo
class foo
- export(\printf)
+ export :printf
end
def foobar
@@ -12,7 +12,7 @@ def foobar
end
f = foo.new
-#foo.unexport(\printf)
-foo.export(\foobar)
+#foo.unexport :printf
+foo.export :foobar
f.foobar
f.printf "%s\n", foo
diff --git a/sample/exyacc.rb b/sample/exyacc.rb
new file mode 100644
index 0000000000..ad6191c03d
--- /dev/null
+++ b/sample/exyacc.rb
@@ -0,0 +1,22 @@
+#! /usr/local/bin/ruby -Cn
+# usage: exyacc.rb [yaccfiles]
+# this is coverted from exyacc.pl in the camel book
+
+$/ = nil
+
+while gets()
+ sbeg = $_.index("\n%%") + 1
+ send = $_.rindex("\n%%") + 1
+ $_ = $_[sbeg, send-sbeg]
+ sub(/.*\n/, "")
+ gsub(/'{'/, "'\001'")
+ gsub(/'}'/, "'\002'")
+ gsub('\*/', "\003\003")
+ gsub("/\\*[^\003]*\003\003", '')
+ while gsub(/{[^}{]*}/, ''); end
+ gsub(/'\001'/, "'{'")
+ gsub(/'\002'/, "'}'")
+ while gsub(/^[ \t]*\n(\s)/, '\1'); end
+ gsub(/([:|])[ \t\n]+(\w)/, '\1 \2')
+ print $_
+end
diff --git a/sample/gctest2.rb b/sample/gctest2.rb
new file mode 100644
index 0000000000..851d14f217
--- /dev/null
+++ b/sample/gctest2.rb
@@ -0,0 +1,71 @@
+# GC stress test
+def cons(car, cdr)
+ car::cdr
+end
+
+def car(x)
+ x.car
+end
+
+def cdr(x)
+ x.cdr
+end
+
+def reverse1(x, y)
+ if x == nil then
+ y
+ else
+ reverse1(cdr(x), cons(car(x), y))
+ end
+end
+
+def reverse(x)
+ reverse1(x, nil)
+end
+
+def ints(low, up)
+ if low > up
+ nil
+ else
+ cons(low, ints(low+1, up))
+ end
+end
+
+def print_int_list(x)
+ if x == nil
+ print("NIL\n")
+ else
+ print(car(x))
+ if cdr(x)
+ print(", ")
+ print_int_list(cdr(x))
+ else
+ print("\n")
+ end
+ end
+end
+
+print("start\n")
+
+a = ints(1, 100)
+print_int_list(a)
+b = ints(1, 50)
+print_int_list(b)
+print_int_list(reverse(a))
+print_int_list(reverse(b))
+for i in 1 .. 100
+ b = reverse(reverse(b))
+# print(i, ": ")
+# print_int_list(b)
+end
+print("a: ")
+print_int_list(a)
+print("b: ")
+print_int_list(b)
+print("reverse(a): ")
+print_int_list(reverse(a))
+print("reverse(b): ")
+print_int_list(reverse(b))
+a = b = nil
+print("finish\n")
+GC.start()
diff --git a/sample/list.rb b/sample/list.rb
index 1a20c954d0..fa145f4627 100644
--- a/sample/list.rb
+++ b/sample/list.rb
@@ -1,19 +1,10 @@
# Linked list example
class MyElem
- #���饹�᥽�å�(����)�����
- def MyElem.new(item)
- # �����ѡ����饹�Υ᥽�åɤθƤӽФ�(���ξ��ϥ��饹Class)
- elm = super # �ѿ�������פ�ʤ�
- #elm���Ф���᥽�åɤθƤӽФ�
- elm.init(item)
- end
-
- # �̾�Υ᥽�å����
- def init(item)
+ # ���֥��������������˼�ưŪ�˸ƤФ��᥽�å�
+ def init_object(item)
# @�ѿ��ϥ��󥹥����ѿ�(������פ�ʤ�)
@data = item
@next = nil
- self
end
def data
@@ -63,11 +54,7 @@ class MyList
end
class Point
- def Point.new(x, y)
- super.init(x, y)
- end
-
- def init(x, y)
+ def init_object(x, y)
@x = x; @y = y
self
end
diff --git a/sample/list2.rb b/sample/list2.rb
index fef9d35a84..1c2ca08150 100644
--- a/sample/list2.rb
+++ b/sample/list2.rb
@@ -1,10 +1,6 @@
# Linked list example -- short version
class Point
- def Point.new(x, y)
- super.init(x, y)
- end
-
- def init(x, y)
+ def init_object(x, y)
@x = x; @y = y
self
end
diff --git a/sample/list3.rb b/sample/list3.rb
index c6278574bf..6bedc6ced9 100644
--- a/sample/list3.rb
+++ b/sample/list3.rb
@@ -2,11 +2,7 @@
# using _inspect
class Point
- def Point.new(x, y)
- super.init(x, y)
- end
-
- def init(x, y)
+ def init_object(x, y)
@x = x; @y = y
self
end
diff --git a/sample/rcs.awk b/sample/rcs.awk
new file mode 100644
index 0000000000..08979285c9
--- /dev/null
+++ b/sample/rcs.awk
@@ -0,0 +1,33 @@
+BEGIN {
+ sw = 40.0;
+ dw = 78.0;
+ hdw = dw / 2.0;
+ w = 20.0;
+ h =1.0;
+ d = 0.2;
+ ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./";
+ rnd = srand();
+}
+
+{
+ xr = -hdw; y = h * 1.0; maxxl = -999;
+ s = "";
+ while (xr < hdw) {
+ x = xr * (1 + y) - y * w / 2;
+ i = (x / (1 + h) + sw /2);
+ c = (0 < i && i < length($0)) ? substr($0, i, 1) : "0";
+ y = h - d * c;
+ xl = xr - w * y / (1 + y);
+ if (xl < -hdw || xl >= hdw || xl <= maxxl) {
+ t = rand() * length(ss);
+ c = substr(ss, t, 1);
+ }
+ else {
+ c = substr(s, xl + hdw, 1);
+ maxxl = xl;
+ }
+ s = s c;
+ xr = xr + 1;
+ }
+ print s;
+}
diff --git a/sample/rcs.dat b/sample/rcs.dat
new file mode 100644
index 0000000000..61c88bff89
--- /dev/null
+++ b/sample/rcs.dat
@@ -0,0 +1,17 @@
+0000000000000000220000000000000000
+0000000000000111221110000000000000
+0000000000111112222111110000000000
+0000000111111112222111111110000000
+0000111111111122222211111111110000
+0111111111111222222221111111111110
+2222222222222222222222222222222222
+1122222222222222222222222222222211
+0111122222222222222222222222211110
+0011111122222222222222222211111100
+0001111111222222222222221111111000
+0000111112222222222222222111110000
+0000011122222222112222222211100000
+0000001122222221111222222211000000
+0000000122221111111111222210000000
+0000000221111111111111111220000000
+0000000000000000000000000000000000
diff --git a/sample/rcs.rb b/sample/rcs.rb
new file mode 100644
index 0000000000..faa4606788
--- /dev/null
+++ b/sample/rcs.rb
@@ -0,0 +1,49 @@
+# random dot steraogram
+# usage: rcs.rb rcs.dat
+
+sw = 40.0 # ���̃p�^�[���̕�
+dw = 78.0 # ��������� Random Character Streogram �̕�
+hdw = dw / 2.0
+w = 20.0 # ����̕�
+h =1.0 # ��ʂƊ�ʂ̋���
+d = 0.2 # �P�ʓ�����̕����オ���
+ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./"
+rnd = srand()
+
+while gets()
+# print($_)
+ xr = -hdw; y = h * 1.0; maxxl = -999
+ s = "";
+ while xr < hdw
+ x = xr * (1 + y) - y * w / 2
+ i = (x / (1 + h) + sw /2)
+ if (1 < i && i < $_.length);
+ c = $_[i, 1].to_i
+ else
+ c = 0
+ end
+ y = h - d * c
+ xl = xr - w * y / (1 + y);
+ if xl < -hdw || xl >= hdw || xl <= maxxl
+ tt = rand(ss.length)
+ c = ss[tt, 1]
+ else
+ c = s[xl + hdw, 1]
+ maxxl = xl
+ end
+ s += c
+ xr += 1
+ end
+ print(s, "\n")
+end
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sample/sieve.rb b/sample/sieve.rb
index 192a5865d8..eaf4e33e2c 100644
--- a/sample/sieve.rb
+++ b/sample/sieve.rb
@@ -1,6 +1,6 @@
# sieve of Eratosthenes
sieve = []
-unless max = $ARGV.shift; max = 100; end
+if ! max = $ARGV.shift; max = 100; end
max = max.to_i
print "1"
@@ -15,3 +15,4 @@ for i in 2 .. max
resque
end
end
+print "\n"
diff --git a/sample/uumerge.rb b/sample/uumerge.rb
index 420a3924b6..d0bd016036 100755
--- a/sample/uumerge.rb
+++ b/sample/uumerge.rb
@@ -8,7 +8,7 @@ while gets()
end
end
-fail "missing begin" unless $sawbegin;
+fail "missing begin" if !$sawbegin;
OUT = open($file, "w") if $file != "";
while gets()
@@ -18,10 +18,10 @@ while gets()
end
sub(/[a-z]+$/, ""); # handle stupid trailing lowercase letters
continue if /[a-z]/
- continue unless ((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4
+ continue if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4)
OUT << $_.unpack("u");
end
-fail "missing end" unless $sawend;
+fail "missing end" if ! $sawend;
File.chmod $mode.oct, $file;
exit 0;
diff --git a/signal.c b/signal.c
index f711436f1c..c0173d8e1c 100644
--- a/signal.c
+++ b/signal.c
@@ -168,23 +168,30 @@ Fkill(argc, argv)
{
int sig;
int i;
+ char *s;
if (argc < 2)
Fail("wrong # of arguments -- kill(sig, pid...)");
switch (TYPE(argv[0])) {
case T_FIXNUM:
sig = FIX2UINT(argv[0]);
+ if (sig >= NSIG) {
+ s = rb_id2name(sig);
+ if (!s) Fail("Bad signal");
+ goto str_signal;
+ }
break;
case T_STRING:
{
int negative = 0;
- char *s = RSTRING(argv[0])->ptr;
- if (*s == '-') {
+ s = RSTRING(argv[0])->ptr;
+ if (s[0] == '-') {
negative++;
s++;
}
+ str_signal:
if (strncmp("SIG", s, 3) == 0)
s += 3;
if((sig = signm2signo(s)) == 0)
diff --git a/socket.c b/socket.c
index b691e7e1c8..58a2a8e9e7 100644
--- a/socket.c
+++ b/socket.c
@@ -82,7 +82,6 @@ Fbsock_setopt(sock, lev, optname, val)
level = NUM2INT(lev);
option = NUM2INT(optname);
Check_Type(val, T_STRING);
-
GetOpenFile(sock, fptr);
if (setsockopt(fileno(fptr->f), level, option, val->ptr, val->len) < 0)
@@ -104,7 +103,7 @@ Fbsock_getopt(sock, lev, optname)
len = 256;
val = (struct RString*)str_new(0, len);
Check_Type(val, T_STRING);
-
+
GetOpenFile(sock, fptr);
if (getsockopt(fileno(fptr->f), level, option, val->ptr, &len) < 0)
rb_sys_fail(fptr->path);
@@ -163,7 +162,7 @@ open_inet(class, h, serv, server)
if (hostent == NULL) {
hostaddr = inet_addr(host);
if (hostaddr == -1) {
- if (server && !strlen(host))
+ if (server && !strlen(host))
hostaddr = INADDR_ANY;
else
rb_sys_fail(host);
@@ -193,9 +192,9 @@ open_inet(class, h, serv, server)
}
protoent = getprotobyname(servent->s_proto);
if (protoent == NULL) Fail("no such proto %s", servent->s_proto);
-
+
fd = socket(PF_INET, SOCK_STREAM, protoent->p_proto);
-
+
sockaddr.sin_family = AF_INET;
if (h == Qnil) {
sockaddr.sin_addr.s_addr = INADDR_ANY;
@@ -293,7 +292,7 @@ open_unix(class, path, server)
char *syscall;
VALUE sock;
OpenFile *fptr;
-
+
Check_Type(path, T_STRING);
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) rb_sys_fail("socket(2)");
@@ -361,7 +360,7 @@ Ftcp_addr(sock)
int len = sizeof addr;
GetOpenFile(sock, fptr);
-
+
if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
return tcp_addr(&addr);
@@ -376,7 +375,7 @@ Ftcp_peeraddr(sock)
int len = sizeof addr;
GetOpenFile(sock, fptr);
-
+
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
return tcp_addr(&addr);
@@ -443,7 +442,7 @@ Funix_addr(sock)
int len = sizeof addr;
GetOpenFile(sock, fptr);
-
+
if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
return unix_addr(&addr);
@@ -458,7 +457,7 @@ Funix_peeraddr(sock)
int len = sizeof addr;
GetOpenFile(sock, fptr);
-
+
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
return unix_addr(&addr);
@@ -642,7 +641,7 @@ Fsock_send(argc, argv, sock)
fd = fileno(f);
if (to) {
Check_Type(to, T_STRING);
- n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags),
+ n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags),
(struct sockaddr*)to->ptr, to->len);
}
else {
@@ -678,7 +677,7 @@ sock_recv(sock, argc, argv, from)
GetOpenFile(sock, fptr);
fd = fileno(fptr->f);
- if ((str->len = recvfrom(fd, str->ptr, str->len, flags,
+ if ((str->len = recvfrom(fd, str->ptr, str->len, flags,
(struct sockaddr*)buf, &alen)) < 0) {
rb_sys_fail("recvfrom(2)");
}
diff --git a/spec b/spec
index 75bd5e8065..b7c374db64 100644
--- a/spec
+++ b/spec
@@ -1,6 +1,6 @@
.\" spec - -*- Indented-Text -*- created at: Tue May 25 15:18:26 JST 1993
-* �Ϥ����(�ʤ�Ruby��?)
+* �Ϥ����
Ruby�ϡ�UNIX�Ǽ�ڤ˥��֥������Ȼظ��ץ�����ߥ󥰡פ򤷤����Ȥ���˾��
��¸����뤿������ޤ줿�����Τ����ɬ�פ��Ȼפ�줿������:
@@ -41,57 +41,75 @@ Ruby�Υ��֥������Ȼظ���ǽ�ˤĤ��Ƴؤ٤С���궯�Ϥʤ��Ȥ�Ǥ���褦��
������󥯤Ǥ��뤷�������Ǥʤ��Ƥ�Ruby��ƥ���ѥ��뤷���Ȥ߹��ߥ���
�����ɲä���Τ��ưפǤ���(Perl�ʤɤ���Ϥ뤫���ưפǤ���)��
-* Ruby��ʸˡ
+* Lexical structure
-�����Ǥ�Ruby�����ʸˡ����⤹�롥Ruby�δ���Ū����ʬ�Ͼ�������ʸˡ����
-�������ʤ��ΤǿȤˤĤ���ΤϤ��ۤ��񤷤��ʤ���������
+���ߤ�ruby�μ����ϥ���饯�����åȤȤ���ASCII���Ѥ��롥ruby����ʸ����
+��ʸ������̤��롥���̻Ҥ�����Ǥʤ����Ǥ�դΤȤ����˶���ʸ���򤪤���
+�Ȥ�����롥����ʸ���ϥ��ڡ���(space)������(tab)����ľ����(vertical
+tab)�� CR(carriage return)������(form feed)�Ǥ��롥����(newline)������
+���˼�����³������ˤ϶���ʸ���Ȥ��ơ�����ʳ��Ǥ�ʸ�ζ��ڤ�Ȥ��Ʋ�
+�ᤵ��롥
+
+���̻Ҥϱ�ʸ��("_"��ޤ�)����Ϥޤꡤ�ѿ�����³������ΤǤ��롥ruby��
+���̻Ҥ�Ĺ�������¤Ϥʤ������ߤμ����ϼ��̻ҤȤ��ƥޥ���Х��ȥ�����
+(EUC,SJIS)���̤���������ʤ���
+
+�������Х��ѿ�̾��"$"��³�����̻Ҥޤ��ϵ���1ʸ�������󥹥����ѿ���
+"@"��³�����̻ҡ����饹�����"%"��³�����̻ҤǤ��롥�᥽�å�̾��������
+���ѿ�̾�ȥ��饹̾��ñ�ʤ뼱�̻Ҥ��Ѥ��롥
** ������
-������ץȸ���ν����ˤʤ餤��ʸ������ʳ���'#'��������ޤǤϥ�����
-�ȸ��ʤ���
+������ץȸ���ν����ˤʤ餤��ʸ�������ʸ��ɽ��(?#)�ʳ���`#'�������
+�ޤǤϥ����Ȥȸ��ʤ���
+
+** ͽ���
+
+ͽ���ϰʲ����̤�Ǥ���
+
+ alias else in resque when
+ and elsif include retry while
+ break end module return yield
+ case ensure nil self __END__
+ class fail or super __FILE__
+ continue for protect then __LINE__
+ def if redo undef
-** ���ڤ국��
+ͽ���ϥ��饹̾���᥽�å�̾���ѿ�̾�ʤɤ��Ѥ��뤳�ȤϤǤ��ʤ���
-����ʸ��(���֤ȥ��ڡ���)����Ӳ���(\n)�����ڤ국��Ȥʤ롥����
-���Ԥ�
+** ���ڤ�ʸ��
+
+ʸ����ʤɤΥ�ƥ��������ʳ��ξ��ζ���ʸ��(���֤ȥ��ڡ���)����Ӳ�
+��(\n)�����ڤ국��Ȥʤ롥���˲��Ԥ�
a +
b
-�Τ褦�˹Ԥ���(ʸ)������ǽ��ꡤ���ιԤ�³�����Ȥ�����ʾ��ʳ���ʸ��
-���ڤ�Ȥ��Ƥ�ǧ������롥
+�Τ褦�˹Ԥ���������ǽ��ꡤ���ιԤ�³�����Ȥ�����ʾ�����������ζ�
+�ڤ�Ȥ��Ƥ�ǧ������롥
-** ͽ���
+* �ץ������
-ͽ���ϰʲ����̤�Ǥ���
+��:
- alias elsif module self yield
- and end nil super __END__
- break ensure or then __FILE__
- case fail protect undef __LINE__
- class for redo unless
- continue if resque until
- def in retry when
- else include return while
+ print "hello world!\n"
-ͽ���ϥ��饹̾���᥽�å�̾���ѿ�̾�ʤɤ��Ѥ��뤳�ȤϤǤ��ʤ���
+�ץ������ϼ����¤٤���ΤǤ��롥���ȼ��δ֤ϥ��ߥ�����(`;')�ޤ��ϲ�
+�ԤǶ��ڤ���(��)��
-** ��
+�� �������ιԤ˷�³���뤳�Ȥ�����ʻ��ˤϲ��Ԥϼ��ζ��ڤ�ˤʤ�ʤ���
-Ruby�ץ����������������Ǥϼ���ʸ�Ǥ��롥�ޤ�����������⤹�롥
+* ��
-*** ��ƥ��
+Ruby�Ǥ�nil����������ʳ�������ɾ������롥C��Perl �ʤɤȤϰۤʤꡤ0��
+""(��ʸ����)�ϵ��Ȥ�ɾ������ʤ��Τǵ���Ĥ��뤳�ȡ�
-�ץ���������ľ�ܵ��ҤǤ��륪�֥������Ȥ��ƥ��ȸƤ֡�Ruby�Υ�ƥ�
-��ˤ�ʸ��������ɽ�������ͤȤ�����ƥ�뤬���롥
-
-**** ʸ�����ƥ��
+** ʸ����
"..." # �Хå�����å���β����ѿ�Ÿ������
'...' # �Хå�����å���β��ʤ�(\\��\'�ϲ�᤹��)
-**** �Хå�����å��嵭ˡ
+�Хå�����å��嵭ˡ
\t ����(0x09)
\n ����ʸ��(0x0a)
@@ -108,14 +126,21 @@ Ruby�ץ����������������Ǥϼ���ʸ�Ǥ��롥�ޤ�����������⤹�롥
\M-c �᥿ʸ��(c|0x80)
\����ʳ� ʸ�����Τ��
-**** �ѿ�Ÿ��
+�ѿ�Ÿ��
���֥륯������(`"')�ǰϤޤ줿ʸ���������ɽ������Ǥ� `#{�ѿ�̾}'�Ȥ�
���������ѿ������Ƥ�Ÿ�����뤳�Ȥ��Ǥ��롥�ѿ����ѿ�����(`$',`@',`%')
�ǻϤޤ���ˤ�`#�ѿ�̾'�Ȥ��������Ǥ�Ÿ���Ǥ��롥ʸ��`#'��³��ʸ��
�� `{',`$',`@',`%'�Ǥʤ���С����Τޤ�`#'�Ȥ��Ʋ�ᤵ��롥
-**** ����ɽ����ƥ��
+** ���ޥ�ɽ���
+
+Ruby�Ǥ�sh�Τ褦�˥��ޥ�ɤμ¹Է�̤�ʸ�����ƥ��Τ褦�˻Ȥ����Ȥ�
+�Ǥ��롥``�ǰϤޤ줿ʸ����ϡ����֥륯�����Ȥ�Ʊ�ͤ˥Хå�����å��嵭
+ˡ�β����ѿ�Ÿ�����Ԥʤ�줿�塤���ޥ�ɤȤ��Ƽ¹Ԥ��졤���μ¹Է��
+��ʸ����Ȥ���Ϳ�����롥���ޥ�ɤ�ɾ������뤿�Ӥ˼¹Ԥ���롥
+
+** ����ɽ����
/.../
@@ -139,18 +164,20 @@ Ruby�ץ����������������Ǥϼ���ʸ�Ǥ��롥�ޤ�����������⤹�롥
| ����
( ) ����ɽ����ޤȤ��
-����¾��ʸ�����Ʊ���Хå�����å��嵭ˡ��ͭ���Ǥ��롥
+����¾��ʸ�����Ʊ���Хå�����å��嵭ˡ���ѿ�Ÿ����ͭ���Ǥ��롥
-**** �磻��ɥ����ɥ�ƥ��
+** �磻��ɥ����ɼ�
<...>
* Ǥ�դ�ʸ����(��ʸ�����ޤ�)�Ȱ���
? Ǥ�դ�1ʸ���Ȱ���
[ ] []��Τ����줫1ʸ���Ȱ���
- {..} {}��Τ����줫��ʸ����Ȱ���
+ {..} {}���(����ޤǶ��ڤ�줿)�����줫��ʸ����Ȱ���
+
+����¾��ʸ�����Ʊ���Хå�����å��嵭ˡ���ѿ�Ÿ����ͭ���Ǥ��롥
-**** ���ͥ�ƥ��
+** ���ͥ�ƥ��
123 ����
-123 ����(���Ĥ���)
@@ -164,19 +191,12 @@ Ruby�ץ����������������Ǥϼ���ʸ�Ǥ��롥�ޤ�����������⤹�롥
?\M-a �᥿a�Υ�����(225)
?\M-\C-a �᥿-����ȥ�����a�Υ�����(129)
- \����ܥ� ���̻�/�ѿ�̾�Ȱ��а��б�����������apply�ʤɤǥ᥽��
- �ɤ���ꤹ��Τ˻Ȥ���
+ :����ܥ� ���̻�/�ѿ�̾/�黻�ҤȰ��а��б�����������apply�ʤ�
+ �ǥ᥽�åɤ���ꤹ����ʤɤ˻Ȥ���
?ɽ���Ǥ����ƤΥХå�����å��嵭ˡ��ͭ���Ǥ��롥
-*** ���ޥ�ɤν���
-
-Ruby�Ǥ�sh�Τ褦�˥��ޥ�ɤμ¹Է�̤�ʸ�����ƥ��Τ褦�˻Ȥ����Ȥ�
-�Ǥ��롥``�ǰϤޤ줿ʸ����ϡ����֥륯�����Ȥ�Ʊ�ͤ˥Хå�����å��嵭
-ˡ�β����ѿ�Ÿ�����Ԥʤ�줿�塤���ޥ�ɤȤ��Ƽ¹Ԥ��졤���μ¹Է��
-��ʸ����Ȥ���Ϳ�����롥���ޥ�ɤ�ɾ������뤿�Ӥ˼¹Ԥ���롥
-
-*** �ѿ�����
+** �ѿ������
Ruby���ѿ��ϥ�������(ͭ���ϰ�)�ȼ�̿(ͭ������)�ˤ�ä�4�����ʬ�व�졤
���μ�����ѿ�̾�κǽ�ΰ�ʸ���Ƿ��ꤵ��롥�̾���ѿ���2ʸ���ܰʹߤ�
@@ -184,20 +204,35 @@ Ruby���ѿ��ϥ�������(ͭ���ϰ�)�ȼ�̿(ͭ������)�ˤ�ä�4�����ʬ�व�졤
�ѿ������롥�ѿ�̾��Ĺ���˴ؤ������̤����¤Ϥʤ���
�ѿ��Υ������פ˴ؤ�餺�����������Ƥ��ʤ��ѿ��򻲾Ȥ��������ͤ�nil
-�Ǥ��롥
+�Ǥ��롥������μ�����ѿ��������ɬ�פʤ���
-**** �������Х��ѿ�
+*** �������Х��ѿ�
+
+��:
+
+ $foobar
+ $/
`$'�ǻϤޤ��ѿ��Υ������פϥ������Х�Ǥ��ꡤ�ץ������Τɤ�����Ǥ�
���ȤǤ��롥���μ�̿�ϥץ������μ�̿����������
-**** ���󥹥����ѿ�
+*** ���󥹥����ѿ�
+
+��:
+
+ @foobar
`@'�ǻϤޤ��ѿ��ϥ��󥹥����ѿ��Ǥ��ꡤ���Υ��饹�ޤ��ϥ��֥��饹��
�᥽�åɤ��黲�ȤǤ��롥�������פϥ᥽�å���Ǥ��ꡤ���μ�̿�ϥ��֥���
���Ȥμ�̿����������
-**** ���饹̾/�⥸�塼��̾/���������ѿ�
+*** ���饹̾/�⥸�塼��̾/���������ѿ�
+
+��:
+
+ Array
+ Math
+ foobar
����ե��٥åȤޤ���`_'�ǻϤޤ��ѿ��ϼ��̻ҤȤ�ƤФ졤���������ѿ���
���饹̾�ޤ��ϥ⥸�塼��̾�Ǥ��롥
@@ -231,15 +266,18 @@ Ruby���ѿ��ϥ�������(ͭ���ϰ�)�ȼ�̿(ͭ������)�ˤ�ä�4�����ʬ�व�졤
���������ѿ��Υ������פ��̿�⤽�Υ֥��å��ν���ޤ�(�ȥåץ�٥�Υ���
�����ѿ��ϥץ������ν�λ�ޤ�)�Ǥ��롥
-**** ���饹�ѿ�(���)
+*** ���饹���
-`%'�ǻϤޤ��ѿ��ϥ��饹�ѿ��Ǥ��ꡤ���Υ��饹�����ƤΥ��֥��饹�Υ���
-�����󥹤��黲�ȤǤ��롥�����ѿ��ؤ������ϥȥåץ�٥롤���ʤ���᥽��
-�ɤ�����Ǥ����٥�ǤΤ߲�ǽ�Ǥ��롥�����ѿ��ϥ��饹�֤��ͤ���ͭ���졤
-������������ȥ᥽�åɤ�����ͤ��ѹ����뤳�Ȥ��Ǥ��ʤ��Τǡ�����Ȥ���
-�Ѥ����롥
+��:
+
+ %foobar
+
+`%'�ǻϤޤ��ѿ��ϥ��饹����Ǥ��ꡤ���Υ��饹�����ƤΥ��֥��饹�Υ���
+�����󥹤��黲�ȤǤ��롥��������ؤϥȥåץ�٥롤���ʤ���᥽�åɤ���
+���Ǥ����٥�ǤΤ�������ǽ�Ǥ��롥�����ѿ��ϥ��饹�֤��ͤ���ͭ���졤
+��������������ͤ��ѹ����뤳�Ȥ��Ǥ��ʤ���
-**** �����ѿ�
+*** �����ѿ�
�̾���ѿ��ʳ��˵����ѿ��ȸƤФ���ü���ѿ���4�Ĥ��롥
@@ -251,31 +289,109 @@ Ruby���ѿ��ϥ�������(ͭ���ϰ�)�ȼ�̿(ͭ������)�ˤ�ä�4�����ʬ�व�졤
�����ε����ѿ��������ˤ�äƤ����ͤ��ѹ����뤳�ȤϤǤ��ʤ���������
�ѿ��ؤ��������㳰��ȯ�������롥
-*** ��������
+** ��̤ˤ�륰�롼�ԥ�
+
+��:
+
+ (1+2)*3
+ (foo();bar())
+
+���ϳ�̤ˤ�äƥ��롼�ԥ󥰤��뤳�Ȥ��Ǥ��롥
+
+ `(' �� `)'
+
+��̤���ˤ�ñ�ʤ뼰�����ǤϤʤ��������¤�(��ץ������)���֤����Ȥ���
+��롥
+
+ `(' �� `;' ��... `)'
+
+�����¤Ӥ��ͤϺǸ��ɾ�����������ͤǤ��롥�Ĥޤ���ͤϺǸ��ɾ��������
+���ͤˤʤ롥
+
+** ����
+
+��:
+
+ [1, 2, 3]
+
+�����Array���饹�Υ��󥹥��󥹤Ǥ��롥������������뼰�ϰʲ��η�����
+���롥
+
+ `[' ��, ... `]'
+
+���줾��μ���ɾ��������̤�ޤ�������֤������ǿ���0�ζ������������
+�뤿��ˤ϶�������
+
+ `[' `]'
+
+���Ѥ��롥
+
+** Ϣ������
+
+��:
+
+ {1=>2, 2=>4, 3=>6}
+
+Ϣ������Ȥ�Ǥ�դΥ��֥������Ȥ򥭡�(ź��)�Ȥ��ƻ�������Ǥ��롥Ruby
+��Ϣ�������Dict(����)���饹�Υ��󥹥��󥹤Ǥ��롥�ܺ٤ϥ��饹Dict�ι�
+�򻲾Ȥ��줿����Ϣ���������������Ϣ�����󼰤ϰʲ��η����Ǥ��롥
+
+ `{' �� `=>' ��... `}'
+
+���줾��μ���ɾ��������̤򥭡����ͤȤ���Ϣ�����󥪥֥������Ȥ��֤���
+���ǿ���0��Ϣ��������������뤿��ˤ϶���Ϣ������
+
+ `{' `}'
+
+���Ѥ��롥���Ǥ�1�İʾ夢���硤ۣ��Ǥʤ����`{', `}'�Ͼ�ά�Ǥ��롥
+
+** �᥽�åɸƽм�
+
+��:
+
+ foo.bar()
+ foo.bar
+ bar()
���֥������Ȥ˥�å��������������Ū�ʹ�ʸ����å��������Ǥ��ꡤ���δ�
�ܷ����ϰʲ����̤�Ǥ��롥
- ��1 '.' �᥽�å�̾ '(' ����1... [',' '*' ����n ]')'
+ ��1 `.' �᥽�å�̾ `(' ����1... [`,' `*' ����n ]`)'
��1��ɾ�����������륪�֥������ȤΡ����̻Ҥǻ��ꤵ���᥽�åɤ�Ƥ�
-�Ф������ֺǸ�ΰ�����'*'��³��(ñ���)���Ǥ����硤���μ���ɾ������
-���(����Ǥ���ɬ�פ�����)��Ÿ�����ơ������Ȥ����ɲä��롥
+�Ф������ֺǸ�ΰ�����`*'��³��(ñ���)���Ǥ����硤���μ���ɾ������
+���(����Ǥʤ�����Ѵ������)��Ÿ�����ơ������Ȥ����ɲä��롥
+
+��å��������ǡ��쥷���Ф�self�ξ�硤�쥷���Ф��ά�����̾�Υץ�����
+�ߥ󥰸���ˤ�����ؿ��Τ褦�ʷ����ǥ᥽�åɤ�ƤӽФ����Ȥ��Ǥ��롥
-��������Ĥ�ʤ����ˤϳ�̤��ά�Ǥ��롥
+�᥽�åɸƤӽФ��Ǥ�ۣ�椵���ʤ����ˤϳ�̤��ά�Ǥ��롥ۣ�椵�������
+�Ȥ����������ʲ���ʸ���ޤ���ͽ���ǻϤޤ���Ǥ��롥
+
+ (, [, {, <, /, %, +, -, if, while
+
+�㡧
+ foo bar+baz # �᥽�åɸƤӽФ�foo(bar+baz)
+ foo (1+2)*5 # �᥽�åɸƤӽФ�(foo(1+2)) * 5
+ foo 1 # �᥽�åɸƤӽФ�foo(1)
+ foo -1 # ���������ѿ�foo - 1
+
+�쥷���Ф���ꤷ���᥽�åɸƤӽФ��ǤϤξ�������1�Ĥ�ʤ����ˤ���
+���ά�Ǥ��롥
�᥽�å�̾�Ȥ��Ƥ�Ǥ�դμ��̻Ҥ��Ѥ��뤳�Ȥ��Ǥ��롥�ѿ�̾�Ȥϼ��̻Ҥ�
̾�����֤��㤦�Τǽ�ʣ���Ƥ⹽��ʤ���
-��å��������ǡ��쥷���Ф�self�ξ�硤�쥷���Ф��ά�����̾�Υץ�����
-�ߥ󥰸���ˤ�����ؿ��Τ褦�ʷ����ǥ᥽�åɤ�ƤӽФ����Ȥ��Ǥ��롥��
-�ξ�������1�Ĥ�ʤ����Ǥ��̤ξ�ά�ϤǤ��ʤ���
-
-���饹���ʸ�γ��ǻ��ꤵ�줿�᥽�åɤȥ��饹Module��noexport�᥽�åɤ�
+���饹���ʸ�γ��ǻ��ꤵ�줿�᥽�åɤȥ��饹Module��unexport�᥽�åɤ�
���ꤵ�줿�᥽�åɤϴؿ�Ū�᥽�åɤȸƤФ졤�ؿ������Ǥ����ƤӽФ�����
-���Ǥ��ʤ���
+���Ǥ��ʤ�(DEF����)��
+
+** SUPER
-*** �����ѡ����饹�Υ᥽�åɸƤӽФ�
+��:
+
+ super
+ super(1,2,3)
��å����������ü�ʥ������Ȥ��ƥ����ѡ����饹�Υ᥽�åɤθƤӽФ�����
�롥���η����ϥ᥽�åɤ������������˥����ѡ����饹����������Ѥ��뤿
@@ -284,70 +400,106 @@ Ruby���ѿ��ϥ�������(ͭ���ϰ�)�ȼ�̿(ͭ������)�ˤ�ä�4�����ʬ�व�졤
super
���ߤΥ᥽�åɤ�Ϳ����줿�����Τޤޥ����ѥ��饹��Ʊ̾�Υ᥽�åɤ�Ƥ�
-����
+�Ф��������Ȥ���Ϳ����줿�ѿ����ͤ��ѹ����Ƥ⡤�Ϥ����Τϸ��ΰ�����
+�ͤǤ��롥
- super'(' ����... ')'
+ super`(' ����... `)'
�����ȤȤ�˥����ѡ����饹��Ʊ̾�Υ᥽�åɤ�ƤӽФ������ֺǸ�ΰ�����
-`*'��³�������̾�Υ᥽�åɸƤӽФ���Ʊ�ͤ��Ϥ���롥
+`*'��³�������̾�Υ᥽�åɸƤӽФ���Ʊ�ͤ�Ÿ�������Ϥ���롥
-*** ����/Ϣ������
+** ����
-����Υ��֥������Ȥ��������뼰�η����ϰʲ��η����Ǥ��롥
+��:
- '[' ��, ... ']'
+ foo = bar
+ foo[0] = bar
+ foo.bar = baz
-���줾��μ���ɾ��������̤�ޤ�������֤������ǿ���0�ζ������������
-�뤿��ˤ϶�������
+�����ˤ��ѿ����Ф�������(��������)�ȡ��ץ��������ñ�ˤ��뤿��Υ���
+���å������奬���Ȥ��Ƥ����������롥���������ϰʲ��η����Ǥ��롥
- '[' ']'
+ �ѿ� `=' ��
-���Ѥ��롥
+����ϼ���ɾ�������ѿ����ͤȤ����������롥���饹��⥸�塼��䵿���ѿ�
+�ˤ������Ǥ��ʤ������饹��⥸�塼���������ѹ����뤿��ˤ�class����
+module�����Ѥ��롥�������ϱ黻�ҷ�����ȤäƤ��뤬���᥽�åɤǤϤʤ���
+�Ǻ�������뤳�ȤϤǤ��ʤ���
-** Ϣ������
+���󥿥å������奬���Ȥ��Ƥ��������ϰʲ��Τ�Τ����롥
-Ϣ������Ȥ�Ǥ�դΥ��֥������Ȥ򥭡�(ź��)�Ȥ��ƻ��Ƥ�����Ǥ��롥Ruby
-�Ǥ�Ϣ�������Smalltalk���Ѹ��ڤ��Dict(����)�Ȥ�ƤФ�롥�ܺ٤ϥ�
-�饹Dict�ι�򻲾Ȥ��줿����Ϣ���������������Ϣ�����󼰤ϰʲ��η�����
-���롥
+�������Ǥؤ�����
- '{' �� '=>' ��... '}'
+ ��1`[' ��2... `]' `=' ��n
-���줾��μ���ɾ��������̤򥭡����ͤȤ���Ϣ�����󥪥֥������Ȥ��֤���
-���ǿ���0��Ϣ��������������뤿��ˤ϶���Ϣ������
+��1��ɾ�����������륪�֥������Ȥˡ���2���鼰n�ޤǤ�����Ȥ��ơ�"[]="
+�Ȥ����᥽�åɤ�ƤӽФ���
- '{' '}'
+°������
-���Ѥ��롥
+ ��1 `.' ���̻� `=' ��2
+
+��1��ɾ�����������륪�֥�������(�쥷���Ф���ά���줿����`self')��
+�Ф��ơ�"���̻�="�Ȥ����᥽�åɤ� 2������Ȥ��ƸƤӽФ���
+
+** ��������
+
+��:
+
+ foo += 12
+
+�����ͤ��Τ�Τ˱黻��ä��뤿��˼����������������롥
+
+ ��1 op= ��2 # ��1��������ǽ�Ǥʤ���Фʤ�ʤ���
+
+���η���������Ū�ˡּ�1 = ��1 op ��2�פ�Ʊ�ͤ�ɾ������롥����������1
+��1�󤷤�ɾ������ʤ��Τǡ���1�������Ѥ�������ϡ��ּ�1 = ��1 op ��2��
+�Ȥ�ư��ۤʤ��̤Ȥʤ롥op�Ȥ��ƻȤ���黻�Ҥ�
+
+ +, -, *, /, %, **, &, |, ^, <<, >>
+
+��11����Ǥ��롥�黻�Ҥ�`='�δ֤˥��ڡ���������ƤϤ����ʤ���
-*** ���󻲾ȡ���������
+** ¿������
-����(Ϣ�������ޤ�)�����Ǥλ��Ȥϰʲ��η����ǹԤʤ���
+��:
- ��1 '[' ��2... ']'
+ foo, bar, baz = 1, 2, 3
+ foo, = list()
+ foo, *rest = list2()
-���η���������Ū�ˡ���1��"[]"�Ȥ�����å�����������Ȳ�ᤵ��롥����
-ư��򵿻�Ū�ʥ����ɤǵ��Ҥ���аʲ��Τ褦�ˤʤ롥
+Ʊ����ʣ�����ѿ���������Ԥʤ����Ȥ��Ǥ��롥���η����ϰʲ����̤�Ǥ��롥
- ��1"[]"(��2...)
+ ���� `,' [���� `,' ...] [`*' ����]= �� [, ��...]
-�������������Ǥ�������
+���դμ�����Ĥ����ʤ����ϡ������ͤ�����Ȥ���(ɬ�פʤ��to_a�᥽��
+�ɤ�������Ѵ�����)�����Ǥ򤽤줾�캸�դ��������롥����ʳ��ξ��ˤϡ�
+���줾��μ����ͤ����դ���������롥���դο��ȱ��դ����Ǥο������ʤ�
+���ˤ�­��ʤ��ѿ��ˤ� nil���������졤;�ä����Ǥ�̵�뤵��롥¿������
+�κǸ�����Ǥ�����`*'�������硤�Ĥ�����ư���������Ȥ�����������롥
- ��1 '[' ��2... ']' '=' ��n
+ foo, bar = [1, 2] # foo = 1; bar = 2
+ foo, bar = 1, 2 # foo = 1; bar = 2
+ foo, bar = 1 # foo = 1; bar = nil
+
+ foo, bar, baz = 1, 2 # foo = 1; bar = 2; baz = nil
+ foo, bar = 1, 2, 3 # foo = 1; bar = 2
+ foo,*bar = 1, 2, 3 # foo = 1; bar = [2, 3]
-�Ȥ��������ǹԤʤ�졤
+¿���������ͤ�(������Ѵ����줿)���դǤ��롥
- ��1."[]="(��2...)
+** �黻�Ҽ�
-�Ȥ��������Ȥ��Ʋ�ᤵ��롥
+��:
-*** �黻�ҷ���
+ 1+2*3/4
�ץ�����ߥ󥰤����ؤΤ���˰����Υ᥽�åɸƤӽФ������湽¤�ϱ黻�ҷ�
����Ȥ롥Ruby�ˤϰʲ��ˤ�����黻�Ҥ����롥��Τ�Τۤɷ���̤�������
Ʊ����α黻�Ҥη���̤�Ʊ���Ǥ��롥
- �� -(unary) +(unary) ! ~
+ �� [](���󻲾�), []=(��������)
+ -(unary) +(unary) ! ~
**
* / %
+ -
@@ -362,110 +514,77 @@ Ruby���ѿ��ϥ�������(ͭ���ϰ�)�ȼ�̿(ͭ������)�ˤ�ä�4�����ʬ�व�졤
::
=(����) ��������(+=, -=, ..)
and
- �� or
+ or
+ �� if������ while������
�ۤȤ�ɤα黻���ˤϥ᥽�åɸƤӽФ��Ȥ��Ʋ�ᤵ���(���饹��˺����
�Ǥ���)��������������Ǥ��ʤ��ü�ʤ�Τ����롥������Ǥ��ʤ��ü�黻
�Ҥ�
- &&(������), ||(������), =(����), ...(�ϰϻ���), and, or
+ =(����), ...(�ϰ�), !(����), &&(������), and, |(������), or,
+ if������, while������
-��6�ĤǤ��롥
+��9�Ĥα黻�ҤȤ����Ȥ��Ȥ߹�碌�ˤʤ� !=, !~ ����Ӽ��������黻��
+�Ǥ��롥
-��Ǥ������ü�黻�Ұʳ��α黻�ҷ����ϥ᥽�åɸƤӽФ��ȸ��ʤ���롥
-ñ��黻��(+, -, !, ~)��
-
- ��1."�黻��"()
-
-�Ȥ��������ˡ�����ʳ���2��黻�Ҥ�
-
- ��1."�黻��"(��2)
-
-�˲�ᤵ��롥
-
-** ����
+��Ǥ������ü�黻�Ұʳ��α黻�ҷ����ϰʲ��Τ褦�ʥ᥽�åɸƤӽФ��ȸ�
+�ʤ���롥
-�����ˤ��ѿ����Ф�������(��������)�ȡ��ץ��������ñ�ˤ��뤿��Υ���
-���å������奬���Ȥ��Ƥ����������롥���������ϰʲ��η����Ǥ��롥
-
- �ѿ� '=' ��
+ñ��黻��(+, -, ~)
-����ϼ���ɾ�������ѿ����ͤȤ����������롥���饹��⥸�塼��䵿���ѿ�
-�ˤ������Ǥ��ʤ������饹��⥸�塼���������ѹ����뤿��ˤ�classʸ��
-moduleʸ���Ѥ��롥�������ϱ黻�ҷ�����ȤäƤ��뤬���᥽�åɤǤϤʤ���
-�Ǻ�������뤳�ȤϤǤ��ʤ���
+ ��1. �黻�� ()
-���󥿥å������奬���Ȥ��Ƥ��������ϰʲ��Τ�Τ����롥
+����(Ϣ�������ޤ�)�����Ǥλ���(��1 `[' ��2... `]')
-�������Ǥؤ�����
+ ��1. `[]' (��2...)
- ��1'[' ��2... ' ]' '=' ��n
+�������Ǥ�����( ��1 `[' ��2... `]' `=' ��n)
-��1��ɾ�����������륪�֥������Ȥˡ���2���鼰n�ޤǤ�����Ȥ��ơ�"[]="
-�Ȥ����᥽�åɤ�ƤӽФ���
+ ��1. `[]=' (��2...)
-°������
+����ʳ���2��黻��(�� �黻�� ��)
- ��1 '.' ���̻� '=' ��2
+ ��1. �黻�� (��2)
-��1��ɾ�����������륪�֥������Ȥ��Ф���"���̻�="�Ȥ����᥽�åɤ򡤼�
-2������Ȥ��ƸƤӽФ���
+����Ϥ����ޤǤ⤽�����������Υ᥽�åɸƤӽФ��Ȥ��Ʋ�ᤵ���Ȥ�����
+���ǡ�ruby�ץ������Ǥ����������Ҥ��������Ȥ����櫓�ǤϤʤ���
-��������
-
- ��1 op= ��2 # ��1��������ǽ�Ǥʤ���Фʤ�ʤ���
-
-���η���������Ū�ˡּ�1 = ��1 op ��2�פ�Ʊ�ͤ�ɾ������롥����������1
-��1�󤷤�ɾ������ʤ��Τǡ���1�������Ѥ�������ϡ��ּ�1 = ��1 op ��2��
-�Ȥ�ư��ۤʤ��̤Ȥʤ롥op�Ȥ��ƻȤ���黻�Ҥ�
-
- +, -, *, /, %, **, &, |, ^, <<, >>
-
-��11����Ǥ��롥�黻�Ҥ�`='�δ֤˥��ڡ���������ƤϤ����ʤ���
-
-*** ���ʬ����
-
-�����ͤˤ�ä�ʬ�����뼰�ϰʲ��˼���if����unless����case����ʣ��ʸ����
-3����ȱ黻�ҷ���3���ढ�롥Ruby�Ǥ�nil����������ʳ�������ɾ������롥
-C��Perl�ʤɤȤϰۤʤꡤ0�� ""(��ʸ����)�ϵ��Ȥ�ɾ������ʤ��Τǵ����
-���뤳�ȡ�
-
-if��
+** IF
if ��1 [then]
- ʸ1
+ ��1
[elsif ��2 [then]
- ʸ2 ]...
+ ��2 ]...
[else
- ʸn ]
+ ��n ]
end
-���Ƚ�Ǽ�����1�����ξ���ʸ1��ɾ�����롥����ʳ��ξ���ʸ2��ɾ����
+���Ƚ�Ǽ�����1�����ξ��˼�1��ɾ�����롥����ʳ��ξ��ϼ�2��ɾ����
�롥Ruby��if����else if�Ǥ�elif�Ǥ�ʤ�elsif��if��Ϣ³��Ԥʤ����Ȥ���
�դ��뤳�ȡ�
-unless��
+if�ξ��Ƚ�����μ��Ǥ�ʸ���������ɽ����ƥ��ϼ���$_=~ ��ƥ��פ�
+��ά�Ǥ���Ȥߤʤ���롥
- unless ��1 [then]
- ʸ1
- [else
- ʸ2 ]
- end
+** IF������
+
+ �� if ��
-��1����(nil)���֤�������2��ɾ������㳰��ȯ����������ʸ1��ɾ�����롥
-����ʳ��ξ���ʸ2��ɾ�����롥
+��、����(if)�μ�����Ԥ��뼰������ä�ɾ������롥ư����б�����if��
+��Ʊ�ͤǤ��롥if�����ҤΤĤ��������ͤϾ�郎��Ω�������ˤϼ����͡���
+��Ω�ξ��ˤ�nil�Ǥ��롥
-case��
+** CASE
case ��0
[when ��1 [, ��2]... [then]
- ʸ1 ]..��
+ ��1 ]..��
[else
- ʸn ]
+ ��n ]
end
���ʬ����C��switch����Pascal��case�˻��Ƥ��롥break��æ�Ф��뤳�Ȥ�
-�����ʸ�˷�³���뤳�Ȥ�ʤ��Τ����ա�
+����μ��˷�³���뤳�Ȥ�ʤ��Τ����ա�
���ΰ��פϡּ�n =~ ��0]�ǹԤʤ��롥�Ĥޤꡤ
@@ -478,7 +597,7 @@ case��
stmt3
end
-�ϰʲ���ifʸ�Ȥۤ������Ǥ��롥
+�ϰʲ���if���Ȥۤ������Ǥ��롥
_tmp = expr0
if expr1 =~ _tmp || expr2 =~ _tmp
@@ -489,67 +608,77 @@ case��
stmt3
end
-�黻�ҷ�
+** AND ��
- ��1 '&&' ��2
- ��1 'and' ��2
+ ��1 `&&' ��2
+ ��1 `and' ��2
��1��ɾ�����������ͤ���(nil�ʳ�)�Ǥ���С���2��ɾ�����롥`and'��ͥ���
�̤��㤤��̾�Ǥ��롥
- ��1 '||' ��2
+and��ξ�դμ��Ǥ�ʸ���������ɽ����ƥ��ϼ���$_=~ ��ƥ��פξ�ά��
+����Ȥߤʤ���롥
+
+** OR ��
+
+ ��1 `||' ��2
��1 'or ��2
��1��ɾ�����������ͤ����Ǥ���С���2��ɾ�����롥`or'��ͥ���̤��㤤��
̾�Ǥ��롥
- ��1 '...' ��2
+or��ξ�դμ��Ǥ�ʸ���������ɽ����ƥ��ϼ���$_=~ ��ƥ��פξ�ά��
+����Ȥߤʤ���롥
-��1�����ˤʤ�ޤǤϵ����֤������θ�ϼ�2�������֤��ޤǤϿ����֤�����2
-�����ˤʤ�о��֤ϵ������
+** �ϰϻ��꼰
-*** �����֤���(ñ�㷿)
+ ��1 `...' ��2
-�롼�פ������뼰�������μ����ͤϾ��nil�Ǥ��롥���֥������Ȥ˹��
-�����롼�פ�Ԥʤ�����ˤϼ��˽Ҥ٤륤�ƥ졼�����Ѥ��롥
+��1�����ˤʤ�ޤǤϵ����֤������θ�ϼ�2�������֤��ޤǤϿ����֤�����2
+�����ˤʤ�о��֤ϵ�����롥
-while��
+�黻��`...'��ξ�դϾ�P�Ǥ��ꡤ���� `...'��ξ�դμ��Ǥ�ʸ���������
+ɽ����ƥ��ϼ���$_=~ ��ƥ��פξ�ά�������������$.==����פξ�ά
+�Ȳ�ᤵ��롥
- while ��
- ʸ
- end
+** NOT ��
-��郎���δ֡�ʸ�򷫤��֤��¹Ԥ��롥
+ `!' ��
-until��
+�������Ǥ���е������Ǥ���п����֤���
- until ��
- ʸ
- end
- ��1 until ��2
+`!'���Ǥ�ʸ���������ɽ����ƥ��ϼ���$_=~ ��ƥ��פξ�ά�Ǥ���Ȥ�
+�ʤ���롥
-������(nil)���֤���������ɾ������㳰��ȯ������֡�ʸ�򷫤��֤��¹Ԥ�
-�롥
-*** ��P�ˤĤ���
+ ��1 `!=' ��2
+
+��!(��1 == ��2)�פξ�ά��
-if��unless��while��until�ξ��Ƚ�����μ���������ü�黻��`&&', `||',
-`...'��ξ�դμ��Ͼ�P�ȸƤФ�롥��P�Ǥ�ʸ���������ɽ����ƥ��
-�ϼ���$_=~��ƥ��פξ�ά�Ǥ���Ȥߤʤ���롥���˱黻��`...'��ξ�դ�
-�������������$.==����פξ�ά�Ȳ�ᤵ��롥��P�˸����`!'�黻�Ҥ�
-���ڥ��ɤ��P�Ȥߤʤ���롥
+ ��1 `!~' ��2
-����: �黻��`!'���ü�黻�ҤǤϤʤ��Τǡ��������Ԥʤ����˵���Ĥ�
-�뤳�ȡ���P�����
+��!(��1 ~= ��2)�פξ�ά��
+
+** WHILE
+
+ while ��
+ ��
+ end
- ! ʸ�����ƥ��
- ! ����ɽ����ƥ��
+����ɾ�������ͤ����δ֡����򷫤��֤��¹Ԥ��롥while�����ͤ�nil�Ǥ��롥
-�η��ǸƤӽФ����᥽�åɤΰ����ϡ���ƥ���ɽ�����֥������ȤǤϤʤ���
-�嵭����Ӥη�̤�Ϳ�����롥���Τ��ᡤ��§Ū��`!'�᥽�åɤϺ������
-�ʤ������ɤ���
+while�ξ��Ƚ�����μ��Ǥ�ʸ���������ɽ����ƥ��ϼ���$_=~ ��ƥ���
+�ξ�ά�Ǥ���Ȥߤʤ���롥
-*** ���ƥ졼��(�����֤���)
+** WHILE ������
+
+ ñ�㼰 while ��
+
+�����֤�������(while)�Ϥޤ���Ԥ��뼰��ɾ�����Ƥ����P��ɾ�������
+�ǡ�������٤ϼ���¹Ԥ��뤳�Ȥˤʤ롥while�����ҤΤĤ��������ͤ�nil��
+���롥
+
+** ���ƥ졼��(�����֤���)
���ƥ졼���Ȥ����湽¤(�ä˥롼��)����ݲ��Τ�����Ѥ�����᥽�åɤ�
���Ǥ��롥�����ɤ�����(�֥��å��ȸƤФ��)����ꤷ�ƥ��ƥ졼����Ƥ�
@@ -561,205 +690,122 @@ if��unless��while��until�ξ��Ƚ�����μ���������ü�黻��`&&', `||',
���ƥ졼���Ȥ����湽¤(�ä˥롼��)����ݲ��Τ�����Ѥ�����᥽�åɤ�
���Ǥ��롥���ƥ졼���θƤӽФ��ϰʲ��ι�ʸ�ǹԤʤ��롥
- �� '{' �ѿ�... '|' ʸ... '}'
+ �� `{' �ѿ�... `|' ��... `}'
-��ʸ�פ�֥��å��Ȥ������ꤷ���ּ��פΥ᥽�åɤ򥤥ƥ졼���Ȥ���ɾ����
+�ּ��פ�֥��å��Ȥ������ꤷ���ּ��פΥ᥽�åɤ򥤥ƥ졼���Ȥ���ɾ����
�롥�ּ��פΥȥåץ�٥�Υ᥽�åɤ��������ƥ졼���Ȥ��ƸƤӽФ��졤
�쥷���Ф�ɽ�����䡤�����μ��ϥ��ƥ졼���Ȥ��ƤϸƤӽФ���ʤ����ּ���
��ʣ���μ���ޤ�����ơ������ƥ졼���Ȥ��ƽ�˸ƤФ�롥
-���ƥ졼�����yieldʸ���¹Ԥ����ȡ������ǻ��ꤵ�줿�ͤ�doʸ�ǻ��ꤵ
+���ƥ졼�����yield�����¹Ԥ����ȡ������ǻ��ꤵ�줿�ͤ�do���ǻ��ꤵ
�줿�ѿ����������졤�֥��å����¹Ԥ���롥�֥��å��μ¹Ԥ���λ����Ȥ�
-���ͤ� yieldʸ���ͤȤ����֤���롥����᥽�åɤ����ƥ졼���Ȥ��ƸƤӽ�
+���ͤ� yield�����ͤȤ����֤���롥����᥽�åɤ����ƥ졼���Ȥ��ƸƤӽ�
���줿���ɤ����ϥ᥽�å�iterator_p()������ͤ��Τ뤳�Ȥ��Ǥ��롥��ˤ�
Enumerable�⥸�塼���grep�᥽�åɤΤ褦�˥��ƥ졼���Ȥ��ƸƤФ줿����
���̤Υ᥽�åɤȤ��ƸƤФ줿���Ȥ�ư��ۤʤ�᥽�åɤ⤢�롥
+** FOR
+
���֥������Ȥγ����Ǥ��Ф�������Ԥʤ�����η������󶡤���Ƥ��롥��
���ϰʲ����̤ꡥ
for �ѿ�.. in ��
- ʸ
+ ��
end
-���γ����Ǥ��Ф�ʸ��¹Ԥ��롥����ϰʲ��μ��������Ǥ��롥
+���γ����Ǥ��Ф�����¹Ԥ��롥����ϰʲ��μ��������Ǥ��롥
- (��).each '{' �ѿ�.. '|' ʸ '}'
+ (��).each `{' �ѿ�.. `|' �� `}'
��äƼ����ͤΥ��֥������Ȥ��᥽�å�each������ʤ���硤for��¹Ԥ���
���㳰��ȯ�����롥
-*** ���ƥ졼������ǤΥ֥��å��ƤӽФ�
+** YIELD
- yield '(' [�� [',' ��...]])
+ yield `(' [�� [`,' ��...]])
yield
���ƥ졼������ǥ֥��å��θƤӽФ���Ԥʤ���yield��¹Ԥ����᥽�åɤ�
���ƥ졼���Ȥ��ƸƤӽФ���Ƥ��ʤ����ˤ��㳰��ȯ�����롥yield ���ͤϥ�
���å�������ͤǤ��롥
-*** �㳰����
+yield�ΰ����γ�̤�ۣ��Ǥʤ��¤��ά�Ǥ��롥
+
+** FAIL
+
+ fail `(' [������] `)'
+
+�㳰��ȯ�������롥��å�������Ϳ����줿���ˤ�ȯ�������������ե�����
+̾�����ֹ�򥷥��ƥ��ѿ�`$@'�ˡ���å�������`$!'�˥��åȤ��롥
+
+fail�ΰ����γ�̤�ۣ��Ǥʤ��¤��ά�Ǥ��롥
+
+** PROTECT
�������ͽ�����ʤ����֤�ȯ���������ˤ��㳰��ȯ�����롥Ruby�Ǥ��㳰����
�����ª���ơ��ƻ�Ԥ����ꡤ�������Ԥʤä��ꤹ�뤳�Ȥ��Ǥ��롥
protect
- ʸ1
+ ��1
[resque
- ʸ2 ]
+ ��2 ]
[ensure
- ʸ3]
+ ��3]
end
-ʸ1��¹Ԥ������μ¹�����㳰��ȯ�������resque��ǻ��ꤵ�줿ʸ2��¹�
-���롥����ensure�᤬¸�ߤ������protectʸ��λ��������ɬ��(���ェλ��
-�����Ǥʤ����㳰, return, break, continue, redo�ʤɤˤ��æ�ФǤ�)ʸ3
+��1��¹Ԥ������μ¹�����㳰��ȯ�������resque��ǻ��ꤵ�줿��2��¹�
+���롥����ensure�᤬¸�ߤ������protect����λ��������ɬ��(���ェλ��
+�����Ǥʤ����㳰, return, break, continue, redo�ʤɤˤ��æ�ФǤ�)��3
��¹Ԥ��롥
-unlessʸ��untilʸ�Ͼ���ɾ����������㳰��ȯ��������硤ɾ����̤���
-�Ǥ���ȸ��ʤ��Τǡ����ۤ��㳰������ԤʤäƤ��뤳�Ȥˤʤ롥
-
-*** ���롼�ԥ�
-
-���ϳ�̤ˤ�äƥ��롼�ԥ󥰤��뤳�Ȥ��Ǥ��롥
-
- '(' �� ')'
-
-���˳�̤��Ѥ��ơ�ʸ(�ޤ���ʸ���¤�)�򼰤ˤ��뤳�Ȥ�Ǥ��롥
-
- '(' ʸ ';' ʸ... ')'
-
-ʸ���¤Ӥ��ͤϺǸ��ɾ�����������ͤǤ��롥�Ĥޤ���ͤϺǸ��ɾ������ʸ
-���ͤˤʤ롥
-
-** ʸ
-
-Ruby�ץ�������������⤦��Ĥ����Ǥ�ʸ�Ǥ��롥ʸ�ˤ�ñ��ʸ������ʸ��
-���ʸ�����롥���̤�ʸ���ͤ��Ѥ��뤳�ȤϤʤ��������Ȥ����Ѥ�������
-�⤢��Τǡ��ͤ���ġ��̾��ʸ���ͤ�nil�Ǥ��롥
-
-*** ��
-
-����ñ��ʸ�Ǥ��롥
-
-*** ¿������
-
-Ʊ����ʣ�����ѿ���������Ԥʤ����Ȥ��Ǥ��롥���η����ϰʲ����̤�Ǥ��롥
-
- �ѿ� ',' [�ѿ� ',' ...] ['*' �ѿ�]= �� [, ��...]
-
-���դμ�����Ĥ����ʤ����ϡ������ͤ�����Ȥ���(ɬ�פʤ��to_a�᥽��
-�ɤ�������Ѵ�����)�����Ǥ򤽤줾���ѿ����������롥����ʳ��ξ��ˤϡ�
-���줾��μ����ͤ��ѿ�����������롥���դ��ѿ��ο��ȱ��դ����Ǥο�����
-��ʤ����ˤ�­��ʤ��ѿ��ˤ� nil���������졤;�ä����Ǥ�̵�뤵��롥¿
-�������κǸ�����Ǥ�����`*'�������硤�Ĥ�����ư���������Ȥ�������
-����롥
-
- foo, bar = [1, 2] # foo = 1; bar = 2
- foo, bar = 1, 2 # foo = 1; bar = 2
- foo, bar = 1 # foo = 1; bar = nil
-
- foo, bar, baz = 1, 2 # foo = 1; bar = 2; baz = nil
- foo, bar = 1, 2, 3 # foo = 1; bar = 2
- foo,*bar = 1, 2, 3 # foo = 1; bar = [2, 3]
-
-¿��������ñ��ʸ�Ǥ��롥�����ͤ�(������Ѵ����줿)���դǤ��롥
-
-*** ����ʸ
-
-�����ή����ѹ�����ʲ���ʸ�����롥������ñ��ʸ�Ǥ��롥
+** RETURN
-returnʸ
-
- return [��[',' ��...]]
+ return [��[`,' ��...]]
�����ͤ�����ͤȤ��ƥ᥽�åɤμ¹Ԥ�λ���롥����2�İʾ�Ϳ����줿��
�ˤϡ����������ǤȤ��������᥽�åɤ�����ͤȤ��롥������Ĥ�ʤ���
��ˤ� nil ������ͤȤʤ롥
-�롼������ʸ
+** BREAK
- continue
- redo
break
-�嵭3�Ĥϥ롼����ǻȤ���
-
-continue�Ϥ�äȤ���¦�Υ롼�פμ��η����֤���Ϥ�롥redo�ϥ롼�׾��
-�Υ����å���Ԥʤ鷺�����ߤη����֤�����ľ����break �ϥ롼�פ�æ�Ф�
-�롥C�Ȱ㤤��break�Ϥ�äȤ���¦�Υ롼�פ�æ�Ф�����Ѥ����������case
-��ȴ������Ѥϻ����ʤ���
-
-retryʸ
+break �ϥ롼�פ�æ�Ф��롥C�Ȱ㤤��break�Ϥ�äȤ���¦�Υ롼�פ�æ�Ф�
+����Ѥ����������case ��ȴ������Ѥϻ����ʤ���
- retry
-
-protectʸ��resque��ǻȤ���protectʸ��Ϥᤫ��¹Ԥ��롥�㳰������Ԥʤ�
-�Ƥ���ƻ�Ԥ���Τ˻Ȥ���resque��ʳ���retry���Ѥ���줿����㳰��ȯ
-�����롥
-
-failʸ
-
- fail '(' [������] ')'
- fail [������]
-
-�㳰��ȯ�������롥��å�������Ϳ����줿���ˤ�ȯ�������������ե�����
-̾�����ֹ�򥷥��ƥ��ѿ�`$@'�ˡ���å�������`$!'�˥��åȤ��롥
-
-yieldʸ
-
- yield �� [',' ��...]
-
-ʸ�Ȥ���yield���Ѥ��뤳�Ȥ�Ǥ��롥���ξ��ϼ����̤dz��ɬ�פϤʤ���
-
-*** �᥽�åɸƤӽФ�ʸ
-
-1�İʾ�ΰ�������ĥ᥽�åɸƤӽФ����ˤ�ۣ�椵���ʤ���С��������
-�̤dz��ɬ�פϤʤ������η����ϰʲ����̤�Ǥ��롥
-
- �� '.' �᥽�å�̾ ����1 ',' [����2...]['*' ����n]
- �᥽�å�̾ ����1 ',' [����2...]['*' ����n]
- super ����1 ',' [����2... ]['*' ����n]
-
-��ʸ���ϻ��ˡ����Τ褦�˲��Ǥ�����ϼ��Ȥ��Ƥβ�᤬ͥ�褵��롥
+** CONTINUE
+ continue
- foo bar+baz # �᥽�åɸƤӽФ�foo(bar+baz)
- foo (bar)+baz # �᥽�åɸƤӽФ�foo(bar) + bar
- foo 1 # �᥽�åɸƤӽФ�foo(1)
- foo -1 # ���������ѿ�foo - 1
+continue�Ϥ�äȤ���¦�Υ롼�פμ��η����֤���Ϥ�롥
-��̤Τʤ��᥽�åɸƤӽФ�ʸ��ñ��ʸ�Ǥ��롥
+** REDO
-*** ���潤����
+ redo
-ñ��ʸ�����潤���Ҥ��ղä�����Τ�ʸ�Ǥ���(ñ��ʸ�ǤϤʤ�)�������Ҥϰ�
-����4����Ǥ��롥
+redo�ϥ롼�׾��Υ����å���Ԥʤ鷺�����ߤη����֤�����ľ����
- ñ��ʸ if ��
- ñ��ʸ unless ��
- ñ��ʸ while ��
- ñ��ʸ until ��
+** RETRY
-��、����(if/unless)�μ�����Ԥ���ʸ������ä�ɾ������롥ư����б�
-������ʬ������Ʊ�ͤǤ��롥
+ retry
-�����֤�������(while/until)�Ϥޤ���Ԥ���ʸ��ɾ�����Ƥ����P��ɾ��
-����Τǡ�������٤�ʸ��¹Ԥ��뤳�Ȥˤʤ롥
+protect����resque��ǻȤ���protect����Ϥᤫ��¹Ԥ��롥�㳰������Ԥʤ�
+�Ƥ���ƻ�Ԥ���Τ˻Ȥ���resque��ʳ���retry���Ѥ���줿����㳰��ȯ
+�����롥
-*** ���饹���ʸ
+** ���饹���
-���饹��������빽ʸ�ϰʲ����̤�Ǥ��롥
+���饹��������빽���ϰʲ����̤�Ǥ��롥
- class ���饹̾ [':' �����ѡ����饹̾ ]
+ class ���饹̾ [`:' �����ѡ����饹̾ ]
�������
end
���饹̾��Ǥ�դμ��̻ҤǤ���(��ʸ���ǻϤ�뤳�Ȥ�侩����)�����饹���
-�Υͥ��ȤϤǤ��ʤ��Τ�¾�����ʸ��Ǥϥ��饹������Ǥ��ʤ���
+�Υͥ��ȤϤǤ��ʤ��Τ�¾���������Ǥϥ��饹������Ǥ��ʤ���
-*** �⥸�塼�����ʸ
+** �⥸�塼�����
-�⥸�塼���������빽ʸ�ϰʲ����̤�Ǥ��롥
+�⥸�塼���������빽���ϰʲ����̤�Ǥ��롥
module ���饹̾
�������
@@ -768,27 +814,13 @@ yieldʸ
�⥸�塼��̾����ʸ���ǻϤޤ뼱�̻ҤǤ��롥���饹Ʊ�͡��⥸�塼�������
�ͥ��ȤǤ��ʤ���
-*** ���󥯥롼��ʸ
-
-�⥸�塼��򥤥󥯥롼�ɤ��뤳�Ȥˤ�äơ����饹�ޤ��ϥ⥸�塼��˵�ǽ
-���ɲäǤ��롥�⥸�塼��򥤥󥯥롼�ɤ�����硤���Υ⥸�塼��(�����
-���Υ⥸�塼�뤬���˥��󥯥롼�ɤ��Ƥ���⥸�塼��)�����ƤΥ᥽�åɤ�
-�����Ѥ����̤Τ������򤹤�Х��󥯥롼�ɤϸ��ꤵ�줿¿�ŷѾ��Ȥ����롥
-
-¾�Υ⥸�塼��򥤥󥯥롼�ɤ��빽ʸ�ϰʲ����̤�Ǥ��롥
-
- include �⥸�塼��̾ [',' �⥸�塼��̾...]
-
-���ߤ������Υ��饹�ޤ��ϥ⥸�塼��(�ȥåץ�٥�Ǥ�Object���饹)�˻�
-�ꤷ���⥸�塼��򥤥󥯥롼�ɤ��롥
-
-*** �᥽�å����ʸ
+** �᥽�å����
�̾�(�ðۥ᥽�åɤǤʤ�)�᥽�å�����η����ϰʲ����̤�Ǥ��롥�̾�᥽��
-������ϥͥ��ȤǤ��ʤ��Τǡ��᥽�å����ʸ��Ǥϥ᥽�å����ʸ��ƤӸ�
+������ϥͥ��ȤǤ��ʤ��Τǡ��᥽�å��������Ǥϥ᥽�å��������ƤӸ�
�ӽФ��ʤ���
- def �᥽�å�̾ ['(' ���� [',' ����...][',' '*'���� ] ')']
+ def �᥽�å�̾ [`(' ���� [`,' ����...][`,' `*'���� ] `)']
�������
end
@@ -798,17 +830,22 @@ yieldʸ
�᥽�åɤˤϴؿ�Ū�᥽�åɤ��̾�᥽�åɤ����롥�ؿ�Ū�᥽�åɤϴؿ���
���Ǥ����ƤӽФ����Ȥ��Ǥ�������äƳ������륯�饹�Ȥ��Υ��֥��饹�Υ�
-���åɤ��餷���ƤӽФ����Ȥ��Ǥ��ʤ������饹���ʸ�γ��ˤ���defʸ�ϴ�
-��Ū�᥽�åɤ�����������饹���ʸ����ˤ���defʸ���̾�Υ᥽�åɤ���
-�����롥�᥽�åɤβĻ�����Module���饹��export/noexport�᥽�åɤ�Ȥ�
-���ѹ����롥
+���åɤ��餷���ƤӽФ����Ȥ��Ǥ��ʤ���
+
+�����˥᥽�åɤ���������硤���饹������γ��ˤ���def���ϴؿ�Ū�᥽��
+�ɤ�����������饹���������ˤ���def�����̾�Υ᥽�åɤ�������롥����
+�ѡ����饹�Υ᥽�åɤ�����������ˤ���������᥽�åɤβĻ����ϥ���
+�ѡ����饹�Υ᥽�åɤΤ�Τ�����Ѥ���
-** �ðۥ᥽�å����ʸ
+�᥽�åɤβĻ������ѹ�������ˤ�Module���饹��export/unexport�᥽��
+�ɤ��Ѥ��롥
+
+** �ðۥ᥽�å����
�᥽�å�����ˤϤ⤦����ðۥ᥽�åɤ���������롥�ðۥ᥽�åɤȤϤ���
����Υ��֥������Ȥ˸�ͭ�Υ᥽�åɤǤ��롥�����ϰʲ����̤�Ǥ��롥
- def �� '.' �᥽�å�̾ ['(' ���� [',' ����...][',' '*'���� ] ')']
+ def �� `.' �᥽�å�̾ [`(' ���� [`,' ����...][`,' `*'���� ] `)']
�������
end
@@ -821,7 +858,21 @@ yieldʸ
�Υ��֥��饹�ˤ�Ѿ�����롥�����ؤ���Х��饹���ðۥ᥽�åɤ�¾�Υ���
�������Ȼظ������ƥ�ˤ����륯�饹�᥽�åɤ�Ư���򤹤롥
-*** �᥽�åɤ���̾���ʸ
+** INCLUDE
+
+�⥸�塼��򥤥󥯥롼�ɤ��뤳�Ȥˤ�äơ����饹�ޤ��ϥ⥸�塼��˵�ǽ
+���ɲäǤ��롥�⥸�塼��򥤥󥯥롼�ɤ�����硤���Υ⥸�塼��(�����
+���Υ⥸�塼�뤬���˥��󥯥롼�ɤ��Ƥ���⥸�塼��)�����ƤΥ᥽�åɤ�
+�����Ѥ����̤Τ������򤹤�Х��󥯥롼�ɤϸ��ꤵ�줿¿�ŷѾ��Ȥ����롥
+
+¾�Υ⥸�塼��򥤥󥯥롼�ɤ��빽���ϰʲ����̤�Ǥ��롥
+
+ include �⥸�塼��̾ [`,' �⥸�塼��̾...]
+
+���ߤ������Υ��饹�ޤ��ϥ⥸�塼��(�ȥåץ�٥�Ǥ�Object���饹)�˻�
+�ꤷ���⥸�塼��򥤥󥯥롼�ɤ��롥
+
+** ALIAS
�ʲ��η����ǥ᥽�åɤ���̾��Ĥ��뤳�Ȥ��Ǥ��롥
@@ -831,28 +882,20 @@ yieldʸ
���åɤ����������Ƥ⡤�Ť��᥽�åɤ��ƤӽФ��줿�Τ�����Ʊ��Ư����
�롥
-*** �᥽�å�������ä�ʸ
+** UNDEF
�᥽�åɤ��������ä�����ˤ�undef���Ѥ��롥
undef �᥽�å�̾
-���̻Ҥޤ���ʸ����ǻ��ꤷ���᥽�åɤ��������ä���
+���ꤷ���᥽�åɤ��������ä���
def�ˤ����̾�����undef�ˤ��������ä���Ȥ��ȥ��饹�Υ��󥿥ե���
-���򥹡��ѡ����饹����Ω���ѹ����뤳�Ȥ��Ǥ��롥���������᥽�åɤ�self
-�˥�å����������äƤ�����ˤϤ褯���դ��ʤ��ȴ�¸�Υ᥽�åɤ�ư�
-�ʤ��ʤ��ǽ�������롥
-
--------------------------------------------------------
-* Ruby���Ȥ߹��ߵ�ǽ
+���򥹡��ѡ����饹����Ω���ѹ����뤳�Ȥ��Ǥ��롥���������᥽�åɤ�self
+�˥�å����������äƤ�����⤢��Τǡ��褯���դ��ʤ��ȴ�¸�Υ᥽�å�
+��ư��ʤ��ʤ��ǽ�������롥
-Ruby�ץ�����ߥ󥰤δ��ܤϥ��饹���⥸�塼��Ȥ��Υ᥽�åɤν����Ǥ��롥
-Ruby�ˤϽ����Ϥ��Τ�Τ˰ʲ��ε�ǽ���Ȥ߹��ޤ�Ƥ��롥�饤�֥������
-�ɤ��뤳�Ȥˤ�äƵ�ǽ�������뤬�������˴ؤ��ƤϤ��줾��Υ饤�֥��
-�Υɥ�����Ȥ򻲾Ȥ��Ƥ�餤������
-
-** �ؿ�
+* �Ȥ߹��ߴؿ�
Ruby�ˤϸ�̩�ʰ�̣�Ǥϴؿ��Ϥʤ���Kernel���饹�δؿ��᥽�åɤ�(���Ƥ�
�̾說�饹����ؿ������ǸƤӽФ���Τ�)���ؿ�Ū���Ѥ����롥�ؿ�Ū��
@@ -1081,7 +1124,7 @@ Ruby�ˤϸ�̩�ʰ�̣�Ǥϴؿ��Ϥʤ���Kernel���饹�δؿ��᥽�åɤ�(���Ƥ�
��������Ƥ��ʤ��ޥ���Ǥ�flags�Ϥ��Ĥ�nil�ޤ���0�Ǥʤ���Ф�
��ʤ���
-** �����ƥ��ѿ�
+* �Ȥ߹����ѿ������
$! ���顼��å�������fail�����ꤹ�롥
@@ -1180,7 +1223,6 @@ Ruby�ˤϸ�̩�ʰ�̣�Ǥϴؿ��Ϥʤ���Kernel���饹�δؿ��᥽�åɤ�(���Ƥ�
$VERSION ruby�ΥС������򼨤�ʸ����
-** �����ƥ����
%TRUE t
%FALSE nil
@@ -1201,9 +1243,9 @@ Ruby�ˤϸ�̩�ʰ�̣�Ǥϴؿ��Ϥʤ���Kernel���饹�δؿ��᥽�åɤ�(���Ƥ�
�ϴ����ˤ�Ʊ���ǤϤʤ���%FALSE�˴ؤ��Ƥϡ����Τ褦�����������
�ʤ���
-** ���饹/�⥸�塼��
+* �Ȥ߹��ߥ��饹�ȥ⥸�塼��
-*** Array(���饹)
+** Array(���饹)
������ź���Ȥ�������Υ��饹�Ǥ��롥�����ϰ���Ū�ˤ�����``[...]''��
�Ԥʤ��롥
@@ -1385,7 +1427,13 @@ Methods:
obj���������Ƭ���ɲä��롥
-*** Bignum(���饹)
+Single Methods:
+
+ Array[item...]
+
+ ���������ǤȤ���������������롥
+
+** Bignum(���饹)
̵��¿��Ĺ�����Υ��饹���黻�η�̤�����Fixnum���ϰ���Ǥ�����ˤϼ�
ưŪ�˥��饹��Fixnum���Ѵ�����롥����Ū��Ruby�ץ������Ǥ�Fixnum��
@@ -1425,7 +1473,7 @@ Methods:
���Ⱦ�;��2���Ǥ�������֤���
-*** Block(���饹)
+** Block(���饹)
���ƥ졼�����Ϥ�����³����ޤȤ᤿���֥������ȡ��¹Ԥ��륳���ɤ�����
�ʤ�����ƥ�����(���������ѿ�)�ʤɤ���¸���롥
@@ -1434,7 +1482,7 @@ SuperClass: Object
Methods:
- do(arg[, ...])
+ call(arg[, ...])
�֥��å���¹Ԥ��롥
@@ -1446,7 +1494,7 @@ Single Methods:
���ƤФ��ȡ����λ����Ǽ¹Ԥ����٤������ɤ���߹�������֥���
����(Block)���������롥
-*** Class(���饹)
+** Class(���饹)
���饹�Υ��饹����긷̩����������ȥ��饹���ðۥ᥽�åɤ�Ѿ����뤿��
�ˡ����줾��᥿���饹�ȸƤФ��̾���Τʤ����饹�򥯥饹�Ȥ��ƻ�����
@@ -1472,7 +1520,7 @@ Methods:
�饹���ðۥ᥽�åɤˤ�äƥ����С��饤�ɤ��졤���饹�ˤ�äư�
�����ۤʤ롥
-*** Comparable(�⥸�塼��)
+** Comparable(�⥸�塼��)
��ӱ黻��������饹�Τ����Mixin�����Υ⥸�塼��򥤥󥯥롼�ɤ��뤳
�Ȥˤ�äơ�`<=>'�黻�Ҥ�������������¾�α黻�ҤϤ�����������Ѥ���
@@ -1504,7 +1552,7 @@ Methods:
self��min��max���ϰ���ˤ���������֤���
-*** Cons(���饹)
+** Cons(���饹)
�ǡ�������(�ڥ�)��ɽ�����륯�饹���̾������`::'�黻�Ҥ��Ѥ��ƹԤʤ�
��롥Lisp��CONS�ڥ���Ʊ�ͤ�List������������Ѥ����뤳�Ȥ⤢�롥
@@ -1561,7 +1609,7 @@ Methods:
CONS�ڥ�����ʤ�ꥹ�Ȥγ����Ǥ�Ϳ���륤�ƥ졼����
-*** DBM(���饹)
+** DBM(���饹)
NDBM�ե�����򥢥��������륯�饹���������ǡ����Ȥ��ʸ����Ǥʤ���Ф�
��ʤ��Ȥ������¤ȡ��ǡ������ե��������¸�����Ȥ�����������Ƥ�
@@ -1657,7 +1705,7 @@ Single Methods:
�롥mode�ξ�ά�ͤ�0666�Ǥ��롥mode�Ȥ���nil����ꤹ��ȥǡ���
�١���������¸�ߤ��ʤ����ˤϿ����˥����ץ󤻤���nil���֤���
-*** Dict(���饹)
+** Dict(���饹)
���񤢤뤤��Ϣ������Ǥ�դΥ��֥������Ȥ�ź���ȤǤ�������Υ��饹�Ǥ�
�롥Hash�Ȥ���̾���Ǥ⥢�������Ǥ��롥Ϣ�����󥪥֥������Ȥ������ϰ���
@@ -1740,11 +1788,15 @@ Methods:
Single Methods:
+ Dict[key, value...]
+
+ ������ܤΰ�����key���������ܤΰ�����value�Ȥ��뼭����������롥
+
new
������(����)���񥪥֥������Ȥ��֤���
-*** Directory(���饹)
+** Directory(���饹)
�ǥ��쥯�ȥ�������Ǥ����֤��ǥ��쥯�ȥꥹ�ȥ꡼�����Τ���Υ��饹��
Dir�Ȥ���̾���Ǥ⥢�������Ǥ��롥
@@ -1808,7 +1860,7 @@ Single Methods:
path�ǻ��ꤵ�줿�ǥ��쥯�ȥ�������롥�ǥ��쥯�ȥ�϶��Ǥ���
ɬ�פ����롥
-*** Enumerable(�⥸�塼��)
+** Enumerable(�⥸�塼��)
���Ǥ��Ф��뷫���֤���Ԥʤ����饹�Τ����Mixin�����Υ⥸�塼��򥤥�
���롼�ɤ��뤿��ˤϡ��᥽�å�`each'���������ɬ�פ����롥
@@ -1866,7 +1918,7 @@ Methods:
���Ƥ����Ǥ򥽡��Ȥ���������֤���
-*** Etc(�⥸�塼��)
+** Etc(�⥸�塼��)
/etc�ǥ��쥯�ȥ�ʲ��ξ�������뤿��Υ⥸�塼�롥���饹�˥��󥯥롼��
���ƻȤ����Ȥ�Ǥ��롥
@@ -1938,7 +1990,7 @@ Single Methods:
���Ƥ�passwd����ȥ���˥����������뤿��Υ��ƥ졼����
-*** File(���饹)
+** File(���饹)
�ե����륢�������Τ���Υ��饹���᥽�å�open()����������롥�ޤ�������
���饹���ðۥ᥽�åɤȤ���test�Υե�����ƥ��ȱ黻�������Υ᥽�åɤ���
@@ -2097,7 +2149,7 @@ Single Methods:
����ʳ���FileTest�⥸�塼��Υ᥽�åɤ��ðۥ᥽�åɤȤ��ƻ��ġ�
-*** FileTest(�⥸�塼��)
+** FileTest(�⥸�塼��)
�ե�����ƥ����ѥ᥽�åɤ򽸤᤿�⥸�塼�롥���󥯥롼�ɤ����Ѥ��뤳��
��Ǥ��롥
@@ -2203,7 +2255,7 @@ Single Methods:
filename�Υե����뤬¸�ߤ����礭����0�Ǥ�����������֤���
-*** Fixnum(���饹)
+** Fixnum(���饹)
31bit(�ޥ����long��Ĺ��-1 bit)�����Υ��饹��builtin class�Ǥ��롥����
���饹��pointer���¨�ͤǤ��뤿��call by value�ǸƤӽФ����������ħŪ
@@ -2268,7 +2320,7 @@ Methods:
���ƥ졼����self����max�ޤǷ����֤���
-*** Float(���饹)
+** Float(���饹)
��ư���������Υ��饹��
@@ -2309,7 +2361,7 @@ Single Methods:
float��Ʊ���ͤ���Ŀ�����Float���֥������Ȥ��֤���
-*** GC(�⥸�塼��)
+** GC(�⥸�塼��)
Ruby�Ȥ߹��ߤ�garbage collector�������Ԥʤ�����Υ⥸�塼�롥���Υ�
���塼��Υ᥽�åɤ���Ѥ��뤳�Ȥˤ�äơ����Ū��GC��ߤ᤿�ꡤGC�ε�
@@ -2335,7 +2387,7 @@ Single Methods:
GC�򳫻Ϥ��롥
-*** Glob(���饹)
+** Glob(���饹)
�磻��ɥ����ɤΥ��饹���磻��ɥ����ɤΥ�ƥ���<...>�Ȥ��������Ǥ�
�롥����ɽ���Ȥۤ�Ʊ���褦�˻Ȥ��뤬��������ϵ�ǽ�����ʤ�������������
@@ -2362,7 +2414,7 @@ Single Methods:
ʸ�����磻��ɥ����ɤ��Ѵ��������֥������Ȥ��֤���
-*** Integer(���饹)
+** Integer(���饹)
�������饹���ºݤϤ����礭���ˤ�ä�Fixnum��Bignum������ĤΥ��֥��饹
�Ǽ¸�����Ƥ��롥Integer�Ϥ����Υ����ѡ����饹�Ȥʤ���ݥ��饹�Ǥ�
@@ -2392,7 +2444,7 @@ Methods:
���Ĥ⿿���֤���
-*** IO(���饹)
+** IO(���饹)
�����ϤΤ���δ��ܥ��饹��
@@ -2493,7 +2545,7 @@ Methods:
str����Ϥ��롥���Ϥ����Х��ȿ����֤���
-*** Kernel(���饹)
+** Kernel(���饹)
���ƤΥ��饹�δ��쥯�饹��Ruby�Ȥ߹��ߤ����Ƥδؿ��᥽�åɤϤ��Υ��饹
���������Ƥ��롥�ؿ��᥽�åɤˤĤ��Ƥϡִؿ��פι��ܤ򻲾ȤΤ��ȡ�
@@ -2565,7 +2617,7 @@ Methods:
����������ˤ�ɬ��������⤽��˹�碌�ƺ�������뤳�ȡ�
-*** Math(�⥸�塼��)
+** Math(�⥸�塼��)
��ư�������黻�򥵥ݡ��Ȥ��륯�饹��Math�⥸�塼���Ʊ������Υ᥽�å�
���ðۥ᥽�åɤȤ�ξ�����������Ƥ���Τǡ��ðۥ᥽�åɤ�ƤӽФ��ƻ�
@@ -2610,7 +2662,7 @@ Single Methods:
x��Ω�������֤���
-*** Module(���饹)
+** Module(���饹)
�⥸�塼��Υ��饹��
@@ -2665,7 +2717,7 @@ Methods:
name�ǻ��ꤵ�줿�᥽�åɤ�ؿ������Ǥ����ƤӽФ���ǽ�ˤ��롥��
�Ǥ˴ؿ��᥽�åɤǤ�����ˤϲ��⤷�ʤ���
-*** Nil(���饹)
+** Nil(���饹)
����ɽ�����֥�������nil�Υ��饹�����ѿ�(����)nil��Nil���饹��ͣ��Υ�
�󥹥��󥹤Ǥ��롥
@@ -2686,7 +2738,7 @@ Methods:
��˿����֤���
-*** Numeric(���饹)
+** Numeric(���饹)
�����̤�������ɽ����ݥ��饹��
@@ -2717,7 +2769,7 @@ Methods:
���ο����֤������ο��ȤϤ��ο���ۤ���Ǿ��������Ǥ��롥
-*** Object(���饹)
+** Object(���饹)
���Ƥ��̾說�饹�Υ����ѥ��饹���̾說�饹�Υ��󥹥��󥹤ΰ���Ū�ʿ���
����������Ƥ��롥���Υ��饹�Υ��֥��饹�Ǥʤ����饹��Kernel��Nil�ȡ�
@@ -2727,6 +2779,9 @@ SuperClass: Builtin
Methods:
+ init_object
+
+
is_member_of(class)
���֥�������self�����饹class�Υ��󥹥��󥹤Ǥ�����������֤���
@@ -2752,7 +2807,7 @@ Methods:
���֥������Ȥ�������Ѵ����롥�����ͥ륯�饹���������Ƥ����
�ե���Ȥϡ����Υ��֥������ȼ��Ȥ�ޤ�1���Ǥ�������֤���
-*** Process(�⥸�塼��)
+** Process(�⥸�塼��)
�ץ������˴ؤ�������Ԥʤ�����Υ⥸�塼�롥Math�⥸�塼���Ʊ�ͤ���
�ƤΥ᥽�åɤ��ðۥ᥽�åɤȤ��Ƥ��̾�Υ᥽�åɤȤ��Ƥ�Ȥ��롥
@@ -2827,7 +2882,7 @@ Single Methods:
�ץ������θ��ߤμ�UID��uid�˥��åȤ���.
-*** Range(���饹)
+** Range(���饹)
�ϰϥ��֥������ȤΥ��饹���ϰϥ��֥������Ȥ�`..'�黻�Ҥˤ�ä��������졤
����Ū�ˤϰʲ��Τ褦�ʻȤ����򤹤�
@@ -2855,7 +2910,7 @@ Methods:
self =~ other
self��other��Ʊ�����饹���Ф����ϰϥ��֥������Ȥǡ������ϰ���
- ��other�������(start <= other <= end)�������֤��������caseʸ
+ ��other�������(start <= other <= end)�������֤��������case��
���ϰϻ��ꤹ����������Ǥ��롥�㤨��
case i
@@ -2867,7 +2922,7 @@ Methods:
each
- �ϰ����¸�ߤ��륪�֥������Ȥ�Ϳ���륤�ƥ졼�������forʸ�Τ�
+ �ϰ����¸�ߤ��륪�֥������Ȥ�Ϳ���륤�ƥ졼�������for���Τ�
����Ѥ����롥
end
@@ -2878,7 +2933,7 @@ Methods:
�ϰϤλ������֤���
-*** Socket(���饹)
+** Socket(���饹)
SuperClass: BasicSocket
@@ -2938,7 +2993,8 @@ Single Methods:
�����åȤΥڥ����֤��������λ���� open��Ʊ���Ǥ��롥
-*** Regexp(���饹)
+
+** Regexp(���饹)
����ɽ���Υ��饹������ɽ���Υ�ƥ���/.../�Ȥ���������ɽ������ưŪ��
�������뤿��ˤ�
@@ -2974,7 +3030,12 @@ Single Methods:
���̤��롥���ꤵ��ʤ����ϥޥå���Ԥʤä������Υ����ƥ��ѿ�
`$='���ͤˤ�äƶ��̤��뤫���ʤ��������ꤵ��롥
-*** BasicSocket(���饹)
+ quote(str)
+
+ ʸ������������ɽ���ǰ�̣�����ʸ���򥨥������פ��롥������ʸ
+ ������֤���
+
+** BasicSocket(���饹)
�����åȤ�ɽ����ݥ��饹������Ū�ʥ����å����ϥ��֥��饹���������롥
�㤨�Х��󥿡��ͥåȥɥᥤ��ξ���TCPsocket���Ѥ��롥
@@ -3008,7 +3069,7 @@ Methods:
how��1�Ǥ�����ϡ��ʹߤ����������ݤ���롥how��2�λ��ˤϡ�����
�ʹߤ������������Ȥ�˵��ݤ���롥shutdown(2)�򻲾ȡ�
-*** String(���饹)
+** String(���饹)
ʸ���󥯥饹��Ruby��ʸ����ϥ̥륿���ߥ͡��ȤǤϤʤ��Τǡ��Х��ʥ�ǡ�
���ⰷ���롥���äƤɤ��餫�Ȥ�����ñ�ʤ�ʸ����Ȥ������Х�����Ǥ��롥
@@ -3323,7 +3384,7 @@ Single Methods:
string��Ʊ�����Ƥ���Ŀ�����ʸ������֤���
-*** Struct(���饹)
+** Struct(���饹)
��¤�Υ��饹��ʣ���Υǡ�����ޤȤ������Ѥ�����(��: Time::times)��
�ǡ�����ޤȤ����ˤ����󥯥饹���Ѥ����뤳�Ȥ⤢�뤬(��: select)��
@@ -3386,7 +3447,7 @@ Single Methods:
�Фǻ��ꤵ�줿̾�����ðۥ᥽�åɤ��������Ƥ��ơ����Υ᥽�å�
�ˤ�äƥ��Ф����Ƥ����뤳�Ȥ��Ǥ��롥
-*** TCPserver(���饹)
+** TCPserver(���饹)
TCP/IP���ȥ꡼�෿��³�Υ�����¦�Υ����åȤΥ��饹�����Υ��饹�ˤ�ä�
��ñ�˥����åȤ����Ѥ��������ФΥץ�����ߥ󥰤��Ǥ��롥�㤨��echo����
@@ -3432,7 +3493,7 @@ Single Methods:
³����������դ��롥��ά�������ƤΥۥ��Ȥ������³�׵�������
���롥
-*** TCPsocket
+** TCPsocket
���󥿡��ͥåȥɥᥤ��Υ��ȥ꡼�෿�����åȤΥ��饹���̾��IO���饹��
���֥��饹��Ʊ�ͤ������Ϥ��Ǥ��롥���Υ��饹�ˤ�äƥ����åȤ��Ѥ�����
@@ -3470,7 +3531,7 @@ Single Methods:
����service��/etc/services(�ޤ���NIS)����Ͽ����Ƥ��륵����
��̾���ݡ����ֹ�Ǥ��롥
-*** Time(���饹)
+** Time(���饹)
���֤�ɽ�����饹���羮��Ӥʤɤ��Ǥ��롥Time.now�Ǹ��ߤλ��֤����뤳��
���Ǥ��롥�ޤ��ե�����Υ����ॹ����פ�����᥽�åɤ�����ͤ⤳�Υ���
@@ -3593,7 +3654,7 @@ Single Methods:
���֤�ñ�̤��äǤ��ꡤ��ư����������Ϳ�����롥�ܺ٤�
times(3)�򻲾ȤΤ��ȡ�
-*** UNIXserver
+** UNIXserver
UNIX���ȥ꡼�෿��³�Υ�����¦�Υ����åȤΥ��饹��
@@ -3606,7 +3667,7 @@ Methods:
���饤����Ȥ������³�׵������դ�����³����UNIXsocket�Υ���
�����󥹤��֤���
-*** UNIXsocket
+** UNIXsocket
UNIX�ɥᥤ��Υ��ȥ꡼�෿�����åȤΥ��饹���̾��IO���饹�Υ��֥��饹
��Ʊ�ͤ������Ϥ��Ǥ��롥
@@ -3636,6 +3697,210 @@ Single Methods:
path�ǻ��ꤷ���ѥ�̾���Ѥ�����³���������åȤ��֤���
+* C����ȤΥ��󥿥ե�����
+
+ruby��C����ȤΥ��󥿡��ե��������󶡤���C���줫��Υ��饹���⥸�塼��
+�������C����ǵ��Ҥ����᥽�åɤ������ruby�Υ᥽�åɤθƤӽФ�������
+�졼���θƤӽФ����㳰�����ʤɤ�Ԥʤ����Ȥ�����롥�ޤ���OS�������м�
+�Ի���C�ǽ񤫤줿�⥸�塼�������ɤ��뤳�Ȥ����롥
+
+����Ū�ʥ��󥿥ե������˴ؤ��Ƥϡ��̥ɥ������(ź�եե����� C-IF)��
+���ȤΤ��ȡ�
+
+* ʸˡ
+
+�ʲ��ϵ���BNF�ǵ��Ҥ���ruby��ʸˡ�Ǥ��롥������Τʵ��Ҥ�parse.y�򻲾�
+���줿����
+
+PROGRAM : COMPEXPR
+
+COMPEXPR : EXPR (TERM EXPR)* [TERM]
+
+EXPR : MLHS `=' ARGS
+ | ASSOCS
+ | return ARGS
+ | fail ARGS
+ | yield ARGS
+ | identifier CALL_ARGS
+ | PRIMARY `.' identifier CALL_ARGS
+ | super CALL_ARGS
+ | undef FNAME
+ | alias FNAME FNAME
+ | include identifier (`,' identifier)*
+ | EXPR if EXPR
+ | EXPR while EXPR
+ | EXPR and EXPR
+ | EXPR or EXPR
+ | ARG
+
+ARG : LHS `=' ARG
+ | LHS OP_ASGN ARG
+ | ARG `..' ARG
+ | ARG `...' ARG
+ | ARG `+' ARG
+ | ARG `-' ARG
+ | ARG `*' ARG
+ | ARG `/' ARG
+ | ARG `%' ARG
+ | ARG `**' ARG
+ | `+' ARG
+ | `-' ARG
+ | ARG `|' ARG
+ | ARG `^' ARG
+ | ARG `&' ARG
+ | ARG `<=>' ARG
+ | ARG `>' ARG
+ | ARG `>=' ARG
+ | ARG `<' ARG
+ | ARG `<=' ARG
+ | ARG `==' ARG
+ | ARG `!=' ARG
+ | ARG `=~' ARG
+ | ARG `!~' ARG
+ | `!' ARG
+ | `~' ARG
+ | ARG `<<' ARG
+ | ARG `>>' ARG
+ | ARG `::' ARG
+ | ARG `&&' ARG
+ | ARG `||' ARG
+ | PRIMARY
+
+PRIMARY : LITERAL
+ | VARIABLE
+ | super `(' [CALL_ARGS] `)'
+ | super
+ | PRIMARY `[' [ARGS] `]'
+ | `[' [ARGS] `]'
+ | `{' ARGS `}'
+ | `{' ASSOCS `}'
+ | redo
+ | break
+ | continue
+ | retry
+ | return
+ | fail `(' ARGS `)'
+ | fail `(' `)'
+ | fail
+ | yield `(' ARGS `)'
+ | yield `(' `)'
+ | yield
+ | PRIMARY `{' [ITER_VAR] `|' COMPEXPR `}'
+ | identifier `(' [CALL_ARGS] `)'
+ | PRIMARY `.' identifier `(' [CALL_ARGS] `)'
+ | PRIMARY `.' identifier
+ | if EXPR THEN
+ COMPEXPR
+ (elsif EXPR THEN COMPEXPR)*
+ [else COMPEXPR]
+ end
+ | while EXPR TERM COMPEXPR end
+ | case COMPEXPR
+ (when ARGS THEN)+
+ [else COMPEXPR]
+ end
+ | for ITER_VAR in EXPR TERM
+ COMPEXPR
+ end
+ | protect
+ COMPEXPR
+ [resque COMPEXPR]
+ [ensure COMPEXPR]
+ end
+ | `(' COMPEXPR `)'
+ | class identifier `:' identifier
+ COMPEXPR
+ end
+ | module identifier
+ COMPEXPR
+ end
+ | def FNAME ARGLIST
+ COMPEXPR
+ end
+ | def SINGLETON `.' FNAME ARGLIST
+ COMPEXPR
+ end
+
+THEN : TERM
+ | then
+ | TERM then
+
+ITER_VAR : LHS
+ | MLHS
+
+MLHS : LHS `,' [LHS (`,' LHS)*] [`*' LHS]
+
+LHS : VARIABLE
+ | PRIMARY `[' [ARGS] `]'
+ | PRIMARY `.' identifier
+
+CALL_ARGS : ARGS
+ | ASSOCS
+ | ARGS `,' ASSOCS
+ | ARGS `,' `*' ARG
+
+ARGS : ARG
+ | ARGS `,' ARG
+
+ARGLIST : `('[identifier(`,'identifier)*][`*'identifier]`)'
+ | TERM
+
+SINGLETON : VARIABLE
+ | `(' COMPEXPR `)'
+
+ASSOCS : ASSOC (`,' ASSOC)*
+
+ASSOC : ARG `=>' ARG
+
+VARIABLE : identifier
+ | VARNAME
+ | nil
+ | self
+ | `__FILE__'
+ | `__LINE__'
+
+LITERAL : numeric
+ | SYMBOL
+ | STRING
+ | REGEXP
+ | GLOB
+
+TERM : `;'
+ | `\n'
+
+������겼�ϻ����������ǧ������롥
+
+SYMBOL : `:'FNAME
+ | `:'VARNAME
+
+FNAME : identifier | `::' | `..' | `|' | `^' | `&'
+ | `<=>' | `==' | `=~' | `>' | `>=' | `<' | `<='
+ | `<<' | `>>' | `+' | `-' | `*' | `/' | `%' | `**'
+ | `~' | `+@' | `-@' | `[]' | `[]='
+
+VARNAME : GLOBAL
+ | `@'identifier
+ | `%'identifier
+
+GLOBAL : `$'identifier
+ | `$'any_char
+
+STRING : `"' any_char* `"'
+ | `'' any_char* `''
+ | ``' any_char* ``'
+
+REGEXP : `/' any_char* `/'
+
+GLOB : `<' any_char* `>'
+
+* �ռ�
+
+Ruby�θ�����ͤ�C, Perl, Eiffel�γƸ���ˤ��ν�˱ƶ�������Ƥ���. ��
+��¾�˱ƶ������������Ȥ��Ƥ�tcl, AWK, bourne shell, CLU, Sather,
+Icon, Smalltalk, Emacs Lisp�ʤɤ�����. �ޤ�ruby�θ�����ͤ���ꤹ�뤿
+��˶��Ϥ��Ʋ����ä�������ʲ��ˤ�����(�ɾ�ά): ���ͷ�����������������
+ƣ���Ϻ����¼���Σţá��غ�������DEC�����ʤ�@�ֺ�.�ٻ��̡�
+
-------------------------------------------------------
Local variables:
fill-column: 70
diff --git a/sprintf.c b/sprintf.c
index 278b16607c..c74ec080ff 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -282,7 +282,7 @@ Fsprintf(argc, argv)
blen += strlen(&buf[blen]);
}
break;
-
+
case 'd':
case 'D':
case 'O':
diff --git a/st.c b/st.c
index 80f08e9fb6..eb3ad92871 100644
--- a/st.c
+++ b/st.c
@@ -58,7 +58,7 @@ int reorder_flag;
tbl->grow_factor = grow_factor;
tbl->reorder_flag = reorder_flag;
tbl->num_bins = size;
- tbl->bins =
+ tbl->bins =
(st_table_entry **) Calloc((unsigned)size, sizeof(st_table_entry *));
return tbl;
}
@@ -122,11 +122,11 @@ char **value;
hash_val = do_hash(key, table);
FIND_ENTRY(table, ptr, hash_val);
-
+
if (ptr == nil(st_table_entry)) {
return 0;
} else {
- if (value != nil(char *)) *value = ptr->record;
+ if (value != nil(char *)) *value = ptr->record;
return 1;
}
}
@@ -176,7 +176,7 @@ char *value;
{
int hash_val;
st_table_entry *tbl;
-
+
hash_val = do_hash(key, table);
ADD_DIRECT(table, key, value, hash_val, tbl);
}
@@ -210,13 +210,13 @@ register st_table *table;
int i, old_num_bins = table->num_bins, hash_val;
table->num_bins = table->grow_factor*old_num_bins;
-
+
if (table->num_bins%2 == 0) {
table->num_bins += 1;
}
-
+
table->num_entries = 0;
- table->bins =
+ table->bins =
(st_table_entry **) Calloc((unsigned) table->num_bins,
sizeof(st_table_entry *));
@@ -245,9 +245,9 @@ st_table *old_table;
if (new_table == nil(st_table)) {
return nil(st_table);
}
-
+
*new_table = *old_table;
- new_table->bins =
+ new_table->bins =
(st_table_entry **) Calloc((unsigned) num_bins,
sizeof(st_table_entry *));
@@ -357,7 +357,7 @@ int modulus;
{
register int val = 0;
register int c;
-
+
while ((c = *string++) != '\0') {
val = val*997 + c;
}
diff --git a/string.c b/string.c
index 3861f71d32..aacc6f621c 100644
--- a/string.c
+++ b/string.c
@@ -489,7 +489,7 @@ Fstr_rindex(argc, argv, str)
Check_Type(sub, T_STRING);
if (pos > str->len) return Qnil; /* substring longer than string */
- sbeg = str->ptr; s = s + pos - sub->len;
+ sbeg = str->ptr; s = sbeg + pos - sub->len;
t = sub->ptr;
len = sub->len;
while (sbeg <= s) {
@@ -535,7 +535,7 @@ Fstr_next(orig)
char c = -1;
str = (struct RString*)str_new(orig->ptr, orig->len);
-
+
sbeg = str->ptr; s = sbeg + str->len - 1;
while (sbeg <= s) {
@@ -642,7 +642,9 @@ str_replace(str, beg, len, val)
REALLOC_N(str->ptr, char, str->len+val->len-len+1);
}
- memmove(str->ptr+beg+val->len, str->ptr+beg+len, str->len-(beg+len));
+ if (len != val->len) {
+ memmove(str->ptr+beg+val->len, str->ptr+beg+len, str->len-(beg+len));
+ }
memcpy(str->ptr+beg, val->ptr, val->len);
str->len += val->len - len;
str->ptr[str->len] = '\0';
@@ -830,7 +832,7 @@ Fsub(obj, pat, val)
Check_Type(rb_lastline, T_STRING);
return Fstr_sub_internal(rb_lastline, pat, val, 1);
}
-
+
static VALUE
Fgsub(obj, pat, val)
VALUE obj, pat, val;
diff --git a/struct.c b/struct.c
index 819b3526da..a368605965 100644
--- a/struct.c
+++ b/struct.c
@@ -167,7 +167,7 @@ Fstruct_aref(s, idx)
if (TYPE(idx) == T_STRING)
return struct_find(rb_intern(RSTRING(idx)->ptr));
-
+
i = NUM2INT(idx);
if (s->len <= i)
Fail("offset %d too large for struct(size:%d)", i, s->len);
diff --git a/time.c b/time.c
index b6c1bd26cb..73f3837ec5 100644
--- a/time.c
+++ b/time.c
@@ -30,9 +30,13 @@ struct time_object {
static ID id_tv;
-#define GetTimeval(obj, tobj) \
- Get_Data_Struct(obj, id_tv, struct time_object, tobj)
+#define GetTimeval(obj, tobj) {\
+ if (!id_tv) id_tv = rb_intern("tv");\
+ Get_Data_Struct(obj, id_tv, struct time_object, tobj);\
+}
+
#define MakeTimeval(obj,tobj) {\
+ if (!id_tv) id_tv = rb_intern("tv");\
Make_Data_Struct(obj, id_tv, struct time_object, Qnil, Qnil, tobj);\
tobj->tm_got=0;\
}
@@ -118,7 +122,7 @@ time_timeval(time)
static VALUE
Stime_at(class, time)
VALUE class, time;
-{
+{
VALUE obj;
int sec, usec;
struct time_object *tobj;
@@ -557,6 +561,4 @@ Init_Time()
rb_define_method(C_Time, "usec", Ftime_usec, 0);
rb_define_method(C_Time, "strftime", Ftime_strftime, 1);
-
- id_tv = rb_intern("tv");
}
diff --git a/variable.c b/variable.c
index 88a306841f..bdfca0a2cf 100644
--- a/variable.c
+++ b/variable.c
@@ -3,14 +3,13 @@
variable.c -
$Author: matz $
- $Date: 1995/01/10 10:43:03 $
+ $Date: 1995/01/12 08:54:53 $
created at: Tue Apr 19 23:55:15 JST 1994
************************************************/
#include "ruby.h"
#include "env.h"
-#include "node.h"
#include "ident.h"
#include "st.h"
@@ -210,58 +209,6 @@ rb_gvar_get(entry)
}
VALUE
-rb_ivar_get_1(obj, id)
- struct RBasic *obj;
- ID id;
-{
- VALUE val;
-
- if (obj->iv_tbl == Qnil)
- return Qnil;
- if (st_lookup(obj->iv_tbl, id, &val))
- return val;
- if (verbose)
- Warning("instance var %s not initialized", rb_id2name(id));
- return Qnil;
-}
-
-VALUE
-rb_ivar_get(id)
- ID id;
-{
- return rb_ivar_get_1(Qself, id);
-}
-
-VALUE
-rb_mvar_get(id)
- ID id;
-{
- VALUE val;
-
- if (st_lookup(class_tbl, id, &val)) return val;
- if (verbose)
- Warning("local var %s not initialized", rb_id2name(id));
- return Qnil;
-}
-
-VALUE
-rb_const_get(id)
- ID id;
-{
- struct RClass *class = (struct RClass*)CLASS_OF(Qself);
- VALUE value;
-
- while (class) {
- if (class->c_tbl && st_lookup(class->c_tbl, id, &value)) {
- return value;
- }
- class = class->super;
- }
- Fail("Uninitialized constant %s", rb_id2name(id));
- /* not reached */
-}
-
-VALUE
rb_gvar_set(entry, val)
struct global_entry *entry;
VALUE val;
@@ -301,13 +248,67 @@ rb_gvar_set2(name, val)
}
VALUE
+rb_mvar_get(id)
+ ID id;
+{
+ VALUE val;
+
+ if (st_lookup(class_tbl, id, &val)) return val;
+ if (verbose)
+ Warning("local var %s not initialized", rb_id2name(id));
+ return Qnil;
+}
+
+VALUE
+rb_ivar_get_1(obj, id)
+ struct RObject *obj;
+ ID id;
+{
+ VALUE val;
+
+ switch (TYPE(obj)) {
+ case T_OBJECT:
+ case T_CLASS:
+ case T_MODULE:
+ if (obj->iv_tbl && st_lookup(obj->iv_tbl, id, &val))
+ return val;
+ return Qnil;
+ default:
+ Fail("class %s can not have instance variables",
+ rb_class2name(CLASS_OF(obj)));
+ break;
+ }
+ if (verbose) {
+ Warning("instance var %s not initialized", rb_id2name(id));
+ }
+ return Qnil;
+}
+
+VALUE
+rb_ivar_get(id)
+ ID id;
+{
+ return rb_ivar_get_1(Qself, id);
+}
+
+VALUE
rb_ivar_set_1(obj, id, val)
- struct RBasic *obj;
+ struct RObject *obj;
ID id;
VALUE val;
{
- if (obj->iv_tbl == Qnil) obj->iv_tbl = new_idhash();
- st_insert(obj->iv_tbl, id, val);
+ switch (TYPE(obj)) {
+ case T_OBJECT:
+ case T_CLASS:
+ case T_MODULE:
+ if (obj->iv_tbl == Qnil) obj->iv_tbl = new_idhash();
+ st_insert(obj->iv_tbl, id, val);
+ break;
+ default:
+ Fail("class %s can not have instance variables",
+ rb_class2name(CLASS_OF(obj)));
+ break;
+ }
return val;
}
@@ -319,13 +320,30 @@ rb_ivar_set(id, val)
return rb_ivar_set_1(Qself, id, val);
}
-static VALUE
-const_bound(class, id)
+VALUE
+rb_const_get(id)
+ ID id;
+{
+ struct RClass *class = (struct RClass*)CLASS_OF(Qself);
+ VALUE value;
+
+ while (class) {
+ if (class->iv_tbl && st_lookup(class->iv_tbl, id, &value)) {
+ return value;
+ }
+ class = class->super;
+ }
+ Fail("Uninitialized constant %s", rb_id2name(id));
+ /* not reached */
+}
+
+VALUE
+rb_const_bound(class, id)
struct RClass *class;
ID id;
{
while (class) {
- if (class->c_tbl && st_lookup(class->c_tbl, id, Qnil)) {
+ if (class->iv_tbl && st_lookup(class->iv_tbl, id, Qnil)) {
return TRUE;
}
class = class->super;
@@ -339,13 +357,11 @@ rb_const_set(class, id, val)
ID id;
VALUE val;
{
- if (const_bound(class, id))
+ if (rb_const_bound(class, id))
Fail("already initialized constnant");
- if (class->c_tbl == Qnil)
- class->c_tbl = new_idhash();
-
- st_insert(class->c_tbl, id, val);
+ if (class->iv_tbl == Qnil) class->iv_tbl = new_idhash();
+ st_insert(class->iv_tbl, id, val);
}
void
diff --git a/version.c b/version.c
index aa9028b0e4..27a3182f9c 100644
--- a/version.c
+++ b/version.c
@@ -3,8 +3,8 @@
version.c -
$Author: matz $
- $Revision: 1.4 $
- $Date: 1994/12/19 08:30:17 $
+ $Revision: 1.5 $
+ $Date: 1995/01/12 08:54:54 $
created at: Thu Sep 30 20:08:01 JST 1993
Copyright (C) 1994 Yukihiro Matsumoto
diff --git a/version.h b/version.h
index ef005b1692..d24ad99a31 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "0.64"
-#define VERSION_DATE "95/01/10"
+#define RUBY_VERSION "0.65"
+#define VERSION_DATE "95/02/08"