Listing 6. Find matching opening parenthesis
public static int pos_open_parenthesis( Vector tokens, int closed_parenthesis )
{
int i;
Token t;
i=closed_parenthesis-2;
while ( i>=0 )
{
t=(Token)tokens.elementAt( i );
if ( t.mark=='(' )
{
return i;
}
i--;
}
return 0;
}
|