Akim Demaille 1d5956f87f symbols: clean up their parsing
Prompted by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html

We have four classes of directives that declare symbols: %nterm,
%type, %token, and the family of %left etc.  Currently not all of them
support the possibility to have several type tags (`<type>`), and not
all of them support the fact of not having any type tag at all
(%type).  Let's unify this.

- %type
  POSIX Yacc specifies that %type is for nonterminals only.  However,
  some Bison users want to use it for both tokens and nterms
  (actually, Bison's own grammar does this in several places, e.g.,
  CHAR).  So it should accept char/string literals.

  As a consequence cannot be used to declare tokens with their alias:
  `%type foo "foo"` would be ambiguous (are we defining foo = "foo",
  or are these two different symbols?)

  POSIX specifies that it is OK to use %type without a type tag.  I'm
  not sure what it means, but we support it.

- %token
  Accept token declarations with number and string literal:
  (ID|CHAR) NUM? STRING?.

- %left, etc.
  They cannot be the same as %token, because we accept to declare the
  symbol with %token, and to then qualify its precedence with %left.
  Then `%left foo "foo"` would also be ambiguous: foo="foo", or two
  symbols.

  They cannot be simply a list of identifiers, but POSIX Yacc says we
  can declare token numbers here.  I personally think this is a bad
  idea, precedence management is tricky in itself and should not be
  cluttered with token declaration issues.

  We used to accept declaring a token number on a string literal here
  (e.g., `%left "token" 1`).  This is abnormal.  Either the feature is
  useful, and then it should be supported in %token, or it's useless
  and we should not support it in corner cases.

- %nterm
  Obviously cannot accept tokens, nor char/string literals.  Does not
  exist in POSIX Yacc, but since %type also works for terminals, it is
  a nice option to have.

* src/parse-gram.y: Avoid relying on side effects.  For instance, get
rid of current_type, rather, build the list of symbols and iterate
over it to assign the type.
It's not always possible/convenient.  For instance, we still use
current_class.
Prefer "decl" to "def", since in the rest of the implementation we
actually "declare" symbols, we don't "define" them.
(token_decls, token_decls_for_prec, symbol_decls, nterm_decls): New.
Use them for %token, %left, %type and %nterm.
* src/symlist.h, src/symlist.c (symbol_list_type_set): New.
* tests/regression.at b/tests/regression.at
(Token number in precedence declaration): We no longer accept
to give a number to string literals.
2018-12-16 12:27:28 +01:00
2018-12-11 06:55:41 +01:00
2018-12-11 06:55:41 +01:00
2018-10-05 07:01:04 +02:00
2018-12-08 07:50:43 +01:00
2018-11-29 06:16:20 +01:00
2018-11-21 22:03:50 +01:00
2018-11-26 06:33:45 +01:00
2018-12-16 12:27:28 +01:00
2018-05-19 15:17:28 +02:00
2018-12-16 12:27:28 +01:00
2018-11-21 22:05:45 +01:00
2018-12-11 07:06:12 +01:00
2006-01-22 07:59:51 +00:00
2006-01-22 07:59:51 +00:00
2018-05-12 18:18:41 +02:00
2018-10-14 15:15:29 +02:00
2018-11-10 17:02:50 +01:00
2018-10-05 07:01:06 +02:00
2018-12-04 20:43:01 +01:00
2007-08-15 20:21:33 +00:00
2018-12-01 11:13:08 +01:00
2018-12-14 05:10:18 +01:00
2018-05-12 18:18:41 +02:00
2018-10-26 08:40:07 +02:00
2018-05-12 18:18:41 +02:00
2018-11-16 17:37:47 +01:00
2013-02-18 10:01:28 +01:00
2018-12-04 20:29:28 +01:00
2018-12-11 06:55:41 +01:00

This package contains the GNU Bison parser generator.

* Installation
** Build
See the file INSTALL for generic compilation and installation
instructions.

Bison requires GNU m4 1.4.6 or later.  See:

      https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz

** Internationalization
Bison supports two catalogs: one for Bison itself (i.e., for the
maintainer-side parser generation), and one for the generated parsers
(i.e., for the user-side parser execution).  The requirements between
both differ: bison needs ngettext, the generated parsers do not.  To
simplify the build system, neither are installed if ngettext is not
supported, even if generated parsers could have been localized.  See
http://lists.gnu.org/archive/html/bug-bison/2009-08/msg00006.html for
more details.

* Questions
See the section FAQ in the documentation (doc/bison.info) for
frequently asked questions.  The documentation is also available in
PDF and HTML, provided you have a recent version of Texinfo installed:
run "make pdf" or "make html".

If you have questions about using Bison and the documentation does
not answer them, please send mail to <help-bison@gnu.org>.

* Bug reports
Please send bug reports to <bug-bison@gnu.org>.  Be sure to include the
version number from 'bison --version', and a complete, self-contained test
case in each bug report.

* Copyright statements
For any copyright year range specified as YYYY-ZZZZ in this package,
note that the range specifies every single year in that closed interval.

-----

Local Variables:
mode: outline
fill-column: 76
ispell-dictionary: "american"
End:

Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018 Free Software
Foundation, Inc.

This file is part of GNU bison, the GNU Compiler Compiler.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

# LocalWords:  parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american
# LocalWords:  MERCHANTABILITY
Description
No description provided
Readme 18 MiB
Languages
C 61%
M4 11.7%
C++ 11.3%
Shell 4.1%
XSLT 3.1%
Other 8.8%