diff options
author | Joel E. Denny <joeldenny@joeldenny.org> | 2011-05-29 20:06:22 -0400 |
---|---|---|
committer | Joel E. Denny <joeldenny@joeldenny.org> | 2011-06-11 12:18:07 -0400 |
commit | a40e77ebf62c136a38594ce30cf39ae2f5f08471 (patch) | |
tree | 5cb6f624e3ed18d23452a141de10e2c93ef29d1f | |
parent | 378e917c55295fb209173857c936288a72e6cf0a (diff) | |
download | bison-a40e77ebf62c136a38594ce30cf39ae2f5f08471.tar.gz |
doc: motivate named references.
Suggested by Hans Aberg at
<http://lists.gnu.org/archive/html/bug-bison/2011-05/msg00008.html>.
* doc/bison.texinfo (Named References): Explain briefly how
they're better than the traditional positional references.
(cherry picked from commit 7d31f0928907ccdd647479075d385b5a36c62611)
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | doc/bison.texinfo | 17 |
2 files changed, 19 insertions, 6 deletions
@@ -1,5 +1,13 @@ 2011-05-29 Joel E. Denny <joeldenny@joeldenny.org> + doc: motivate named references. + Suggested by Hans Aberg at + <http://lists.gnu.org/archive/html/bug-bison/2011-05/msg00008.html>. + * doc/bison.texinfo (Named References): Explain briefly how + they're better than the traditional positional references. + +2011-05-29 Joel E. Denny <joeldenny@joeldenny.org> + doc: discuss named references after locations. Reported by Hans Aberg at <http://lists.gnu.org/archive/html/bug-bison/2011-05/msg00008.html>. diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 456eb7b6..6471b3b6 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -4092,10 +4092,16 @@ statement when it is followed by a semicolon. @section Using Named References @cindex named references -While every semantic value can be accessed with positional references -@code{$@var{n}} and @code{$$}, it's often much more convenient to refer to -them by name. First of all, original symbol names may be used as named -references. For example: +As described in the preceding sections, the traditional way to refer to any +semantic value or location is a @dfn{positional reference}, which takes the +form @code{$@var{n}}, @code{$$}, @code{@@@var{n}}, and @code{@@$}. However, +such a reference is not very descriptive. Moreover, if you later decide to +insert or remove symbols in the right-hand side of a grammar rule, the need +to renumber such references can be tedious and error-prone. + +To avoid these issues, you can also refer to a semantic value or location +using a @dfn{named reference}. First of all, original symbol names may be +used as named references. For example: @example @group @@ -4105,8 +4111,7 @@ invocation: op '(' args ')' @end example @noindent -The positional @code{$$}, @code{@@$}, @code{$n}, and @code{@@n} can be -mixed with @code{$name} and @code{@@name} arbitrarily. For example: +Positional and named references can be mixed arbitrarily. For example: @example @group |