help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why yacc_EOF is used as a list_terminator for for_command?


From: Peng Yu
Subject: Re: Why yacc_EOF is used as a list_terminator for for_command?
Date: Mon, 10 May 2021 13:03:27 -0500

On Mon, May 10, 2021 at 12:23 PM Koichi Murase <myoga.murase@gmail.com> wrote:
>
> 2021年5月11日(火) 1:25 Peng Yu <pengyu.ut@gmail.com>:
> > list_terminator is this. I can see why '\n' and ';' are included. But
> > it doesn't make sense to me why yacc_EOF is needed here.
> >
> > list_terminator:'\n'
> > | ';'
> > | yacc_EOF
> > ;
>
> They are in effect in the following places.
>
> pipeline_command: pipeline
>         |       timespec list_terminator
>         |       BANG list_terminator
>
> > It may be useful to include yacc_EOF in other rules.
>
> Do you have a better idea? Where would you include it? Is it worth
> changing the current implementation which works without problems
> currently? It's useless to change the code that actually doesn't
> change any behavior. It may just introduce a new bug.

My goal is not to change the current implementation. I am asking the
question from the perspective of how would one implement it from
scratch.

It is out of my scope on how to make a change without breaking the
current code. Given the uses of many global variables in parse.y, I
feel it is almost impossible to make a structural change to the code
in it hoping to not inadvertently affect something that works
currently.

> > But Is it correct to include it here?
>
> How do you define "correct" and "incorrect"? There can be always many
> different ways to represent a formal language. As far as they accept
> the same set of strings, they are equally correct.

"Correct" means if you were to start from scratch and whether it is
the best of all the possible implementation choices. (Or maybe
"necessary" is a better word in this case.)

>From your writing, it seems that yacc_EOF is unnecessary in the
for-rule. If so, although having yacc_EOF for the for-rule still
works, it could be considered "incorrect" by the above definition.

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]