Index: gram.y
===================================================================
RCS file: /cvsroot/pgsql-server/src/pl/plpgsql/src/gram.y,v
retrieving revision 1.40
retrieving revision 1.41
diff -c -c -r1.40 -r1.41
*** gram.y	10 Nov 2002 00:35:58 -0000	1.40
--- gram.y	25 Mar 2003 03:16:40 -0000	1.41
***************
*** 4,10 ****
   *						  procedural language
   *
   * IDENTIFICATION
!  *	  $Header: /cvsroot/pgsql-server/src/pl/plpgsql/src/gram.y,v 1.40 2002/11/10 00:35:58 momjian Exp $
   *
   *	  This software is copyrighted by Jan Wieck - Hamburg.
   *
--- 4,10 ----
   *						  procedural language
   *
   * IDENTIFICATION
!  *	  $Header: /cvsroot/pgsql-server/src/pl/plpgsql/src/gram.y,v 1.41 2003/03/25 03:16:40 tgl Exp $
   *
   *	  This software is copyrighted by Jan Wieck - Hamburg.
   *
***************
*** 105,111 ****
  %type <nsitem>	decl_aliasitem
  %type <str>		decl_stmts decl_stmt
  
! %type <expr>	expr_until_semi expr_until_then expr_until_loop
  %type <expr>	opt_exitcond
  
  %type <ival>	assign_var cursor_variable
--- 105,112 ----
  %type <nsitem>	decl_aliasitem
  %type <str>		decl_stmts decl_stmt
  
! %type <expr>	expr_until_semi expr_until_rightbracket
! %type <expr>	expr_until_then expr_until_loop
  %type <expr>	opt_exitcond
  
  %type <ival>	assign_var cursor_variable
***************
*** 822,827 ****
--- 823,843 ----
  						check_assignable(yylval.variable);
  						$$ = yylval.variable->dno;
  					}
+ 				| assign_var '[' expr_until_rightbracket
+ 					{
+ 						PLpgSQL_arrayelem	*new;
+ 
+ 						new = malloc(sizeof(PLpgSQL_arrayelem));
+ 						memset(new, 0, sizeof(PLpgSQL_arrayelem));
+ 
+ 						new->dtype		= PLPGSQL_DTYPE_ARRAYELEM;
+ 						new->subscript	= $3;
+ 						new->arrayparentno = $1;
+ 
+ 						plpgsql_adddatum((PLpgSQL_datum *)new);
+ 
+ 						$$ = new->dno;
+ 					}
  				;
  
  stmt_if			: K_IF lno expr_until_then proc_sect stmt_else K_END K_IF ';'
***************
*** 1491,1496 ****
--- 1507,1516 ----
  					{ $$ = plpgsql_read_expression(';', ";"); }
  				;
  
+ expr_until_rightbracket :
+ 					{ $$ = plpgsql_read_expression(']', "]"); }
+ 				;
+ 
  expr_until_then :
  					{ $$ = plpgsql_read_expression(K_THEN, "THEN"); }
  				;
***************
*** 1577,1592 ****
  	for (;;)
  	{
  		tok = yylex();
! 		if (tok == '(')
  			parenlevel++;
! 		else if (tok == ')')
  		{
  			parenlevel--;
  			if (parenlevel < 0)
  				elog(ERROR, "mismatched parentheses");
  		}
- 		else if (parenlevel == 0 && tok == until)
- 			break;
  		/*
  		 * End of function definition is an error, and we don't expect to
  		 * hit a semicolon either (unless it's the until symbol, in which
--- 1597,1612 ----
  	for (;;)
  	{
  		tok = yylex();
! 		if (tok == until && parenlevel == 0)
! 			break;
! 		if (tok == '(' || tok == '[')
  			parenlevel++;
! 		else if (tok == ')' || tok == ']')
  		{
  			parenlevel--;
  			if (parenlevel < 0)
  				elog(ERROR, "mismatched parentheses");
  		}
  		/*
  		 * End of function definition is an error, and we don't expect to
  		 * hit a semicolon either (unless it's the until symbol, in which
***************
*** 1986,1991 ****
--- 2006,2014 ----
  			}
  			break;
  		case PLPGSQL_DTYPE_RECFIELD:
+ 			/* always assignable? */
+ 			break;
+ 		case PLPGSQL_DTYPE_ARRAYELEM:
  			/* always assignable? */
  			break;
  		case PLPGSQL_DTYPE_TRIGARG:
