When to use a token yacc_EOF instead of relying on 0 return value of yylex()?

Peng Yu <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <CABrM6wnTdD0NmX98KTCzDVETS4Nynixk2ddVByKbB10XCVNXLA@mail.gmail.com>
Hi,

yacc_EOF instead of 0 is used in `yylex()`.

http://git.savannah.gnu.org/cgit/bash.git/tree/parse.y#n3257

The grammar explicitly relies on yacc_EOF.

http://git.savannah.gnu.org/cgit/bash.git/tree/parse.y#n376

But this seems to be different from the normal usage in flex/bison.
For example, flex has <<EOF>> (I know bash doesn't use its hand coded
yylex()). Bison expects yylex() to just return 0 upon seeing the EOF
of the input.

""" (From bison manual regarding yylex)
The null character must not be used this way, because its code is zero
and that signifies end-of-input.
"""

So is there a reason bash parsing must the non-standard yacc_EOF? Or
bash parsing can be solved by using a yylex() that returns 0 upon
seeing EOF? Thanks.

-- 
Regards,
Peng

_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.