Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
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
Reporter Clausecker View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Robert Clausecker
Organization Zuse Institute Berlin
User Reference
Section yacc
Page Number 3415, 3425–3426
Line Number 15000–15006, 115422–115425, 115447–115452
Interp Status ---
Final Accepted Text
Summary 0001269: yacc: yychar is mentioned but not further specified
Description 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.
Desired Action 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.)

to

> 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.
Attached Files

- Relationships

-  Notes
(0004479)
joerg (reporter)
2019-07-11 08:21

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?
(0004480)
Clausecker (reporter)
2019-07-11 09:33

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.

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker