Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in case stmt with '('



> So your suggestion would amount to omitting the check for balanced
> parens, thus assuming (in the event that a closing paren is not found)
> that the glob pattern is correctly formed.  This doesn't simplify the
> parser in any significant way, and it delays detection of some other
> malformed glob patterns.

I'm ready to believe that my suggestion doesn't simplify the parser
significantly, but I'm _not_ suggesting to forego checking for balanced parens
-- on the contrary, I assume the parser would only accept well-formed glob
patterns.

	     | required paren
	     v
	"( x ) )"
	       ^
	       | optional paren
	       v
	 " x   )"

What I am suggesting is that the trailing ')' (which if present is UNbalanced)
not be required to be present.  I.e., each well-formed case-prefix pattern
(which may have internal parens or '|'s) is terminated by an [external]
'|', ')', or whitespace; if by whitespace, then the parser considers the
following token: if it is '|' or ')', then parsing of the case-prefix continues,
else the case-prefix is considered complete (the parser regards the whitespace
as equivalent to a trailing ')', if you will), and the token is taken to be
the initial token of the case-clause body.  Accordingly, I believe that
detection of malformed glob patterns would not at all be delayed.
Perhaps my approach might even make it easier to avoid the remaining problem
with Zoltan's current patch.



Messages sorted by: Reverse Date, Date, Thread, Author