zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: (very) bad syntax error checking
@ 2000-05-26 14:24 Peter Stephenson
  2000-05-27  4:02 ` Bart Schaefer
  2000-05-27  8:13 ` PATCH (!): " Bart Schaefer
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Stephenson @ 2000-05-26 14:24 UTC (permalink / raw)
  To: Zsh hackers list

It's rather late in the day to come across problems like this.


% cat test.zsh
if true; # then missing
  print hello
fi

print This line should not be executed.
% zsh -f ./test.zsh
./test.zsh:3: parse error near `fi'
This line should not be executed.


Yuk.  This is the way people accidentally delete all the files on their
disks, etc.  I can't believe this has always been there --- I suspect it
must be part of the parsing changes that we've somehow all missed.  I won't
be releasing anything until this gets fixed.  If it's a lot of code to fix
(I would guess it's just an errflag test or two) I'll hold off for another
week.

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: PATCH (!): Re: PATCH: (very) bad syntax error checking
@ 2000-05-29  8:27 Sven Wischnowsky
  2000-05-29  8:56 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 2000-05-29  8:27 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> Second, encountering the token "fi" alone on a line is not setting the
> returned token to LEXERR, so in init.c the test of (tok == LEXERR) fails
> (the value of `tok' is, not surpisingly, `FI').
> 
> What follows appears to fix it, but Sven should confirm.  For one thing,
> I wonder why parse_list() doesn't use YYERROR() ... is there some reason
> why `ecused' should not be set to 0 in that specific case?

It doesn't use YYERROR* because it has to return NULL and we have
YYERRORs only for void and integer, I think (I didn't change that
part).

And we don't need to reset ecused there, it's one of the top-level
functions that will set up their environments with init_parse() the
next time round.

Your patch looks good, as far as I can see.

> I included a hunk for the grammar test, but why is the line number `-1'?

Because ZTST_execchunk() uses eval to execute the test code and
bin_eval() uses parse_string() with a last argument of zero to turn of 
line numbering. Hm, the fix would be to add a global variable where
bin_eval()/parse_string() (and other functions?) can store the old
line number and the error functions use (lineno < 0 ? savedlineno : lineno)
or something like that, right?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: PATCH (!): Re: PATCH: (very) bad syntax error checking
@ 2000-05-29  9:10 Sven Wischnowsky
  0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 2000-05-29  9:10 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On May 29, 10:27am, Sven Wischnowsky wrote:
> } Subject: Re: PATCH (!): Re: PATCH: (very) bad syntax error checking
> }
> } Bart Schaefer wrote:
> } 
> } > I wonder why parse_list() doesn't use YYERROR() ... is there some reason
> } > why `ecused' should not be set to 0 in that specific case?
> } 
> } It doesn't use YYERROR* because it has to return NULL and we have
> } YYERRORs only for void and integer, I think (I didn't change that
> } part).
> 
> Zero is NULL, and NULL is zero.  Using YYERROR(0) would return NULL.

But we are quite picky about distinguishing between the two.

> But perhaps a better question is: `tok' is a global, right? 

Yes.

> Why not put
> the `tok = LEXERROR' into yyerror() itself?

Good question. Haven't looked yet...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-05-29  9:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-26 14:24 PATCH: (very) bad syntax error checking Peter Stephenson
2000-05-27  4:02 ` Bart Schaefer
2000-05-27  8:13 ` PATCH (!): " Bart Schaefer
2000-05-28 20:51   ` Peter Stephenson
2000-05-29  8:27 Sven Wischnowsky
2000-05-29  8:56 ` Bart Schaefer
2000-05-29  9:10 Sven Wischnowsky

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).