rev 463 - in trunk: . bison include/prothon pr src

SVN User <[email protected]> Sun, 09 May 2004 01:29:13 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-05-09 01:29:09 -0400 (Sun, 09 May 2004)
New Revision: 463

Added:
   trunk/pr/func.pr
Removed:
   trunk/pr/bind2.pr
   trunk/pr/cache.pr
   trunk/pr/fixed.pr
   trunk/pr/int.pr
   trunk/pr/scope.pr
Modified:
   trunk/STATUS.txt
   trunk/bison/bison.simple
   trunk/include/prothon/prothon.h
   trunk/pr/init.pr
   trunk/pr/object.pr
   trunk/pr/test.pr
   trunk/src/builtins-core.c
   trunk/src/builtins-int.c
   trunk/src/bytecodes.h
   trunk/src/interp.c
   trunk/src/interp.h
   trunk/src/main.c
   trunk/src/parser.h
   trunk/src/parser_routines.c
   trunk/src/prothon.y
   trunk/src/symbol.c
Log:
changed all symbols to keywords: local, global, self, super, outer, caller, changed object/block scheme,
things are probably quite broken

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/STATUS.txt	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,12 +1,8 @@
 
 ----------------------- TO-DO (highest priority first) ------------------------
 
---- change obj$func() to obj.func$()
-
 --- Add properties methods support (__get__,  __set__, __delete__)  rename protoList
 
---- Add Globals built-in attribute (actually a synonym for current Main module which can be named Main1, Main2, ...)
-
 --- Add __attrs__ & __protos__ functionality.
 
 --- Auto-documenter app

Modified: trunk/bison/bison.simple
===================================================================
--- trunk/bison/bison.simple	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/bison/bison.simple	2004-05-09 05:29:09 UTC (rev 463)
@@ -252,8 +252,11 @@
   int yylen;
 
 #if YYDEBUG != 0
-  if (yydebug)
-    printf("Starting parse\n");
+  if (yydebug) {
+    fprintf(fout, "Starting parse\n");
+    fflush(fout);
+  }
+
 #endif
 
   yystate = 0;
@@ -341,8 +344,11 @@
 #endif
 
 #if YYDEBUG != 0
-      if (yydebug)
-	printf("Stack size increased to %d\n", yystacksize);
+      if (yydebug) {
+	fprintf(fout, "Stack size increased to %d\n", yystacksize);
+    fflush(fout);
+  }
+
 #endif
 
       if (yyssp >= yyss + yystacksize - 1)
@@ -350,8 +356,11 @@
     }
 
 #if YYDEBUG != 0
-  if (yydebug)
-    printf("Entering state %d\n", yystate);
+  if (yydebug) {
+    fprintf(fout, "Entering state %d\n", yystate);
+    fflush(fout);
+  }
+
 #endif
 
   goto yybackup;
@@ -375,8 +384,11 @@
   if (yychar == YYEMPTY)
     {
 #if YYDEBUG != 0
-      if (yydebug)
-	printf("Reading a token: ");
+      if (yydebug) {
+	fprintf(fout, "Reading a token: ");
+    fflush(fout);
+  }
+
 #endif
       yychar = YYLEX;
     }
@@ -389,8 +401,11 @@
       yychar = YYEOF;		/* Don't call YYLEX any more */
 
 #if YYDEBUG != 0
-      if (yydebug)
-	printf("Now at end of input.\n");
+      if (yydebug) {
+	fprintf(fout, "Now at end of input.\n");
+    fflush(fout);
+  }
+
 #endif
     }
   else
@@ -400,13 +415,14 @@
 #if YYDEBUG != 0
       if (yydebug)
 	{
-	  printf("Next token is %d (%s", yychar, yytname[yychar1]);
+	  fprintf(fout, "Next token is %d (%s", yychar, yytname[yychar1]);
 	  /* Give the individual parser a way to print the precise meaning
 	     of a token, for further debugging info.  */
 #ifdef YYPRINT
 	  YYPRINT (stderr, yychar, yylval);
 #endif
-	  printf(")\n");
+	  fprintf(fout, ")\n");
+      fflush(fout);
 	}
 #endif
     }
@@ -440,8 +456,10 @@
   /* Shift the lookahead token.  */
 
 #if YYDEBUG != 0
-  if (yydebug)
-    printf("Shifting token %d (%s), ", yychar, yytname[yychar1]);
+  if (yydebug) {
+    fprintf(fout, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+    fflush(fout);
+  }
 #endif
 
   /* Discard the token being shifted unless it is eof.  */
@@ -477,13 +495,14 @@
     {
       int i;
 
-      printf("Reducing via rule %d (line %d), ",
+      fprintf(fout, "Reducing via rule %d (line %d), ",
 	       yyn, yyrline[yyn]);
 
       /* Print the symbols being reduced, and their result.  */
       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
-	printf("%s ", yytname[yyrhs[i]]);
-      printf(" -> %s\n", yytname[yyr1[yyn]]);
+	fprintf(fout, "%s ", yytname[yyrhs[i]]);
+      fprintf(fout, " -> %s\n", yytname[yyr1[yyn]]);
+    fflush(fout);
     }
 #endif
 
@@ -500,10 +519,11 @@
   if (yydebug)
     {
       short *ssp1 = yyss - 1;
-      printf("state stack now");
+      fprintf(fout, "state stack now");
       while (ssp1 != yyssp)
-		printf(" %d", *++ssp1);
-      printf("\n");
+		fprintf(fout, " %d", *++ssp1);
+      fprintf(fout, "\n");
+      fflush(fout);
     }
 #endif
 
@@ -604,8 +624,10 @@
 	YYABORT;
 
 #if YYDEBUG != 0
-      if (yydebug)
-	printf("Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+  if (yydebug) {
+	fprintf(fout, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+    fflush(fout);
+  }
 #endif
 
       yychar = YYEMPTY;
@@ -640,10 +662,11 @@
   if (yydebug)
     {
       short *ssp1 = yyss - 1;
-      printf("Error: state stack now");
+      fprintf(fout, "Error: state stack now");
       while (ssp1 != yyssp)
-	printf(" %d", *++ssp1);
-      printf("\n");
+	      fprintf(fout, " %d", *++ssp1);
+      fprintf(fout, "\n");
+      fflush(fout);
     }
 #endif
 
@@ -672,8 +695,10 @@
     YYACCEPT;
 
 #if YYDEBUG != 0
-  if (yydebug)
-    printf("Shifting error token, ");
+  if (yydebug) {
+    fprintf(fout, "Shifting error token, ");
+    fflush(fout);
+  }
 #endif
 
   *++yyvsp = yylval;
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/include/prothon/prothon.h	2004-05-09 05:29:09 UTC (rev 463)
@@ -57,13 +57,13 @@
 
 //**************************** DEBUG DEFINITIONS ******************************
   
-//#define DEBUG_THREADS
-//#define DEBUG_MEM_MGR
-//#define TRACE_PARSER
+#define TRACE_PARSER
 #define DUMP_MODULE_CODE
 #define TRACE_INTERPRETER
 //#define DUMP_OBJECTS_AT_END
 //#define PROSIST_DEBUG
+//#define DEBUG_THREADS
+//#define DEBUG_MEM_MGR
 
 
 //*****************************************************************************
@@ -290,7 +290,7 @@
 	STOP_ITERATION_EXC,	//  36
 	LOCK_EXC,			//  37
 	PERMISSION_EXC,		//  38
-
+ 
 // constants
 	ZERO_INT,			//  39
 	MAX_INT,			//  40 MaxInt
@@ -409,7 +409,6 @@
 	__FROMSTORPROXY__,
 	__CALL__,
 	__BINDOBJ__,
-	__CONTAINER__,
 
 	SYM_ENUM_COUNT
 } sym_enum_t;

Deleted: trunk/pr/bind2.pr
===================================================================
--- trunk/pr/bind2.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/bind2.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,35 +0,0 @@
-#!/usr/bin/env prothon
-
-
-object obj:
-    def $__str__():
-        return 'test obj'
-    def $func():
-        print '$:',$
-
-object self(obj):
-    def $__str__():
-        return 'self'
-    print obj                   # test obj 
-    print obj.func              # <func:93d7c0>
-    print obj.func.bind()       # <func:93d860:bound:test obj>
-    print obj.func.bind($)      # <func:93d920:bound:self>
-    print obj.func.bind(^)      # <func:93d9e0:bound:test obj> 
-    x=obj.func
-    x()                 # $: self
-    x=obj.func.bind()
-    x()                 # $: test obj
-    x=obj.func.bind($)
-    x()                 # $: self
-    x=obj.func.bind(^)
-    x()                 # $: test obj
-    x=obj.func.bind($)
-    x()                 # $: self
-    obj.func()          # $: test obj
-    obj$func()          # $: self
-    with ^: obj$func()  # $: test obj
-
-x = obj.func.bind()
-print x                 # <func:93dd20:bound:test obj>
-x.unbind()
-print x                 # <func:93dd20>
\ No newline at end of file

Deleted: trunk/pr/cache.pr
===================================================================
--- trunk/pr/cache.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/cache.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,43 +0,0 @@
-#!/usr/bin/env prothon
-
-# cache.pr
-
-#!/usr/bin/env prothon
-
-object ModInt(Int):	
-	$modulo	= 10
-	def	$__init__(i=0):	
-		^__init__(i % $modulo)
-	def	$__add__(other):
-		print ">>>", $, other
-		if $modulo != other.modulo:	
-			raise TypeError	
-		return ^__call__(^__add__(other) % $modulo)	
-
-object Mod16Int(ModInt):
-	$modulo	= 16
-
-object Mod16IntC(Mod16Int):	
-	$cache = {}	
-	def	$__init__(i):
-		i =	i %	$modulo	
-		if i in	$cache:	
-			$__init__($cache[i])
-		else:
-			obj	= Mod16Int(i)
-			$cache[i] =	obj	
-			$__init__(obj)
-
-i =	Mod16IntC(27)
-
-print i + i
-
-/*
-j =	Mod16IntC(8)
-k =	Mod16IntC(8)
-
-n = i+i
-print 'n', n
-
-print "%i +	%i + %i	= %02i"	% (i, j, k,	(i + j + k))
-*/
\ No newline at end of file

Deleted: trunk/pr/fixed.pr
===================================================================
--- trunk/pr/fixed.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/fixed.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,35 +0,0 @@
-#!/usr/bin/env prothon
-
-object Fixed(Int):
-    $dp = 2 
-    $divisor = 100
-    
-    def $__call__(n=0, decimalplaces=2):
-        obj = Proto($)
-        obj.dp = decimalplaces
-        obj.divisor = 10
-        obj.__init__(n)   # binary data init here 
-        return obj
-
-object PrettyPrintFixed(Fixed): 
-
-    def $__init__(n):
-        ^__init__(n)
-        # Set default print format width.
-        $setPrintWidth($dp+5)
-        
-    def $setPrintWidth(wid):
-        # Create string comprehension "%W.Pf"
-        # where W is wid and P  is $dp
-        $pattern =  "%%%i.%if" % (wid, $dp) 
-        print $pattern
-        
-    def $__str__(): 
-        return  $pattern % ($ / $divisor)
-print """
-This should print
-
-%6.1f 
-123456.7 
-"""
-print PrettyPrintFixed(1234567, 1)
Added: trunk/pr/func.pr
===================================================================
--- trunk/pr/func.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/func.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -0,0 +1,27 @@
+print """
+
+following should print
+
+f1 a 
+f2 b 
+f2 c 
+f1 d 
+f2 e 
+"""
+def f1(x=''):
+	print 'f1 '+x
+
+def f2(y=''):
+	print 'f2 '+y
+	
+f = Proto(f1)
+f.__init__(f2)
+
+f1('a')
+f2('b')
+f('c')
+
+g = Func(f1)
+h = Func(f2)
+g('d')
+h('e')
Modified: trunk/pr/init.pr
===================================================================
--- trunk/pr/init.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/init.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -13,9 +13,9 @@
 
 """
 
-print Int(), Int (1234), Int(1//3), Int(-01)
+print Int(), Int(1234), Int(1//3), Int(-01)
 print Float(), Float(12.34), Float(1/3) #   Float(-0.1)  ERR XXX
-print String(), String("abc"), String(123), String(String)
+print String(), String("abc"), String(123)
 print Tuple(), Tuple(*(1,2,3)), Tuple(4,5,6)
 print List(), List(*[1,2,3]), List(4,5,6)
 print Dict(**{1:2, 3:4}), Dict(a=1, b=2, c=3)
Deleted: trunk/pr/int.pr
===================================================================
--- trunk/pr/int.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/int.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,20 +0,0 @@
-#!/usr/bin/env prothon
-
-print
-print 'this should print'
-print '16 + 4'
-print '4'
-print
-
-INT=Int()
-with INT:
-	def $__add__(other):
-		print $, "+", other
-		i = ^__add__(other) % 16
-		i.setProto(INT)
-		return i
-i=16
-i.setProto(INT)
-j=4
-j.setProto(INT)
-print i+j

Modified: trunk/pr/object.pr
===================================================================
--- trunk/pr/object.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/object.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -3,14 +3,14 @@
 # object.pr
 
 object Point(Object):
-	$x = 0; $y = 0
-	def $__init__(x, y):
-		$x=x; $y=y
-	def $move(xofs, yofs):
-		$x += xofs; $y += yofs
-		print $
-	def $__str__():
-		return '<'+$x+':'+$y+'>'
+	self.x = 0; self.y = 0
+	def self.__init__(x, y):
+		self.x=x; self.y=y
+	def self.move(xofs, yofs):
+		self.x += xofs; self.y += yofs
+		print self.
+	def self.__str__():
+		return '<'+self.x+':'+self.y+'>'
 		
 print
 print "Should print..."
Deleted: trunk/pr/scope.pr
===================================================================
--- trunk/pr/scope.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/scope.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,20 +0,0 @@
-#!/usr/bin/env prothon
-
-print
-print "This should print 1 2 3 4 5 ..."
-print
-
-X=1
-def f1():
-	x=2
-	def @f2():
-		x=3
-		print X, &x, x, $x, @x
-f1()
-obj = Object()
-obj.x = 4
-obj.f = f2
-x=5
-obj.f()
-
-print

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/pr/test.pr	2004-05-09 05:29:09 UTC (rev 463)
@@ -1,21 +1,36 @@
+#!/usr/bin/env prothon
 
-def f1(x=''):
-	print 'f1'+x
+object Fixed(Int):
+    dp = 2 
+    divisor = 100
+    
+    def __call__(n=0, decimalplaces=2):
+        obj = Proto(self)
+        obj.dp = decimalplaces
+        obj.divisor = 10
+        obj.__init__(n)   # binary data init here 
+        return obj
 
-def f2(y=''):
-	print 'f2'+y
-	
-f = Proto(f1)
+object PrettyPrintFixed(Fixed): 
 
-f()
+    def __init__(n):
+        Int.__init__{self}(n)
+        # Set default print format width.
+        self.setPrintWidth(self.dp+5)
+        
+    def setPrintWidth(wid):
+        # Create string comprehension "%W.Pf"
+        # where W is wid and P  is selfdp
+        self.pattern =  "%%%i.%if" % (wid, self.dp) 
+        print self.pattern
+        
+    def __str__(): 
+        return  self.pattern % (self / self.divisor)
+        
+print """
+This should print
 
-f.__init__(f2)
-
-f1()
-f2()
-f()
-
-g = Func(f1)
-h = Func(f2)
-g(' g')
-h(' h')
+%6.1f 
+123456.7 
+"""
+print PrettyPrintFixed(1234567, 1)

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/builtins-core.c	2004-05-09 05:29:09 UTC (rev 463)
@@ -741,22 +741,6 @@
 	return new_string_obj(ist, str);
 }
 
-DEF(Func, bind, FPARM1(obj, OBJ(NONE))) {
-	obj_p bindee, bind_obj = copy_object(ist, self);
-
-	BIN_CONTENT_CHK(Func);
-
-	if (parms[1] == OBJ(NONE)) {
-		if (!(bindee = get_attr(ist, self, SYM(__CONTAINER__)))) {
-			raise_exception(ist, OBJ(INTERPRETER_EXC), "no default object found for bind method");		
-			return NULL;
-		}
-	} else
-		bindee = parms[1];
-	set_attr(ist, bind_obj, SYM(__BINDOBJ__), bindee);
-	return bind_obj;
-}
-
 DEF(Func, unbind, NULL) {
 	BIN_CONTENT_CHK(Func);
 	read_unlock(ist, self);
@@ -846,7 +830,6 @@
 	MODULE_SUB_INIT(Func);
 	MODULE_ADD_SYM(Func, __init__);
 	MODULE_ADD_SYM(Func, __str__);
-	MODULE_ADD_SYM(Func, bind);
 	MODULE_ADD_SYM(Func, unbind);
 	MODULE_ADD_SYM(Func, __cDataLen__);
 	MODULE_ADD_SYM(Func, __objList__);

Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/builtins-int.c	2004-05-09 05:29:09 UTC (rev 463)
@@ -108,7 +108,7 @@
 	set_immutable(OBJ(LONG_PROTO));
 }
 
-DEF(Int, __init__, FORM_STAR_PARAM) {
+DEF(Int, __init__, FORM_STAR_PARAM) { // 9bd8c0 9a4760 0 0 9bd820
 	i64_t i = 0;
 	BIN_EMPTY_CHK();
 	if (list_len(ist, parms[1]))

Modified: trunk/src/bytecodes.h
===================================================================
--- trunk/src/bytecodes.h	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/bytecodes.h	2004-05-09 05:29:09 UTC (rev 463)
@@ -116,7 +116,7 @@
 OP_PUSH,
 
 // OBJ(protos)
-// Push new execution frame identical to last except with self set to
+// Push new execution frame identical to last except with default-local set to
 // a new object (usually a prototype) made with prototypes from list protos.
 // New obj also stored at destination reference location on stack.
 // stack length is ((num proto refs)+1)*2 since ref is two stack items
@@ -126,7 +126,7 @@
 OP_OBJ,
 
 // WITH (self)
-// Push new execution frame identical to last except with self
+// Push new execution frame identical to last except with locals
 // equal to top-of-stack.  Similar to a call.
 // Code is in a simple function-object that only has code.
 // stack: self -> <empty>
@@ -162,16 +162,30 @@
 //***       The combined obj/reference represents attributes or data 
 //***		contained in the object that can be read from or written to.
 
+// PUSH_DEF_LOCAL_REF(symbol)
+// push default local reference (local-obj/ref) onto stack
+// stack: -> def-local,symbol
+// param: <unused>
+// |opcode|symbol-key|
+OP_PUSH_DEF_LOCAL_REF,
+
 // PUSH_LOCAL_REF(symbol)
 // push local reference (local-obj/ref) onto stack
-// stack: -> local-dict,symbol
+// stack: -> local-scope,symbol
 // param: <unused>
 // |opcode|symbol-key|
 OP_PUSH_LOCAL_REF,
 
+// PUSH_DEF_GLOBAL_REF(Symbol)
+// push default global reference (global-obj/ref) onto stack
+// stack: -> def-global,symbol
+// param: <unused>
+// |opcode|symbol-key|
+OP_PUSH_DEF_GLOBAL_REF,
+
 // PUSH_GLOBAL_REF(Symbol)
 // push global reference (global-obj/ref) onto stack
-// stack: -> global-dict,symbol
+// stack: -> global-scope,symbol
 // param: <unused>
 // |opcode|symbol-key|
 OP_PUSH_GLOBAL_REF,
@@ -183,26 +197,26 @@
 // |opcode|symbol-key|
 OP_PUSH_SELF_REF,
 
-// PUSH_SUPER_REF(:symbol)
-// push super (inherited) obj reference (self/ref) onto stack
+// PUSH_SUPER_REF(.symbol)
+// push inherited super obj reference (super/ref) onto stack
 // stack: -> super-obj,symbol
 // param: <unused>
 // |opcode|symbol-key|
 OP_PUSH_SUPER_REF,
 
-// PUSH_EXT_REF(^symbol)
-// push inherited local reference (ext-local-obj/ref) onto stack
-// stack: -> ext-local-dict,symbol
+// PUSH_SUPER_REF(.symbol)
+// push inherited super obj reference (super/ref) onto stack
+// stack: -> super-obj,symbol
 // param: <unused>
 // |opcode|symbol-key|
-OP_PUSH_SYN_REF,
+OP_PUSH_OUTER_REF,
 
-// PUSH_DYN_REF(&symbol)
-// push inherited local reference (dynamic-obj/ref) onto stack
-// stack: -> dyn-local-dict,symbol
+// PUSH_SUPER_REF(.symbol)
+// push inherited super obj reference (super/ref) onto stack
+// stack: -> super-obj,symbol
 // param: <unused>
 // |opcode|symbol-key|
-OP_PUSH_DYN_REF,
+OP_PUSH_CALLER_REF,
 
 // BEQ(object-id)
 // branch relative param words in code if top-of-stack equals obj-id
@@ -264,18 +278,42 @@
 // |opcode|
 OP_RESTORE_TMP,
 
+// PUSH_LOCAL
+// push local scope object-id onto stack
+// param: <unused>
+// |opcode|
+OP_PUSH_LOCAL,
+
+// PUSH_GLOBAL
+// push global scope object-id onto stack
+// param: <unused>
+// |opcode|
+OP_PUSH_GLOBAL,
+
 // PUSH_SELF
-// push self object-id onto stack
+// push self scope object-id onto stack
 // param: <unused>
 // |opcode|
 OP_PUSH_SELF,
 
 // PUSH_SUPER
-// push super object-id onto stack
+// push super scope object-id onto stack
 // param: <unused>
 // |opcode|
 OP_PUSH_SUPER,
 
+// PUSH_OUTER
+// push outer scope object-id onto stack
+// param: <unused>
+// |opcode|
+OP_PUSH_OUTER,
+
+// PUSH_CALLER
+// push caller scope object-id onto stack
+// param: <unused>
+// |opcode|
+OP_PUSH_CALLER,
+
 // OP_CHAIN_CMP
 // make chain compare object from items on stack
 // stack: VALUE_OBJ, True/False -> cmp_object
@@ -285,34 +323,42 @@
 // |opcode|
 OP_CHAIN_CMP,
 
+// OBJBIND()
+// bind function (function obj) on stack with obj on stack
+// leave bound method result on stack
+// if bind-tgt is NULL, use self as bind-tgt
+// stack: function-obj,bind-tgt -> bound-function
+// param: <unused>
+// |opcode|
+OP_OBJBIND,
+
+// BIND()
+// bind function (attribute ref pair) on stack with bind-tgt on stack
+// leave bound method result on stack
+// if bind-tgt is NULL, use obj of attr-ref-pair as bind-tgt
+// stack: obj,func-symbol,bind-tgt -> bound-function
+// param: <unused>
+// |opcode|
+OP_BIND,
+
 // OBJCALL(func_obj, params)
-// call unbound function object & params on stack
+// call function, with unbound function object, bind target, & params on stack
 // use locals container for self
 // params are in pairs of optional-label/value
 // pop all and leave result on stack
-// stack: func-object,label,value,label,value,... -> result
+// if bind-tgt is NULL, use current self as bind-tgt
+// stack: func-object,bind-tgt,label,value,label,value,... -> result
 // param: num param pairs on stack
 // |opcode|
 OP_OBJCALL,
 
-// SUPERCALL(object, func, params)
-// call function using object, func-symbol, & params on stack
-// get function by looking up func-symbol in object's attributes
-// call function using current self
-// params are in pairs of optional-label/value
-// label is symbol-obj, PARAM_NORMAL, PARAM_STAR, or PARAM_STAR_STAR	
-// pop all and leave result on stack
-// stack: object,func-symbol,label,value,label,value,... -> result
-// param: num param pairs on stack
-// |opcode|
-OP_SUPERCALL,
-
 // CALL(self, func, params)
-// call function with self-obj, func-symbol, & params on stack
+// call function, with self-obj, func-symbol, bind target, & params on stack
 // params are in pairs of optional-label/value
 // label is symbol-obj, PARAM_NORMAL, PARAM_STAR, or PARAM_STAR_STAR	
 // pop all and leave result on stack
-// stack: obj,func-symbol,label,value,label,value,... -> result
+// if bind-tgt is NULL, use self-obj as bind-tgt
+// stack: self-obj,func-symbol,bind-tgt,label,value,label,value,... -> result
 // param: num param pairs on stack
 // |opcode|
 OP_CALL,

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/interp.c	2004-05-09 05:29:09 UTC (rev 463)
@@ -114,6 +114,8 @@
 	frame->syn_locals		= (func_obj ? get_attr(ist, func_obj, SYM(__SYN_LOCALS__)) : syn_locals);
 	frame->dyn_locals		= dyn_locals;
 	frame->locals			= locals;
+	frame->def_locals		= locals;
+	frame->def_globals		= frame->globals;
 	frame->code				= code;
 	if(!frame->globals)       frame->globals = globals;
 	if(!frame->syn_locals) frame->syn_locals = syn_locals;
@@ -672,7 +674,7 @@
 obj_p exec_loop(isp ist){
 	obj_p  func_obj, temp = NULL;
 	opcode_t op;
-	int i, param, super_flag;
+	int i, param;
 	frame_p switch_frame = NULL, free_frame = NULL, frame = ist->frame;
 	int have_exstk, exc_try_loc = 0, exc_exc_loc = 0, return_flag = FALSE;
 	int exc_final=0, exc_final_return=0, stack_lim = frame->code->max_stack_depth;
@@ -758,62 +760,85 @@
 				for(i=0; i < param; i++) 
 					return_value = fr_pop; 
 				break;
+			case OP_PUSH_LOCAL:
+				fr_push(frame->locals);
+				break;
+			case OP_PUSH_GLOBAL:
+				fr_push(frame->globals);
+				break;
 			case OP_PUSH_SELF:
 				fr_push(frame->self);
 				break;
 			case OP_PUSH_SUPER:
 				fr_push(proto_item(ist, frame->self, 0));
 				break;
-			case OP_PUSH_SELF_REF: 
-				fr_push(frame->self);  
+			case OP_PUSH_OUTER: {
+				if (!frame->syn_locals) {
+					raise_exception(ist, OBJ(INTERPRETER_EXC), "outer not available here");
+					break;
+				}
+				fr_push(frame->syn_locals);  
+			}	break;
+			case OP_PUSH_CALLER:
+				if (!frame->dyn_locals) {
+					raise_exception(ist, OBJ(INTERPRETER_EXC), "caller not available here");
+					break;
+				}
+				fr_push(frame->dyn_locals);  
+				break;
+			case OP_PUSH_DEF_LOCAL_REF: 
+				fr_push(frame->def_locals);  
 				fr_push(fr_data(1)); 
 				break;
-			case OP_PUSH_SUPER_REF: 
-				fr_push(frame->self);  
-				fr_push(new_super_obj(ist, fr_data(1))); 
+			case OP_PUSH_DEF_GLOBAL_REF: 
+				fr_push(frame->def_globals);  
+				fr_push(fr_data(1));
 				break;
+			case OP_PUSH_LOCAL_REF: 
+				fr_push(frame->locals);  
+				fr_push(fr_data(1)); 
+				break;
 			case OP_PUSH_GLOBAL_REF: 
 				fr_push(frame->globals);  
 				fr_push(fr_data(1)); 
 				break;
-			case OP_PUSH_LOCAL_REF: 
-				fr_push(frame->locals);  
+			case OP_PUSH_SELF_REF: 
+				fr_push(frame->self);  
 				fr_push(fr_data(1)); 
 				break;
-			case OP_PUSH_DYN_REF:
-				if (!frame->dyn_locals) {
-					raise_exception(ist, OBJ(INTERPRETER_EXC), "Dynamic access (@x) not available here");
-					break;
-				}
-				fr_push(frame->dyn_locals);  
+			case OP_PUSH_SUPER_REF: 
+				fr_push(proto_item(ist, frame->self, 0));
 				fr_push(fr_data(1)); 
-sloc_break:		break;
-			case OP_PUSH_SYN_REF: {
+				break;
+			case OP_PUSH_OUTER_REF: {
 				obj_p func   = frame->func;
 				obj_p synloc = frame->syn_locals;
 				obj_p sym    = fr_data(1);
 				while (!synloc || !get_attr(ist, synloc, sym)) {
 					if (!func || !(synloc = get_attr(ist, func, SYM(__SYN_LOCALS__)))) {
-						raise_exception(ist, OBJ(INTERPRETER_EXC), "closure variable &%s not found", as_str(ist, sym));
-						goto sloc_break;
+						raise_exception(ist, OBJ(INTERPRETER_EXC), "outer.%s not found", as_str(ist, sym));
+						goto outref_brk;
 					}
 					func = get_attr(ist, func, SYM(__SYN_FUNC__));
 				}
 				fr_push(synloc);  
 				fr_push(sym); 
-			}	break;
+outref_brk:		break;
+			}	
+			case OP_PUSH_CALLER_REF: 
+				if (!frame->dyn_locals) {
+					raise_exception(ist, OBJ(INTERPRETER_EXC), "caller not available here");
+					break;
+				}
+				fr_push(frame->dyn_locals);  
+				fr_push(fr_data(1)); 
+				break;
 			case OP_DEREF: {
-				obj_p att;			fr_sp -= 2;
+				obj_p att;			
+				fr_sp -= 2;
 				att = get_item(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]);
-				if (att) {
-					su(i);
-					if(has_proto_QUES(ist, att, OBJ(FUNC_PROTO)))
-						set_attr(ist, att, SYM(__CONTAINER__), fr_stack[fr_sp]);
-					un_su(i);
-				}
 				fr_push(att);
-				break;
-			}
+			}   break;
 			case OP_ASSIGN: {
 				int sp1, sp2 = fr_sp - param*2;
 				sp1 = sp2 - param;
@@ -995,16 +1020,35 @@
 				frame->next_frame     = new_frame;
 				switch_frame		  = new_frame;
 			}	break;
+			case OP_OBJBIND: {
+				obj_p bindee, bound_meth;
+				fr_sp -= 2;
+				if (!(bindee = fr_stack[fr_sp+1])) bindee = frame->self;
+				bound_meth = copy_object(ist, fr_stack[fr_sp]);
+				set_attr(ist, bound_meth, SYM(__BINDOBJ__), bindee); IF_EXC_BREAK;
+				fr_push(bound_meth);
+			}	break;
+			case OP_BIND: {
+				obj_p obj, bindee, bound_meth;
+				fr_sp -= 3;
+				if (!(bindee = fr_stack[fr_sp+2])) bindee = fr_stack[fr_sp];
+				obj = get_item(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]); IF_EXC_BREAK;
+				bound_meth = copy_object(ist, obj);
+				set_attr(ist, bound_meth, SYM(__BINDOBJ__), bindee); IF_EXC_BREAK;
+				fr_push(bound_meth);
+			}	break;
 			case OP_OBJCALL: {
-				fr_sp -= 1+2*param;
+				fr_sp -= 2+2*param;
 				func_obj = fr_stack[fr_sp];
 				if (func_obj->data_type == DATA_TYPE_FUNCPTR) {
 					obj_p res, self;
 					clist_p plist;
 					if (!func_obj->data.ptr) goto no_func_ptr;
-					plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+1);
-					if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
-						self = frame->self; IF_EXC_BREAK;
+					plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+2);
+					if ( !(self = fr_stack[fr_sp+1]) &&
+						 !(self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
+						self = frame->self; 
+					IF_EXC_BREAK;
 					pre_call_lock(ist, self, plist); IF_EXC_BREAK;
 					res = ((pr_func*)(func_obj->data.ptr))
 								(ist, self, 
@@ -1022,13 +1066,15 @@
 					if (!func_obj->data.ptr) goto no_func_ptr;
 					new_locals = NEW_OBJ(NULL);
 					syn_self = get_attr(ist, func_obj, SYM(__SYN_SELF__)); IF_EXC_BREAK;
-					if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
-						self = frame->self;   IF_EXC_BREAK;
+					if ( !(self = fr_stack[fr_sp+1]) &&
+						 !(self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
+						self = frame->self; 
+					IF_EXC_BREAK;
 					new_frame = create_frame( ist, syn_self, self, NULL, NULL,	
 											  frame->locals, new_locals, func_obj, NULL );
 					fr_next = new_frame;
 					new_frame->prev_frame = frame;
-					load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+1);
+					load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+2);
 					IF_EXC_BREAK;
 					switch_frame = new_frame;
 				} else if (has_proto_QUES(ist, func_obj, OBJ(GEN_PROTO))) {
@@ -1036,13 +1082,12 @@
 					IF_EXC_BREAK;
 					tmp_frame = func_obj->data.ptr;
 					frame->next_frame = tmp_frame;
-					load_frame_params(ist, tmp_frame->locals, func_obj, param*2, fr_stack+fr_sp+1);
+					load_frame_params(ist, tmp_frame->locals, func_obj, param*2, fr_stack+fr_sp+2);
 					IF_EXC_BREAK;
 					fr_push(func_obj);
 				} else {
-					memmove(fr_stack+fr_sp+2, fr_stack+fr_sp+1, (param*2) * sizeof(obj_p));
+					memmove(fr_stack+fr_sp+2, fr_stack+fr_sp+1, (param*2+1) * sizeof(obj_p));
 					fr_stack[fr_sp+1] = SYM(__CALL__);
-					super_flag = FALSE;
 					goto get_func;
 				}
 			}	break;
@@ -1079,18 +1124,14 @@
 			} // fall into OP_WITH on purpose
 			case OP_WITH:
 				fr_sp--;
-				switch_frame = create_frame( ist, NULL, fr_stack[fr_sp], frame->globals, frame->syn_locals, 
+				switch_frame = create_frame( ist, NULL, frame->self, frame->globals, frame->syn_locals, 
 											        frame->dyn_locals, frame->locals, fr_data(1), NULL );
+				switch_frame->def_locals = fr_stack[fr_sp];
 				switch_frame->prev_frame = frame;
 				frame->next_frame = switch_frame;
 end_op_obj:		break;
-			case OP_SUPERCALL:
-				super_flag = TRUE;
-				goto op_call;
 			case OP_CALL: {
-				super_flag = FALSE;
-op_call:
-				fr_sp -= 2+(2*param);
+				fr_sp -= 3+(2*param);
 				if (has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SUPER_PROTO))) {
 					func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]->data.ptr, NULL, frame->syn_self);
 					goto got_func;
@@ -1127,12 +1168,14 @@
 				}
 				if (func_obj->data_type == DATA_TYPE_FUNCPTR){
 					clist_p plist;
-					obj_p res, self, slf = super_flag? frame->self : fr_stack[fr_sp];
+					obj_p res, self;
 					if (!func_obj->data.ptr) goto no_func_ptr2;
-					plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+2);
+					plist = get_func_params(ist, func_obj, param*2, fr_stack+fr_sp+3);
 					IF_EXC_BREAK;
-					if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
-						self = slf;   IF_EXC_BREAK;
+					if ( !(self = fr_stack[fr_sp+2]) &&
+						 !(self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
+						self = fr_stack[fr_sp]; 
+					IF_EXC_BREAK;
 					pre_call_lock(ist, self, plist);  IF_EXC_BREAK;
 					assert(sizeof(obj_p) == sizeof(clist_item_t));
 					res = ((pr_func*)(func_obj->data.ptr))
@@ -1151,13 +1194,15 @@
 					if (!func_obj->data.ptr) goto no_func_ptr2;
 					new_locals = NEW_OBJ(NULL);
 					syn_self = get_attr(ist, func_obj, SYM(__SYN_SELF__)); IF_EXC_BREAK;
-					if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
-						self = super_flag? frame->self : fr_stack[fr_sp];   IF_EXC_BREAK;
-					new_frame = create_frame(	ist, syn_self,  self, NULL, NULL, 
-												frame->locals, new_locals, func_obj, NULL );
+					if ( !(self = fr_stack[fr_sp+2]) &&
+						 !(self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
+						self = fr_stack[fr_sp];
+					IF_EXC_BREAK;
+					new_frame = create_frame( ist, syn_self,  self, NULL, NULL, 
+											  frame->locals, new_locals, func_obj, NULL );
 					fr_next = new_frame;
 					new_frame->prev_frame = frame;
-					load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+2);
+					load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+3);
 					IF_EXC_BREAK;
 					switch_frame = new_frame;
 				} else if (has_proto_QUES(ist, func_obj, OBJ(GEN_PROTO))) {
@@ -1165,7 +1210,7 @@
 					IF_EXC_BREAK;
 					tmp_frame = func_obj->data.ptr;
 					frame->next_frame = tmp_frame;
-					load_frame_params(ist, tmp_frame->locals, func_obj, param*2, fr_stack+fr_sp+2);
+					load_frame_params(ist, tmp_frame->locals, func_obj, param*2, fr_stack+fr_sp+3);
 					IF_EXC_BREAK;
 					fr_push(func_obj);
 				} else {
@@ -1252,7 +1297,7 @@
 				int i;
 				fr_sp -= param;
 				for (i=0; i < param; i++) 
-					if (fr_stack[fr_sp+i]) {
+					if (fr_stack[fr_sp+i]) {  // NOT STACKLESS XXX
 						obj_p str_obj = call_func0(ist, fr_stack[fr_sp+i], SYM(__STR__));
 						IF_EXC_BREAK;
 						printf("%s ", pr_strptr(str_obj));
@@ -1755,6 +1800,18 @@
 		break;
 	case OP_DEF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_DEF", param, codedata(str, code, op, param, pc));
 		break;
+	case OP_PUSH_SELF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SELF", param, codedata(str, code, op, param, pc));
+		break;
+	case OP_PUSH_SUPER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SUPER", param, codedata(str, code, op, param, pc));
+		break;
+	case OP_PUSH_OUTER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_OUTER", param, codedata(str, code, op, param, pc));
+		break;
+	case OP_PUSH_CALLER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_CALLER", param, codedata(str, code, op, param, pc));
+		break;
+	case OP_PUSH_DEF_LOCAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_DEF_LOCAL_REF", param, codedata(str, code, op, param, pc));
+		break;
+	case OP_PUSH_DEF_GLOBAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_DEF_GLOBAL_REF", param, codedata(str, code, op, param, pc));
+		break;
 	case OP_PUSH_LOCAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_LOCAL_REF", param, codedata(str, code, op, param, pc));
 		break;
 	case OP_PUSH_GLOBAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_GLOBAL_REF", param, codedata(str, code, op, param, pc));
@@ -1763,9 +1820,9 @@
 		break;
 	case OP_PUSH_SUPER_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SUPER_REF", param, codedata(str, code, op, param, pc));
 		break;
-	case OP_PUSH_SYN_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SYN_REF", param, codedata(str, code, op, param, pc));
+	case OP_PUSH_OUTER_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_OUTER_REF", param, codedata(str, code, op, param, pc));
 		break;
-	case OP_PUSH_DYN_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_DYN_REF", param, codedata(str, code, op, param, pc));
+	case OP_PUSH_CALLER_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_CALLER_REF", param, codedata(str, code, op, param, pc));
 		break;
 	case OP_BEQ: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_BEQ", param, codedata(str, code, op, param, pc));
 		break;
@@ -1777,10 +1834,6 @@
 		break;
 	case OP_DUPLICATE: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_DUPLICATE", param, codedata(str, code, op, param, pc));
 		break;
-	case OP_PUSH_SELF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SELF", param, codedata(str, code, op, param, pc));
-		break;
-	case OP_PUSH_SUPER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SUPER", param, codedata(str, code, op, param, pc));
-		break;
 	case OP_GEN: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_GEN", param, codedata(str, code, op, param, pc));
 		break;
 	case OP_OBJ: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_OBJ", param, codedata(str, code, op, param, pc));
@@ -1789,10 +1842,12 @@
 		break;
 	case OP_OBJCALL: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_OBJCALL", param, codedata(str, code, op, param, pc));
 		break;
-	case OP_SUPERCALL: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_SUPERCALL", param, codedata(str, code, op, param, pc));
-		break;
 	case OP_CALL: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_CALL", param, codedata(str, code, op, param, pc));
 		break;
+	case OP_OBJBIND: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_OBJBIND", param, codedata(str, code, op, param, pc));
+		break;
+	case OP_BIND: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_BIND", param, codedata(str, code, op, param, pc));
+		break;
 	case OP_ASSIGN: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_ASSIGN", param, codedata(str, code, op, param, pc));
 		break;
 	case OP_SEQ_ASSIGN: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_SEQ_ASSIGN", param, codedata(str, code, op, param, pc));

Modified: trunk/src/interp.h
===================================================================
--- trunk/src/interp.h	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/interp.h	2004-05-09 05:29:09 UTC (rev 463)
@@ -82,6 +82,8 @@
 	obj_p		dyn_locals;
 	obj_p		locals;
 	obj_p		globals;
+	obj_p		def_locals;
+	obj_p		def_globals;
 	int			pc;
 	code_p		code;
 	clist_p		exc_stack;

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/main.c	2004-05-09 05:29:09 UTC (rev 463)
@@ -72,7 +72,9 @@
 
 #define MEMMGR_TIMEOUT	(200/PAUSE_MS)  /* 200 ms */
 
+#ifdef TRACE_PARSER
 extern int yydebug;
+#endif
 
 static apr_pool_t *apr_root_pool = NULL;
 
@@ -111,7 +113,6 @@
 	/* Now that apr is ready, on to our stuff */
 	ist = get_ist(ACC_SYSTEM);
 
-	yydebug = 0;
 
 #ifdef TRACE_PARSER
 	yydebug = 1;

Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/parser.h	2004-05-09 05:29:09 UTC (rev 463)
@@ -110,6 +110,7 @@
 	int			defdoc_flag;
 	int			eof_flag;
 	clist_p		const_objs;
+	FILE*		debug_stream;
 } parse_state;
 
 parse_state* parse_file_or_string(isp ist, char* filename, char* string);
@@ -141,22 +142,28 @@
 clist_p new_list(void* param, code_p item);
 clist_p new_list2(void* param, code_p item1, code_p item2);
 clist_p new_list_list(void* param, clist_p params);
-code_p amp_label_to_attrref(void* param, obj_p label);
 code_p append_code(void* param, code_p p1, code_p p3, int size);
 code_p assign_cleanup(void* param, code_p ass_code);
 code_p assign_right(void* param, clist_p right);
-code_p at_label_to_attrref(void* param, obj_p label);
 code_p attrref_to_tgtparm(void* param, code_p p1);
 code_p binary(void* param, code_p lparm, int op, code_p rparm);
 code_p body_except_else_to_tryexcept(void* param, code_p body, clist_p except_list, code_p els);
 code_p break_stmt(void* param, obj_p label);
-code_p caret_label_to_attrref(void* param, obj_p label);
 code_p cond_exc_to_assert(void* param, code_p cond, code_p exc);
 code_p continue_stmt(void* param, obj_p label);
 code_p del_ref(void* param, code_p expr);
-code_p ds_label_to_attrref(void* param, obj_p label);
-code_p ds_to_obj(void* param);
-code_p caret_to_obj(void* param);
+code_p local_label_to_attrref(void* param, obj_p label);
+code_p global_label_to_attrref(void* param, obj_p label);
+code_p self_label_to_attrref(void* param, obj_p label);
+code_p super_label_to_attrref(void* param, obj_p label);
+code_p outer_label_to_attrref(void* param, obj_p label);
+code_p caller_label_to_attrref(void* param, obj_p label);
+code_p local_to_obj(void* param);
+code_p global_to_obj(void* param);
+code_p self_to_obj(void* param);
+code_p super_to_obj(void* param);
+code_p outer_to_obj(void* param);
+code_p caller_to_obj(void* param);
 code_p exceptall(void* param);
 code_p exec_expr(void* param, code_p expr);
 code_p expr_andor_expr(void* param, code_p lparm, code_p rparm, int andor_flg);
@@ -183,13 +190,17 @@
 code_p obj_label_to_attrref(void* param, code_p obj, obj_p label);
 code_p op_expr(int op, code_p expr, int size);
 code_p print_arglist(void* param, clist_p list);
+code_p push_null(void* param);
 code_p raise_expr(void* param, code_p expr);
 code_p ref_expr_to_ass_op(void* param, code_p ref, code_p rparm, int iop, int op);
 code_p ref_parm_body_to_def(void* param, code_p name, clist_p params, code_p self, code_p body, int flg) ;
 code_p return_expr(void* param, code_p expr);
-code_p self_func_params(void* param, code_p attr_ref, clist_p parms);
+code_p bound_bind_params(void* param, code_p attr_ref, code_p obj);
+code_p unbound_bind_params(void* param, code_p attr_ref, code_p obj);
+code_p bound_func_params(void* param, code_p attr_ref, clist_p parms);
 code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms);
-code_p obj_ds_label_func_params(void* param, code_p attr_ref, obj_p label, clist_p parms);
+code_p bound_bind_func_params(void* param, code_p attr_ref, code_p obj, clist_p parms);
+code_p unbound_bind_func_params(void* param, code_p attr_ref, code_p obj, clist_p parms);
 code_p sparms_to_slice(void* param, code_p p1, code_p p2, code_p p3, int parm_cnt);
 code_p stack_check(void* param, code_p stmt);
 code_p star_ref_to_formparm(void* param, obj_p label);

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/parser_routines.c	2004-05-09 05:29:09 UTC (rev 463)
@@ -61,8 +61,11 @@
 #include "bytecodes.h"
 
 #ifdef TRACE_PARSER
+
+FILE* parse_debug_fout;
+
 code_p debug_retrn(int line_no, code_p res){
-	printf("******> lin:%4d, len:%3d, dep:%3d, max:%3d\n", line_no, res->len, res->stack_depth, res->max_stack_depth);
+	fprintf(parse_debug_fout, "******> lin:%4d, len:%3d, dep:%3d, max:%3d\n", line_no, res->len, res->stack_depth, res->max_stack_depth);
 	return res;
 }
 #endif
@@ -101,9 +104,41 @@
 			return NULL;
 		}
 		if ( !(parse_state = new_parse_state(ist, stream, NULL)) ) return NULL;
-	} else
+	} else {
+		char *d, *s;
+		filename = pr_malloc(39);
+		for (s=string, d=filename; *s && d < filename+30; s++) 
+			if (*s >= 'a' && *s <= 'z' || *s >= 'A' && *s <= 'Z'|| 
+				*s >= '0' && *s <= '9' || *s == '_')
+				*d++ = *s;
+		*d = 0;
+		strcat(filename, "-src.txt");
 		if ( !(parse_state = new_parse_state(ist, NULL, string)) ) return NULL;
+	}
+#ifdef TRACE_PARSER
+	{	char *d, *s, *dfname = pr_malloc(35);
+		for (s=filename, d=dfname; *s && d < dfname+30; s++) 
+			if (*s >= 'a' && *s <= 'z' || *s >= 'A' && *s <= 'Z'|| 
+				*s >= '0' && *s <= '9' || *s == '_')
+				*d++ = *s;
+		*d = 0;
+		strcat(dfname, ".txt");
+		{	size_t len = strlen(dfname);
+			char* dbg_filename = pr_malloc(len+15);
+			strcpy(dbg_filename, "parse_trace-");
+			strcat(dbg_filename, dfname);
+			parse_debug_fout = fopen(dbg_filename, "w");
+			parse_state->debug_stream = parse_debug_fout;
+		}
+	}
+#endif
+
 	yyparse(parse_state);
+
+#ifdef TRACE_PARSER
+	fclose(parse_debug_fout);
+#endif
+
 	if (parse_state->parse_results)
 		parse_state->parse_results->file_path = filename;
 	if (parse_state->num_errors) {
@@ -174,7 +209,7 @@
 }
 
 //********************************* add_code_flg *******************************
-void add_code_flg(code_p newcode, code_p res, int *k, int free_flg){
+void add_code_flg(code_p newcode, code_p res, int *k, int free_flg) {
 	memcpy(res->code_data + *k, newcode->code_data, newcode->len * sizeof(code_t));
 	add_all_srcmap(res, newcode, *k, free_flg);
 	*k += newcode->len;
@@ -227,6 +262,12 @@
 code_p none(void* param){
 	return debug_retrn(__LINE__, new_code(param,0,0,0,0));
 }
+code_p push_null(void* param) {
+	code_p res = new_code(param, 2, 1, 1, OP_PUSH);
+	res->code_data[0].bytecode.param = 2;
+	res->code_data[1].data = NULL;
+	return debug_retrn(__LINE__, res);
+}
 clist_p empty_list(void* param){
 	return new_clist(4);
 }
@@ -353,33 +394,45 @@
 code_p label_to_attrref(void* param, obj_p label){
 	code_p p;
 	if (*(pr_strptr(label)) >= 'A' && *(pr_strptr(label)) <= 'Z')
-		p = new_code(param, 2, 2, 2, OP_PUSH_GLOBAL_REF);
+		p = new_code(param, 2, 2, 2, OP_PUSH_DEF_GLOBAL_REF);
 	else
-		p = new_code(param, 2, 2, 2, OP_PUSH_LOCAL_REF);
+		p = new_code(param, 2, 2, 2, OP_PUSH_DEF_LOCAL_REF);
 	p->code_data[1].data = sym(IST, (pr_strptr(label)));
 	return debug_retrn(__LINE__, p);
 }
-code_p ds_label_to_attrref(void* param, obj_p label){
+code_p local_label_to_attrref(void* param, obj_p label){
 	code_p p;
+	p = new_code(param, 2, 2, 2, OP_PUSH_LOCAL_REF);
+	p->code_data[1].data = sym(IST, pr_strptr(label));
+	return debug_retrn(__LINE__, p);
+}
+code_p global_label_to_attrref(void* param, obj_p label){
+	code_p p;
+	p = new_code(param, 2, 2, 2, OP_PUSH_GLOBAL_REF);
+	p->code_data[1].data = sym(IST, pr_strptr(label));
+	return debug_retrn(__LINE__, p);
+}
+code_p self_label_to_attrref(void* param, obj_p label){
+	code_p p;
 	p = new_code(param, 2, 2, 2, OP_PUSH_SELF_REF);
 	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p caret_label_to_attrref(void* param, obj_p label){
+code_p super_label_to_attrref(void* param, obj_p label){
 	code_p p;
 	p = new_code(param, 2, 2, 2, OP_PUSH_SUPER_REF);
 	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p amp_label_to_attrref(void* param, obj_p label){
+code_p outer_label_to_attrref(void* param, obj_p label){
 	code_p p;
-	p = new_code(param, 2, 2, 2, OP_PUSH_SYN_REF);
+	p = new_code(param, 2, 2, 2, OP_PUSH_OUTER_REF);
 	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p at_label_to_attrref(void* param, obj_p label){
+code_p caller_label_to_attrref(void* param, obj_p label){
 	code_p p;
-	p = new_code(param, 2, 2, 2, OP_PUSH_DYN_REF);
+	p = new_code(param, 2, 2, 2, OP_PUSH_CALLER_REF);
 	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
@@ -415,45 +468,113 @@
 	assert(k==res->len);
 	return debug_retrn(__LINE__, res);
 }
-code_p self_func_params(void* param, code_p attr_ref, clist_p parms){
+code_p bound_bind_params(void* param, code_p attr_ref, code_p obj){
 	code_p res;
-	int i, k=0;
-	int len = attr_ref->len;
-	int stack_depth = attr_ref->stack_depth;
-	int max_stack_depth = attr_ref->max_stack_depth;
+	int k=0, len = 0, stack_depth = 0, max_stack_depth = 0;
+	calc_code(attr_ref, &len, &stack_depth, &max_stack_depth);
+	calc_code(obj, &len, &stack_depth, &max_stack_depth);
+	res = new_code(param, len+1, stack_depth, max_stack_depth, 0);
+	add_code(attr_ref, res, &k);
+	add_code(obj, res, &k);
+	res->code_data[k++].bytecode.opcode  = OP_BIND;
+	res->stack_depth -= 2;
+	assert(k == res->len);
+	return debug_retrn(__LINE__, res);
+}
+code_p unbound_bind_params(void* param, code_p attr_ref, code_p obj){
+	code_p res;
+	int k=0, len = 0, stack_depth = 0, max_stack_depth = 0;
+	calc_code(attr_ref, &len, &stack_depth, &max_stack_depth);
+	calc_code(obj, &len, &stack_depth, &max_stack_depth);
+	res = new_code(param, len+1, stack_depth, max_stack_depth, 0);
+	add_code(attr_ref, res, &k);
+	res->code_data[k++].bytecode.opcode = OP_DEREF;
+	add_code(obj, res, &k);
+	res->code_data[k++].bytecode.opcode  = OP_OBJBIND;
+	res->stack_depth -= 2;
+	assert(k == res->len);
+	return debug_retrn(__LINE__, res);
+}
+code_p bound_func_params(void* param, code_p attr_ref, clist_p parms) {
+	code_p res, nul = push_null(param);
+	int i, k=0, len = 0, stack_depth = 0, max_stack_depth = 5;
 	int llen = clist_len(parms);
+	calc_code(attr_ref, &len, &stack_depth, &max_stack_depth);
+	calc_code(nul, &len, &stack_depth, &max_stack_depth);
 	for(i=0; i < llen; i++)
 		calc_code(clist_item(parms,i), &len, &stack_depth, &max_stack_depth);
 	res = new_code(param, len+1, stack_depth, max_stack_depth, 0);
 	add_code(attr_ref, res, &k);
+	add_code(nul, res, &k);
 	for(i=0; i < llen; i++)
 		add_code(clist_item(parms,i), res, &k);
 	res->code_data[k].bytecode.opcode  = OP_CALL;
 	res->code_data[k++].bytecode.param = clist_len(parms);
-	res->stack_depth -= 1+(2*llen);
+	res->stack_depth -= 2+(2*llen);
 	assert(k==res->len);
 	return debug_retrn(__LINE__, res);
 }
-code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms){
+code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms) {
+	code_p res, nul = push_null(param);
+	int i, k=0, len = 0, stack_depth = 0, max_stack_depth = 0;
+	int llen = clist_len(parms);
+	calc_code(attr_ref, &len, &stack_depth, &max_stack_depth);
+	calc_code(nul, &len, &stack_depth, &max_stack_depth);
+	for(i=0; i < llen; i++)
+		calc_code(clist_item(parms,i), &len, &stack_depth, &max_stack_depth);
+	res = new_code(param, len+2, stack_depth, max_stack_depth, 0);
+	add_code(attr_ref, res, &k);
+	res->code_data[k++].bytecode.opcode = OP_DEREF;
+	add_code(nul, res, &k);
+	for(i=0; i < llen; i++)
+		add_code(clist_item(parms,i), res, &k);
+	res->code_data[k  ].bytecode.opcode = OP_OBJCALL;
+	res->code_data[k++].bytecode.param  = clist_len(parms);
+	res->stack_depth -= 2+(2*llen);
+	assert(k==res->len);
+	return debug_retrn(__LINE__, res);
+}
+code_p bound_bind_func_params(void* param, code_p attr_ref, code_p obj, clist_p parms) {
 	code_p res;
-	int i, k=0;
-	int len = attr_ref->len;
-	int stack_depth = attr_ref->stack_depth;
-	int max_stack_depth = attr_ref->max_stack_depth;
+	int i, k=0, len = 0, stack_depth = 0, max_stack_depth = 0;
 	int llen = clist_len(parms);
+	calc_code(attr_ref, &len, &stack_depth, &max_stack_depth);
+	calc_code(obj, &len, &stack_depth, &max_stack_depth);
 	for(i=0; i < llen; i++)
 		calc_code(clist_item(parms,i), &len, &stack_depth, &max_stack_depth);
 	res = new_code(param, len+2, stack_depth, max_stack_depth, 0);
 	add_code(attr_ref, res, &k);
 	res->code_data[k++].bytecode.opcode = OP_DEREF;
+	add_code(obj, res, &k);
 	for(i=0; i < llen; i++)
 		add_code(clist_item(parms,i), res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_OBJCALL;
 	res->code_data[k++].bytecode.param  = clist_len(parms);
-	res->stack_depth -= 1+(2*llen);
+	res->stack_depth -= 2+(2*llen);
 	assert(k==res->len);
 	return debug_retrn(__LINE__, res);
 }
+code_p unbound_bind_func_params(void* param, code_p attr_ref, code_p obj, clist_p parms){
+	code_p res;
+	int i, k=0, len = 0, stack_depth = 0, max_stack_depth = 0;
+	int llen = clist_len(parms);
+	calc_code(attr_ref, &len, &stack_depth, &max_stack_depth);
+	calc_code(obj, &len, &stack_depth, &max_stack_depth);
+	for(i=0; i < llen; i++)
+		calc_code(clist_item(parms,i), &len, &stack_depth, &max_stack_depth);
+	res = new_code(param, len+2, stack_depth, max_stack_depth, 0);
+	add_code(attr_ref, res, &k);
+	res->code_data[k++].bytecode.opcode = OP_DEREF;
+	add_code(obj, res, &k);
+	for(i=0; i < llen; i++)
+		add_code(clist_item(parms,i), res, &k);
+	res->code_data[k  ].bytecode.opcode = OP_OBJCALL;
+	res->code_data[k++].bytecode.param  = clist_len(parms);
+	res->stack_depth -= 2+(2*llen);
+	assert(k==res->len);
+	return debug_retrn(__LINE__, res);
+}
+/*
 code_p obj_ds_label_func_params(void* param, code_p obj, obj_p label,  clist_p parms) {
 	code_p res;
 	int i, k=0;
@@ -476,6 +597,7 @@
 	assert(k==res->len);
 	return debug_retrn(__LINE__, res);
 }
+*/
 code_p label_to_formparm(void* param, obj_p label){
 	code_p res = new_code(param, 3, 2, 2, OP_PUSH);
 	res->code_data[0].bytecode.param = 3;
@@ -584,12 +706,13 @@
 	return debug_retrn(__LINE__, expr);
 }
 code_p unary(void* param, int op, code_p parm){
-	parm->len += 3;
-	parm->max_stack_depth = max(parm->max_stack_depth, parm->stack_depth + 1);
+	parm->len += 4;
+	parm->max_stack_depth = max(parm->max_stack_depth, parm->stack_depth + 5);
 	parm = pr_realloc(parm, sizeof(code)+(parm->len)*sizeof(code_t));
-	parm->code_data[parm->len-3].bytecode.opcode = OP_PUSH;
-	parm->code_data[parm->len-3].bytecode.param = 2;
-	parm->code_data[parm->len-2].data = sym_id_table[op].id;
+	parm->code_data[parm->len-4].bytecode.opcode = OP_PUSH;
+	parm->code_data[parm->len-4].bytecode.param = 3;
+	parm->code_data[parm->len-3].data = sym_id_table[op].id;
+	parm->code_data[parm->len-2].data = NULL;
 	parm->code_data[parm->len-1].bytecode.opcode = OP_CALL;
 	parm->code_data[parm->len-1].bytecode.param  = 0;
 	return debug_retrn(__LINE__, parm);
@@ -597,14 +720,14 @@
 code_p binary(void* param, code_p lparm, int op, code_p rparm){
 	code_p res;
 	int have_lparm = FALSE;
-	int k=0, len=0, stack_depth=4, max_stack_depth = 4;
+	int k=0, len=0, stack_depth=7, max_stack_depth = 7;
 	int have_cmp_op = (op >= __LT__QUES && op <= __EQ__QUES);
 	if (lparm->cmp_expr && have_cmp_op) {
 		lparm->cmp_expr = FALSE;
 		calc_code(lparm, &len, &stack_depth, &max_stack_depth);
-		len += 5;
+		len += 6;
 		calc_code(rparm, &len, &stack_depth, &max_stack_depth);
-		len += 7;
+		len += 8;
 		res = new_code(param, len, stack_depth, max_stack_depth, 0);
 		res->cmp_expr = TRUE;
 		add_code(lparm, res, &k);
@@ -613,8 +736,9 @@
 		k++;
 		res->code_data[k++].data            = OBJ(PR_FALSE);
 		res->code_data[k  ].bytecode.opcode = OP_PUSH;
-		res->code_data[k++].bytecode.param  = 2;
+		res->code_data[k++].bytecode.param  = 3;
 		res->code_data[k++].data = SYM(__GETCMP__);
+		res->code_data[k++].data = NULL;
 		res->code_data[k  ].bytecode.opcode = OP_CALL;
 		res->code_data[k++].bytecode.param  = 0;
 		have_lparm = TRUE;
@@ -625,7 +749,7 @@
 			calc_code(rparm, &len, &stack_depth, &max_stack_depth);
 			len++;
 		}
-		len += 3;
+		len += 4;
 		if (have_cmp_op) len++;
 		else calc_code(rparm, &len, &stack_depth, &max_stack_depth);
 		len++;
@@ -640,12 +764,13 @@
 			res->code_data[k++].bytecode.opcode = OP_SWAP;
 		}
 		res->code_data[k  ].bytecode.opcode = OP_PUSH;
-		res->code_data[k++].bytecode.param  = 3;
+		res->code_data[k++].bytecode.param  = 4;
 		res->code_data[k++].data = sym_id_table[op].id;
+		res->code_data[k++].data = NULL;
 		res->code_data[k++].data = PARAM_NORMAL;
 		if (have_cmp_op) {
 			res->code_data[k  ].bytecode.opcode = OP_DUPLICATE;
-			res->code_data[k++].bytecode.param  = -4;
+			res->code_data[k++].bytecode.param  = -5;
 		} else
 			add_code(rparm, res, &k);
 		res->code_data[k  ].bytecode.opcode = OP_CALL;
@@ -659,15 +784,16 @@
 }
 code_p expr_andor_expr(void* param, code_p lparm, code_p rparm, int andor_flg){
 	int k=0;
-	code_p res = new_code( param,  lparm->len + 7 + rparm->len + 2, 1, 
+	code_p res = new_code( param,  lparm->len + 8 + rparm->len + 3, 3, 
 				          max( max( lparm->max_stack_depth, 
-				          lparm->stack_depth+1+rparm->max_stack_depth ), 3 ), 0 );
+				          lparm->stack_depth+2+rparm->max_stack_depth ), 4 ), 0 );
 	add_code(lparm, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_DUPLICATE;
 	res->code_data[k++].bytecode.param  = -1;
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 2;
+	res->code_data[k++].bytecode.param  = 3;
 	res->code_data[k++].data = SYM(__BOOL__QUES);
+	res->code_data[k++].data = NULL;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
 	res->code_data[k++].bytecode.param  = 0;
 	res->code_data[k  ].bytecode.opcode = OP_BEQ;
@@ -683,11 +809,12 @@
 	res->code_data[k++].bytecode.param  = 1;
 	return debug_retrn(__LINE__, res);
 }
-#define SKIP_CODE1_LEN 6
+#define SKIP_CODE1_LEN 7
 void add_skip_code1(code_p body, code_p res, int* k){
 	res->code_data[(*k)  ].bytecode.opcode = OP_PUSH;
-	res->code_data[(*k)++].bytecode.param  = 2;
+	res->code_data[(*k)++].bytecode.param  = 3;
 	res->code_data[(*k)++].data = SYM(__BOOL__QUES);
+	res->code_data[(*k)++].data = NULL;
 	res->code_data[(*k)  ].bytecode.opcode = OP_CALL;
 	res->code_data[(*k)++].bytecode.param  = 0;
 	res->code_data[(*k)  ].bytecode.opcode = OP_BEQ;
@@ -795,7 +922,7 @@
 	*max_stack_depth = max(*max_stack_depth, *stack_depth);
 
 	calc_code(ifexpr, len, stack_depth, max_stack_depth);
-	*len += 5;
+	*len += 6;
 	if (lccp < len_lcc) {
 		if (clist_len(clist_item(lcc, lccp)) == 1)
 			calc_if_clause( param, itemexpr, clist_item(clist_item(lcc, lccp), 0), lccp+1, lcc,
@@ -822,8 +949,9 @@
 
 	add_code(ifexpr, res, k);
 	res->code_data[(*k)  ].bytecode.opcode = OP_PUSH;
-	res->code_data[(*k)++].bytecode.param  = 2;
+	res->code_data[(*k)++].bytecode.param  = 3;
 	res->code_data[(*k)++].data = SYM(__BOOL__QUES);
+	res->code_data[(*k)++].data = NULL;
 	res->code_data[(*k)  ].bytecode.opcode = OP_CALL;
 	res->code_data[(*k)++].bytecode.param  = 0;
 	res->code_data[(*k)  ].bytecode.opcode = OP_BEQ;
@@ -860,9 +988,9 @@
 	*stack_depth += 3;
 	*max_stack_depth = max(*max_stack_depth, *stack_depth);
 	calc_code(expr, len, stack_depth, max_stack_depth);
-	*len += 4;
+	*len += 5;
 	loop_loc = *len;
-	*len += llen-1+6;
+	*len += llen-1+7;
 	if (lccp < len_lcc) {
 		if (clist_len(clist_item(lcc, lccp)) == 1)
 			calc_if_clause( param, itemexpr, clist_item(clist_item(lcc, lccp), 0), lccp+1, lcc,
@@ -905,8 +1033,9 @@
 	}
 	add_code(expr, res, k);
 	res->code_data[*k    ].bytecode.opcode = OP_PUSH;
-	res->code_data[(*k)++].bytecode.param  = 2;
+	res->code_data[(*k)++].bytecode.param  = 3;
 	res->code_data[(*k)++].data = SYM(__ITER__);
+	res->code_data[(*k)++].data = NULL;
 	res->code_data[*k    ].bytecode.opcode = OP_CALL;
 	res->code_data[(*k)++].bytecode.param  = 0;
 	res->code_data[*k    ].bytecode.opcode = OP_TRYEXCEPT;
@@ -916,8 +1045,9 @@
 	res->code_data[*k    ].bytecode.opcode = OP_DUPLICATE;
 	res->code_data[(*k)++].bytecode.param  = -1;
 	res->code_data[*k    ].bytecode.opcode = OP_PUSH;
-	res->code_data[(*k)++].bytecode.param  = 2;
+	res->code_data[(*k)++].bytecode.param  = 3;
 	res->code_data[(*k)++].data = SYM(NEXT);
+	res->code_data[(*k)++].data = NULL;
 	res->code_data[*k    ].bytecode.opcode = OP_CALL;
 	res->code_data[(*k)++].bytecode.param  = 0;
 	res->code_data[*k    ].bytecode.opcode = OP_PUSH;
@@ -992,9 +1122,9 @@
 		clist_item(targets,i) = sym(IST, (pr_strptr(s)));
 	}
 	calc_code(expr, &len, &stack_depth, &max_stack_depth); 
-	len += 4;			
+	len += 5;			
 	loop_loc = len;  
-	len += llen + 5;	
+	len += llen + 6;	
 	body_loc = len;  
 	calc_code(body, &len, &stack_depth, &max_stack_depth); 
 	len += 3;			
@@ -1008,8 +1138,9 @@
 	res = new_code(param, len, stack_depth, max_stack_depth+2, 0);
 	add_code(expr, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 2;
+	res->code_data[k++].bytecode.param  = 3;
 	res->code_data[k++].data = SYM(__ITER__);
+	res->code_data[k++].data = NULL;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
 	res->code_data[k++].bytecode.param  = 0;
 	res->code_data[k  ].bytecode.opcode = OP_TRYEXCEPT;
@@ -1021,6 +1152,7 @@
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
 	res->code_data[k++].bytecode.param  = 2;
 	res->code_data[k++].data = SYM(NEXT);
+	res->code_data[k++].data = NULL;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
 	res->code_data[k++].bytecode.param  = 0;
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
@@ -1063,13 +1195,13 @@
 	calc_code(rparm, &len, &stack_depth, &max_stack_depth); 
 	len += 2;
 	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
-	len += 8;
+	len += 9;
 	end_icall_loc = len;
 	len += 4;
 	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
 	len += 6;
 	calc_code(ref, &len, &stack_depth, &max_stack_depth);
-	len += 2;
+	len += 3;
 	end_exc_loc = len;
 	len++;
 	end_loc = len;
@@ -1082,8 +1214,9 @@
 	add_code_no_free(ref, res, &k);
 	res->code_data[k++].bytecode.opcode = OP_DEREF;
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 3;
+	res->code_data[k++].bytecode.param  = 4;
 	res->code_data[k++].data = sym_id_table[iop].id;
+	res->code_data[k++].data = NULL;
 	res->code_data[k++].data = PARAM_NORMAL;
 	res->code_data[k++].bytecode.opcode = OP_RESTORE_TMP;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
@@ -1104,8 +1237,9 @@
 	add_code_no_free(ref, res, &k);
 	res->code_data[k++].bytecode.opcode = OP_DEREF;
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 3;
+	res->code_data[k++].bytecode.param  = 4;
 	res->code_data[k++].data = sym_id_table[op].id;
+	res->code_data[k++].data = NULL;
 	res->code_data[k++].data = PARAM_NORMAL;
 	res->code_data[k++].bytecode.opcode = OP_RESTORE_TMP;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
@@ -1123,12 +1257,12 @@
 }
 code_p while_expr_body_else(void* param, obj_p label, code_p expr, code_p body, code_p els){
 	code *res;
-	int k=0, len=0, stack_depth=0, max_stack_depth = 3;
+	int k=0, len=0, stack_depth=0, max_stack_depth = 6;
 	int loop_loc, body_loc, els_loc, end_loc;
 	patch_break_continues(label, body);
 	loop_loc = len;
 	calc_code(expr, &len, &stack_depth, &max_stack_depth); 
-	len += 6;
+	len += 7;
 	body_loc = len;  
 	calc_code(body, &len, &stack_depth, &max_stack_depth); 
 	len += 2;			
@@ -1141,8 +1275,9 @@
 	assert(loop_loc == k);
 	add_code(expr, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 2;
+	res->code_data[k++].bytecode.param  = 3;
 	res->code_data[k++].data = SYM(__BOOL__QUES);
+	res->code_data[k++].data = NULL;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
 	res->code_data[k++].bytecode.param  = 0;
 	res->code_data[k  ].bytecode.opcode = OP_BEQ;
@@ -1168,20 +1303,21 @@
 	return debug_retrn(__LINE__, res);
 }
 code_p cond_exc_to_assert(void* param, code_p cond, code_p exc){
-	int k=0, len=0, stack_depth=0, max_stack_depth=4, pop_loc;
+	int k=0, len=0, stack_depth=0, max_stack_depth=7, pop_loc;
 	code *res;
 	if(!((parse_state*) param)->assert_enbld)
 		return debug_retrn(__LINE__, none(param));
 	calc_code(cond, &len, &stack_depth, &max_stack_depth);
-	len += 6;
+	len += 7;
 	calc_code(exc, &len, &stack_depth, &max_stack_depth);
 	len++;
 	pop_loc = len;
 	res = new_code(param, len+1, stack_depth, max_stack_depth, 0);
 	add_code(cond, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 2;
+	res->code_data[k++].bytecode.param  = 3;
 	res->code_data[k++].data = SYM(__BOOL__QUES);
+	res->code_data[k++].data = NULL;
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
 	res->code_data[k++].bytecode.param  = 0;
 	res->code_data[k  ].bytecode.opcode = OP_BEQ;
@@ -1400,14 +1536,30 @@
 	add_to_const_list(param, obj);
 	return debug_retrn(__LINE__, p);
 }
-code_p ds_to_obj(void* param){
+code_p local_to_obj(void* param){
+	code_p p = new_code(param, 1, 1, 1, OP_PUSH_LOCAL);
+	return debug_retrn(__LINE__, p);
+}
+code_p global_to_obj(void* param){
+	code_p p = new_code(param, 1, 1, 1, OP_PUSH_GLOBAL);
+	return debug_retrn(__LINE__, p);
+}
+code_p self_to_obj(void* param){
 	code_p p = new_code(param, 1, 1, 1, OP_PUSH_SELF);
 	return debug_retrn(__LINE__, p);
 }
-code_p caret_to_obj(void* param){
+code_p super_to_obj(void* param){
 	code_p p = new_code(param, 1, 1, 1, OP_PUSH_SUPER);
 	return debug_retrn(__LINE__, p);
 }
+code_p outer_to_obj(void* param){
+	code_p p = new_code(param, 1, 1, 1, OP_PUSH_OUTER);
+	return debug_retrn(__LINE__, p);
+}
+code_p caller_to_obj(void* param){
+	code_p p = new_code(param, 1, 1, 1, OP_PUSH_CALLER);
+	return debug_retrn(__LINE__, p);
+}
 code_p assign_right(void* param, clist_p right){
 	code_p res;
 	int i, k=0, len=0, stack_depth=0, max_stack_depth = 0;

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/prothon.y	2004-05-09 05:29:09 UTC (rev 463)
@@ -57,7 +57,6 @@
  
 %{
 
-#define YYDEBUG 1
 #define YYERROR_VERBOSE 1
 
 #define alloca			pr_malloc
@@ -76,7 +75,13 @@
 #define state ((parse_state*) yylex_param)
 
 #define TD new_string_obj(state->ist, "~")
-
+
+#define YYDEBUG 0
+#ifdef TRACE_PARSER
+#undef YYDEBUG
+#define YYDEBUG 1
+#define fout   state->debug_stream
+#endif
 %}
 
 /* BISON Declarations */
@@ -98,6 +103,7 @@
 %nonassoc AS 
 %nonassoc ASSERT    
 %nonassoc BREAK     
+%nonassoc CALLER  
 %nonassoc CONTINUE  
 %nonassoc DEF_       
 %nonassoc DEL       
@@ -109,13 +115,18 @@
 %nonassoc FOR       
 %nonassoc FROM      
 %nonassoc GEN      
+%nonassoc GLOBAL      
 %nonassoc IF        
 %nonassoc IMPORT    
+%nonassoc LOCAL
 %nonassoc OBJ_      
+%nonassoc OUTER      
 %nonassoc PASS      
 %nonassoc PRINT     
 %nonassoc RAISE     
 %nonassoc RETURN    
+%nonassoc SELF    
+%nonassoc SUPER    
 %nonassoc TRY       
 %nonassoc WHILE     
 %nonassoc WITH    
@@ -175,13 +186,9 @@
 %nonassoc '~'	   
 %right	  EXP	 
 %left	  '.'	   
-%left	  '$'	   
 %left	  ':'	   
 %nonassoc ELIPS	 
 %nonassoc UDOT
-%nonassoc UCARET
-%nonassoc UAMP
-%nonassoc '@'
 %nonassoc PAREN
 %nonassoc TUPLE
 %nonassoc FUNC
@@ -200,21 +207,21 @@
 %nonassoc <str_type>	LABEL			/*  \b\w+\b										*/
 
 %type <list_type> import_path import_param import_params target
-			target_params function_params brace_params
+			target_params func_params brace_params
 			brace_params2 brace_param mul_except ass_expr_list
 			formal_params elif mul_elif list_params
 			list_params2 arg_list for_refs for_refs1 for_refs2
 			arg_list2 tuple_params tuple_params2 for_lc_clause
-			lc_clauses if_lc_clause protos proto_refs
+			lc_clauses if_lc_clause protos proto
 
 %type <code_type>	statement_block statement mul_statement
-			mul_statements compound_statement expr obj
+			mul_statements compound_statement expr obj obj_or_empty
 			assignment_statement assignment_statement2
 			def_statement import_statement small_statement
-			if_statement while_statement for_statement gen_ref
+			if_statement while_statement for_statement
 			try_except_statement except else_except
-			try_finally_statement obj_ref def_ref print_statement
-			assert_statement target_param attr_ref unbound_ref
+			try_finally_statement print_statement
+			assert_statement target_param unbound_ref bound_ref
 			ass_add_statement ass_sub_statement
 			ass_mul_statement ass_div_statement
 			ass_tdv_statement ass_rem_statement
@@ -224,11 +231,9 @@
 			else slice slice_param formal_param is_not_check
 			function_param break_statement return_statement
 			yield_statement with_statement continue_statement
-			del_statement del_tgt exec_statement
-			raise_statement obj_statement list_comp proto_ref
-
+			del_statement exec_statement attr_ref def_ref gen_ref obj_ref
+			raise_statement obj_statement list_comp					
 					
-					
 /* Grammar */
 %%
 
@@ -327,16 +332,9 @@
 	|	CONTINUE LABEL 												{ $$ = continue_stmt(yylex_param, $2); }
 	;
 del_statement:
-		del_tgt
-	|	del_statement ',' attr_ref									{ $$ = append_code(yylex_param, $1, del_ref(yylex_param, $3), 0); }
-	|	del_statement ',' unbound_ref								{ $$ = append_code(yylex_param, $1, del_ref(yylex_param, $3), 0); }
-	|	del_statement ',' obj '[' slice ']'							{ $$ = append_code(yylex_param, $1, del_ref(yylex_param, append_code(yylex_param, $3, $5, 0)), 0); }
+		DEL target_param											{ $$ = del_ref(yylex_param, $2); }
+	|	del_statement ',' target_param								{ $$ = append_code(yylex_param, $1, del_ref(yylex_param, $3), 0); }
 	;
-del_tgt:
-		DEL attr_ref												{ $$ = del_ref(yylex_param, $2); }
-	|	DEL unbound_ref												{ $$ = del_ref(yylex_param, $2); }
-	|	DEL obj '[' slice ']'										{ $$ = del_ref(yylex_param, append_code(yylex_param, $2, $4, 0)); }
-	;
 exec_statement: 
 		EXEC expr													{ $$ = exec_expr(yylex_param, $2); }
 	;
@@ -380,45 +378,44 @@
 	;
 obj_ref:
 		OBJ_ LABEL													{ $$ = label_to_attrref(yylex_param, $2);		state->defdoc_flag=1; }
-	|	OBJ_ '$' LABEL								%prec UDOT		{ $$ = ds_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	OBJ_ '^' LABEL												{ $$ = caret_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	OBJ_ '&' LABEL								%prec UAMP		{ $$ = amp_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	OBJ_ '@' LABEL												{ $$ = at_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
+	|	OBJ_ LOCAL '.' LABEL										{ $$ = local_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	OBJ_ GLOBAL '.' LABEL										{ $$ = global_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
+	|	OBJ_ SELF '.' LABEL											{ $$ = self_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	OBJ_ SUPER '.' LABEL										{ $$ = super_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	OBJ_ OUTER '.' LABEL										{ $$ = outer_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	OBJ_ CALLER '.' LABEL										{ $$ = caller_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
 	|	OBJ_ obj '.' LABEL											{ $$ = obj_label_to_attrref(yylex_param, $2, $4);state->defdoc_flag=1; }
-	;				
+	;										
 protos:
 		/*none*/													{ $$ = empty_list(yylex_param); }
-	|	proto_refs														
+	|	proto														
 	;																
-proto_refs:
-		proto_ref													{ $$ = new_list(yylex_param, $1); }
-	|	proto_refs ',' proto_ref									{ $$ = append_list(yylex_param, $1, $3); }
+proto:
+		attr_ref													{ $$ = new_list(yylex_param, $1); }
+	|	proto ',' attr_ref											{ $$ = append_list(yylex_param, $1, $3); }
 	;
-proto_ref:
-		LABEL														{ $$ = label_to_attrref(yylex_param, $1); }
-	|	'$' LABEL								%prec UDOT			{ $$ = ds_label_to_attrref(yylex_param, $2); }
-	|	'^' LABEL													{ $$ = caret_label_to_attrref(yylex_param, $2); }
-	|	'&' LABEL								%prec UAMP			{ $$ = amp_label_to_attrref(yylex_param, $2); }
-	|	'@' LABEL													{ $$ = at_label_to_attrref(yylex_param, $2); }
-	;				
 def_statement:	
 		def_ref '('  formal_params ')' compound_body				{ $$ = ref_parm_body_to_def(yylex_param, $1, $3, NULL, $5, DEF_FLG); }
 	|	gen_ref '('  formal_params ')' compound_body				{ $$ = ref_parm_body_to_def(yylex_param, $1, $3, NULL, $5, GEN_FLG); }
 	;
 def_ref:
 		DEF_ LABEL													{ $$ = label_to_attrref(yylex_param, $2);		state->defdoc_flag=1; }
-	|	DEF_ '$' LABEL								%prec UDOT		{ $$ = ds_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	DEF_ '^' LABEL												{ $$ = caret_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	DEF_ '&' LABEL								%prec UAMP		{ $$ = amp_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	DEF_ '@' LABEL												{ $$ = at_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
+	|	DEF_ LOCAL '.' LABEL										{ $$ = local_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	DEF_ GLOBAL '.' LABEL										{ $$ = global_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
+	|	DEF_ SELF '.' LABEL											{ $$ = self_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	DEF_ SUPER '.' LABEL										{ $$ = super_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	DEF_ OUTER '.' LABEL										{ $$ = outer_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	DEF_ CALLER '.' LABEL										{ $$ = caller_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
 	|	DEF_ obj '.' LABEL											{ $$ = obj_label_to_attrref(yylex_param, $2, $4);state->defdoc_flag=1; }
 	;										
 gen_ref:
 		GEN LABEL													{ $$ = label_to_attrref(yylex_param, $2);		state->defdoc_flag=1; }
-	|	GEN '$' LABEL								%prec UDOT		{ $$ = ds_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	GEN '^' LABEL												{ $$ = caret_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	GEN '&' LABEL								%prec UAMP		{ $$ = amp_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
-	|	GEN '@' LABEL												{ $$ = at_label_to_attrref(yylex_param, $3);	state->defdoc_flag=1; }
+	|	GEN LOCAL '.' LABEL											{ $$ = local_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	GEN GLOBAL '.' LABEL										{ $$ = global_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	GEN SELF '.' LABEL											{ $$ = self_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	GEN SUPER '.' LABEL											{ $$ = super_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	GEN OUTER '.' LABEL											{ $$ = outer_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
+	|	GEN CALLER '.' LABEL										{ $$ = caller_label_to_attrref(yylex_param, $4);	state->defdoc_flag=1; }
 	|	GEN obj '.' LABEL											{ $$ = obj_label_to_attrref(yylex_param, $2, $4);state->defdoc_flag=1; }
 	;										
 import_statement:													
@@ -491,15 +488,12 @@
 print_statement:
 		PRINT arg_list												{ $$ = print_arglist(yylex_param, $2); }
 	;
-
 is_not_check:
-		{ $$ = (void *)(unsigned long)__IS__QUES; }
-	|	NOT
-		{ $$ = (void *)(unsigned long)__ISNOT__QUES; }
+		/* empty string */											{ $$ = (void *)(unsigned long)__IS__QUES; }
+	|	NOT															{ $$ = (void *)(unsigned long)__ISNOT__QUES; }
 	;
-
 expr:	
-		expr OR expr
+		expr OR expr												
 		{ $$ = expr_andor_expr(yylex_param, $1, $3, OR_FLAG); }
 
 	| 	expr AND expr
@@ -560,24 +554,35 @@
 	|	obj
 	;
 obj:
-		'$'															{ $$ = ds_to_obj(yylex_param); }
-	|	'^'															{ $$ = caret_to_obj(yylex_param); }
-	|	target_param												{ $$ = tgtparm_to_obj(yylex_param, $1); }
+		LOCAL														{ $$ = local_to_obj(yylex_param); }
+	|	GLOBAL														{ $$ = global_to_obj(yylex_param); }
+	|	SELF														{ $$ = self_to_obj(yylex_param); }
+	|	SUPER														{ $$ = super_to_obj(yylex_param); }
+	|	OUTER														{ $$ = outer_to_obj(yylex_param); }
+	|	CALLER														{ $$ = caller_to_obj(yylex_param); }
 	|	INT_														{ $$ = int_to_obj(yylex_param, $1); }
 	|	LONG_														{ $$ = string_to_obj(yylex_param, $1, NEW_LONG); }
 	| 	FLOAT_														{ $$ = float_to_obj(yylex_param, $1, NEW_REAL); }
 	| 	INT_IMAG													{ $$ = float_to_obj(yylex_param, (double) $1, NEW_IMAG); }
 	|	FLOAT_IMAG													{ $$ = float_to_obj(yylex_param, $1, NEW_IMAG); }
 	| 	STRING														{ $$ = string_to_obj(yylex_param, $1, NEW_STRN); }
+	|	target_param												{ $$ = tgtparm_to_obj(yylex_param, $1); }
 	|	'{' brace_params '}'										{ $$ = new_dict(yylex_param, $2); }
 	|	'[' list_params ']'  	 									{ $$ = new_tuple_list(yylex_param, $2, NEW_LIST_); }
 	| 	'(' expr ')'      			 								{ $$ = $2; }
 	| 	'(' tuple_params ')'         								{ $$ = new_tuple_list(yylex_param, $2, NEW_TUPLE_); }
-	|	obj '(' function_params ')'  								{ $$ = obj_func_params(yylex_param, $1, $3); }
-	| 	attr_ref '(' function_params ')'  							{ $$ = self_func_params(yylex_param, $1, $3); }
-	| 	unbound_ref '(' function_params ')'  						{ $$ = unbound_func_params(yylex_param, $1, $3); }
-	| 	obj '$' LABEL '(' function_params ')'  						{ $$ = obj_ds_label_func_params(yylex_param, $1, $3, $5); }
+	|	obj '(' func_params ')'  									{ $$ = obj_func_params(yylex_param, $1, $3); }
+	| 	bound_ref '{' obj_or_empty '}'  							{ $$ = bound_bind_params(yylex_param, $1, $3); }
+	| 	unbound_ref '{' obj_or_empty '}'  							{ $$ = unbound_bind_params(yylex_param, $1, $3); }
+	| 	bound_ref '{' obj_or_empty '}' '(' func_params ')'  		{ $$ = bound_bind_func_params(yylex_param, $1, $3, $6); }
+	| 	unbound_ref '{' obj_or_empty '}' '(' func_params ')'  		{ $$ = unbound_bind_func_params(yylex_param, $1, $3, $6); }
+	| 	bound_ref '(' func_params ')'  								{ $$ = bound_func_params(yylex_param, $1, $3); }
+	| 	unbound_ref '(' func_params ')'  							{ $$ = unbound_func_params(yylex_param, $1, $3); }
 	;
+obj_or_empty:
+		/* empty string */											{ $$ = push_null(yylex_param); }
+	|	obj
+	;
 target:
 		target_params
 	|	'[' target_params ']'  				 						{ $$ = $2; }
@@ -591,19 +596,33 @@
 	;
 target_param:
 		attr_ref
-	|	unbound_ref
 	|	obj '[' slice ']'											{ $$ = append_code(yylex_param, $1, $3, 0); }
 	;
 attr_ref:
-		'$' LABEL								%prec UDOT			{ $$ = ds_label_to_attrref(yylex_param, $2); }
-	|	'^' LABEL													{ $$ = caret_label_to_attrref(yylex_param, $2); }
-	|	obj '.' LABEL												{ $$ = obj_label_to_attrref(yylex_param, $1, $3); }
+		unbound_ref
+	|	bound_ref
 	;
 unbound_ref:
 		LABEL														{ $$ = label_to_attrref(yylex_param, $1); }
-	|	'&' LABEL								%prec UAMP			{ $$ = amp_label_to_attrref(yylex_param, $2); }
-	|	'@' LABEL													{ $$ = at_label_to_attrref(yylex_param, $2); }
 	;
+bound_ref:
+		LOCAL '.' LABEL												{ $$ = local_label_to_attrref(yylex_param, $3); }
+	|	GLOBAL '.' LABEL											{ $$ = global_label_to_attrref(yylex_param, $3); }
+	|	SELF '.' LABEL												{ $$ = self_label_to_attrref(yylex_param, $3); }
+	|	SUPER '.' LABEL												{ $$ = super_label_to_attrref(yylex_param, $3); }
+	|	OUTER '.' LABEL												{ $$ = outer_label_to_attrref(yylex_param, $3); }
+	|	CALLER '.' LABEL											{ $$ = caller_label_to_attrref(yylex_param, $3); }
+	|	obj '.' LABEL												{ $$ = obj_label_to_attrref(yylex_param, $1, $3); }
+	;
+slice:
+		expr														{ $$ = expr_to_slice(yylex_param, $1); }
+	|	slice_param ':' slice_param									{ $$ = sparms_to_slice(yylex_param, $1, $3, NULL, 2); }
+	|	slice_param ':' slice_param ':' slice_param					{ $$ = sparms_to_slice(yylex_param, $1, $3,   $5, 3); }
+	;
+slice_param:
+		/* empty string */											{ $$ = none(yylex_param); }
+	|	expr														{ $$ = expr_to_sparm(yylex_param, $1); }
+	;
 arg_list:
 		/* empty string */											{ $$ = empty_list(yylex_param); }
 	|   arg_list2													
@@ -613,10 +632,10 @@
 	 	expr														{ $$ = new_list(yylex_param, $1); }
 	|	arg_list2 ',' expr											{ $$ = append_list(yylex_param, $1, $3); }
 	;
-function_params:
+func_params:
 		/* empty string */											{ $$ = empty_list(yylex_param); }
 	|	function_param												{ $$ = new_list(yylex_param, $1); }
-	|	function_params ',' function_param							{ $$ = append_list(yylex_param, $1, $3); }
+	|	func_params ',' function_param							{ $$ = append_list(yylex_param, $1, $3); }
 	;
 function_param:
 		expr														{ $$ = expr_to_param(yylex_param, $1); }
@@ -635,15 +654,6 @@
 	|   '*' LABEL													{ $$ = star_ref_to_formparm(yylex_param, $2); }
 	|   EXP LABEL													{ $$ = star_star_ref_to_formparm(yylex_param, $2); }
 	;
-slice:
-		expr														{ $$ = expr_to_slice(yylex_param, $1); }
-	|	slice_param ':' slice_param									{ $$ = sparms_to_slice(yylex_param, $1, $3, NULL, 2); }
-	|	slice_param ':' slice_param ':' slice_param					{ $$ = sparms_to_slice(yylex_param, $1, $3,   $5, 3); }
-	;
-slice_param:
-		/* empty string */											{ $$ = none(yylex_param); }
-	|	expr														{ $$ = expr_to_sparm(yylex_param, $1); }
-	;
 brace_params:
 		/* empty string */											{ $$ = empty_list(yylex_param); }
 	|	brace_params2
@@ -657,7 +667,7 @@
 		expr ':' expr												{ $$ = new_list2(yylex_param, $1, $3); }
 	;
 tuple_params:
-		{ $$ = new_clist(0); }
+		/* empty string */											{ $$ = new_clist(0); }
 	|	expr ','													{ $$ = new_list(yylex_param, $1); }
 	|	tuple_params2
 	|	tuple_params2 ','
@@ -1129,6 +1139,7 @@
 		if (!strcmp(str_ptr,"as")) 		return AS;
 		if (!strcmp(str_ptr,"assert")) 	return ASSERT;
 		if (!strcmp(str_ptr,"break")) 	return BREAK;
+		if (!strcmp(str_ptr,"caller")) 	return CALLER;
 		if (!strcmp(str_ptr,"continue"))return CONTINUE;
 		if (!strcmp(str_ptr,"def")) 	return DEF_;
 		if (!strcmp(str_ptr,"del")) 	return DEL;
@@ -1140,12 +1151,17 @@
 		if (!strcmp(str_ptr,"for")) 	return FOR;
 		if (!strcmp(str_ptr,"from")) 	return FROM;
 		if (!strcmp(str_ptr,"gen")) 	return GEN;		
+		if (!strcmp(str_ptr,"global")) 	return GLOBAL;		
 		if (!strcmp(str_ptr,"if")) 		return IF;
 		if (!strcmp(str_ptr,"import")) 	return IMPORT;
+		if (!strcmp(str_ptr,"local")) 	return LOCAL;
 		if (!strcmp(str_ptr,"object")) 	return OBJ_;
+		if (!strcmp(str_ptr,"outer")) 	return OUTER;
 		if (!strcmp(str_ptr,"pass")) 	return PASS;
 		if (!strcmp(str_ptr,"print")) 	return PRINT;
 		if (!strcmp(str_ptr,"raise")) 	return RAISE;
+		if (!strcmp(str_ptr,"self")) 	return SELF;
+		if (!strcmp(str_ptr,"super")) 	return SUPER;
 		if (!strcmp(str_ptr,"return")) 	return RETURN;
 		if (!strcmp(str_ptr,"try")) 	return TRY;
 		if (!strcmp(str_ptr,"while")) 	return WHILE;

Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c	2004-05-06 07:09:39 UTC (rev 462)
+++ trunk/src/symbol.c	2004-05-09 05:29:09 UTC (rev 463)
@@ -153,7 +153,6 @@
 	{ "__fromStorProxy__", 0},
 	{ "__call__",       0},
 	{ "__bindObj__",    0},
-	{ "__container__",    0}
 };
 
 typedef struct trie_node_s* trie_p;