* PATCH: function parsing
@ 2002-06-04 16:18 Peter Stephenson
2002-06-04 16:33 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2002-06-04 16:18 UTC (permalink / raw)
To: Zsh hackers list
% zsh -c 'function func { } this fails to cause a parse error'
zsh: parse error near `this'
% zsh -c 'func() { } this fails to cause a parse error'
%
I'm assuming the first is correct, since the second certainly isn't as
the text is simply ignored.
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.34
diff -u -r1.34 parse.c
--- Src/parse.c 2 Jun 2002 18:03:20 -0000 1.34
+++ Src/parse.c 4 Jun 2002 16:09:07 -0000
@@ -1611,6 +1611,8 @@
ecbuf[p] = WCB_FUNCDEF(ecused - 1 - p);
isfunc = 1;
+ isnull = 0;
+ break;
} else
break;
isnull = 0;
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: function parsing
2002-06-04 16:18 PATCH: function parsing Peter Stephenson
@ 2002-06-04 16:33 ` Bart Schaefer
2002-06-05 10:56 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2002-06-04 16:33 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh hackers list
On Tue, 4 Jun 2002, Peter Stephenson wrote:
> % zsh -c 'function func { } this fails to cause a parse error'
> zsh: parse error near `this'
> % zsh -c 'func() { } this fails to cause a parse error'
> %
>
> I'm assuming the first is correct, since the second certainly isn't as
> the text is simply ignored.
While you're at it, any chance you can "fix" redirections following a
function definition? E.g. per ksh (and possibly per posix) this:
func() { less } < /etc/termcap
should be equivalent to this:
func() { { less } < /etc/termcap }
rather than the current zsh equivalent:
{ func() { less } } < /etc/termcap
Note that:
func() less < /etc/termcap
is already equivalent to:
func() { less < /etc/termcap }
so the first case above must be only a small matter of parsing.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: function parsing
2002-06-04 16:33 ` Bart Schaefer
@ 2002-06-05 10:56 ` Peter Stephenson
0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2002-06-05 10:56 UTC (permalink / raw)
To: Zsh hackers list
Bart Schaefer wrote:
> While you're at it, any chance you can "fix" redirections following a
> function definition? E.g. per ksh (and possibly per posix) this:
>
> func() { less } < /etc/termcap
>
> should be equivalent to this:
>
> func() { { less } < /etc/termcap }
I've played with it for a little without success.
I've come to the conclusion the only way to do it will be to rewrite it
internally exactly how you've shown it --- i.e. insert a current-shell
construct (the normal effect of braces) inside the list construct and
attach the redirection to that, but it's a bit of a mess unless we
always parse functions as a current-shell construct.
Maybe later.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-06-05 10:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-04 16:18 PATCH: function parsing Peter Stephenson
2002-06-04 16:33 ` Bart Schaefer
2002-06-05 10:56 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).