help-bison
[Top][All Lists]
Advanced

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

When to use a token yacc_EOF instead of relying on 0 return value of yyl


From: Peng Yu
Subject: When to use a token yacc_EOF instead of relying on 0 return value of yylex()?
Date: Mon, 11 Feb 2019 11:12:53 -0600

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



reply via email to

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