|Anonymous | Login||2019-07-15 22:10 UTC|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details|
|ID||Category||Severity||Type||Date Submitted||Last Update|
|0001269||[1003.1(2016)/Issue7+TC2] Shell and Utilities||Objection||Omission||2019-07-10 21:23||2019-07-11 09:33|
|Organization||Zuse Institute Berlin|
|Page Number||3415, 3425–3426|
|Line Number||15000–15006, 115422–115425, 115447–115452|
|Final Accepted Text|
|Summary||0001269: yacc: yychar is mentioned but not further specified|
In both historical and current yacc implementations, the variable yychar holds the lookahead token when a rule is reduced (yylval holds its value). This is primarily useful for handling parser errors and without the existence of yychar, the yyclearin action is rather pointless.
The existence of this variable is suggested by the description of the -p option which reads (in IEEE 1003.1-2017):
> Use sym_prefix instead of yy as the prefix for all external names produced
> by yacc. The names affected shall include the functions yyparse(), yylex(),
> and yyerror(), and the variables yylval, yychar, and yydebug. (In the
> remainder of this section, the six symbols cited are referenced using their
> default names only as a notational convenience.) Local names may also be
> affected by the -p option; however, the -p option shall not affect #define
> symbols generated by yacc.
However, no further specification of yychar is provided. I believe that it was the intent of the committee to provide a specification of yychar, but such a specification was forgotten or accidentally removed during editing. I request a description of yychar and the associated variables YYEMPTY and YYEOF to be added.
Either remove the mention of yychar from he list of variables in lines 15000--15006 or add a description of yychar. I suggest the following description, to be added on its own paragraph before the paragraph starting on line 115422 (or perhaps one paragraph earlier):
> When a parser action is executed, the external int yychar holds either
> the token number of the lookahead token, or YYEMPTY indicating the
> absence of a lookahead token, or YYEOF indicating the end of the token
> stream. yylval holds the value of the lookahead symbol if any.
If a description of YYEOF is added, also change the first sentence of the paragraph starting at line 115447 from:
> The end of the input is marked by a special token called the endmarker,
> which has a token number that is zero or negative. (These values are
> invalid for any other token.)
> The end of the input is marked by a special token YYEOF called the
> endmarker, which has a token number that is zero or negative. (These
> values are invalid for any other token.)
|Tags||No tags attached.|
Neither YYEOF nor YYEMPTY exist in yacc.
With YYDEFBUG, the following code part is used in the file "yaccpar":
if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" );
Do you refer to that?
RE Note: 0004479,
While historical yacc does not have the YYEOF and YYEMPTY macros, other implementations (like Berkeley yacc and GNU bison) have. Some mechanism is required to recognise “no lookahead” and “end of input” or the yychar mechanism is rather hard to use. Since different yacc implementations assign different token numbers to these two cases (and POSIX merely gives us that end-of-input is negative or zero [contrary to e.g. Plan 9 yacc]), it seems hard to distinguish these cases otherwise.
|2019-07-10 21:23||Clausecker||New Issue|
|2019-07-10 21:23||Clausecker||Name||=> Robert Clausecker|
|2019-07-10 21:23||Clausecker||Organization||=> Zuse Institute Berlin|
|2019-07-10 21:23||Clausecker||Section||=> yacc|
|2019-07-10 21:23||Clausecker||Page Number||=> 3415, 3425–3426|
|2019-07-10 21:23||Clausecker||Line Number||=> 15000–15006, 115422–115425, 115447–115452|
|2019-07-11 08:21||joerg||Note Added: 0004479|
|2019-07-11 09:33||Clausecker||Note Added: 0004480|
|Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group|