🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Kevin Rodgers Wed, 07 Oct 1992 17:35
bison 1.18 documentation suggestions
#867
Author: Kevin Rodgers
Date: Wed, 07 Oct 1992 17:35
124 lines
5725 bytes
1. The 'Actions' info node should note that an action should be
   specified for each empty rule, since the default action ($$ = $1)
   results in garbage (i.e. a discarded right-hand sided semantic value
   from a previous rule reduction) being pushed onto the stack.

2. The only mention of the default action is in the 'Rpcalc Expr' node;
   it should either be moved to or duplicated in the 'Actions' node.

3. There should be an index entry for each feature for which a default
   exists, namely:

   feature			value				node
   -------			-----				----
   start symbol			first nonterminal defined	Start Decl
   action			$$ = $1				Actions
   conflict resolution		shift (w/o precedence info)	How Precedence
   data type			int				Value Type
   stack size (YYINITDEPTH)	200				Stack Overflow
   stack limit (YYMAXDEPTH)	10000				Stack Overflow

   For each feature F, two indices should be generated:

   default F
   F, default

Here is a patch to bison.texinfo that implements these suggestions:

*** bison.texinfo.dist	Fri Feb  7 15:59:01 1992
--- bison.texinfo	Wed Oct  7 11:32:48 1992
***************
*** 1189,1201 ****
  the second one.  The third component, @code{'+'}, has no meaningful
  associated semantic value, but if it had one you could refer to it as
  @code{$3}.  When @code{yyparse} recognizes a sum expression using this
! rule, the sum of the two subexpressions' values is produced as the value of
! the entire expression.  @xref{Actions}.
  
- You don't have to give an action for every rule.  When a rule has no
- action, Bison by default copies the value of @code{$1} into @code{$$}.
- This is what happens in the first rule (the one that uses @code{NUM}).
- 
  The formatting shown here is the recommended convention, but Bison does
  not require it.  You can add or change whitespace as much as you wish.
  For example, this:
--- 1189,1199 ----
  the second one.  The third component, @code{'+'}, has no meaningful
  associated semantic value, but if it had one you could refer to it as
  @code{$3}.  When @code{yyparse} recognizes a sum expression using this
! rule, the sum of the two subexpressions' values is produced as the value
! of the entire expression.  Since the rule for numeric constants does not
! have an action, the value of the expression is the value of the @code{NUM}
! token as determined by the default rule.  @xref{Actions}.
  
  The formatting shown here is the recommended convention, but Bison does
  not require it.  You can add or change whitespace as much as you wish.
  For example, this:
***************
*** 2271,2276 ****
--- 2269,2276 ----
  the semantic values of all language constructs.  This was true in the
  RPN and infix calculator examples (@pxref{RPN Calc}).
  
+ @cindex default data type
+ @cindex data type, default
  Bison's default is to use type @code{int} for all semantic values.  To
  specify some other type, define @code{YYSTYPE} as a macro, like this:
  
***************
*** 2349,2354 ****
--- 2349,2364 ----
  useful semantic value associated with the @samp{+} token, it could be
  referred to as @code{$2}.@refill
  
+ @cindex default action
+ @cindex action, default
+ You don't have to give an action for every rule.  When a rule has no
+ action, Bison by default copies the value of @code{$1} into @code{$$}.
+ 
+ However, you should give an action for each empty rule, because in these
+ cases the default action would result in garbage (i.e. an indeterminate
+ value, possibly one discarded during a previous rule reduction) becoming
+ the semantic value of the rule.
+ 
  @code{$@var{n}} with @var{n} zero or negative is allowed for reference
  to tokens and groupings on the stack @emph{before} those that match the
  current rule.  This is a very risky practice, and to use it reliably
***************
*** 2813,2818 ****
--- 2823,2830 ----
  @cindex start symbol, declaring
  @findex %start
  
+ @cindex default start symbol
+ @cindex start symbol, default
  Bison assumes by default that the start symbol for the grammar is the first
  nonterminal specified in the grammar specification section.  The programmer
  may override this restriction with the @code{%start} declaration as follows:
***************
*** 3608,3613 ****
--- 3620,3627 ----
  verbose output file made by @samp{-v} (@pxref{Invocation}) says
  how each conflict was resolved.
  
+ @cindex default conflict resolution
+ @cindex conflict resolution, default
  Not all rules and not all tokens have precedence.  If either the rule or
  the look-ahead token has no precedence, then the default is to shift.
  
***************
*** 3922,3930 ****
--- 3936,3948 ----
  you do not need to make @code{YYMAXDEPTH} painfully small merely to save
  space for ordinary inputs that do not need much stack.
  
+ @cindex default stack limit
+ @cindex stack limit, default
  The default value of @code{YYMAXDEPTH}, if you do not define it, is
  10000.
  
+ @cindex default stack size
+ @cindex stack size, default
  @vindex YYINITDEPTH
  You can control how much stack is allocated initially by defining the
  macro @code{YYINITDEPTH}.  This value too must be a compile-time
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads