Commit Graph

1465 Commits

Author SHA1 Message Date
Akim Demaille
6659366cda Simplify names.
* src/output.c (symbol_definitions_output): Rename symbol
	attributes type_name and has_type_name as type and has_type.
	* data/lalr1.cc: Adjust uses.
2008-11-13 06:24:01 +01:00
Akim Demaille
aea10ef46f Define the "identifier" of a symbol.
Symbols may have several string representations, for instance if they
have an alias.  What I call its "id" is a string that can be used as
an identifier.  May not exist.

Currently the symbols which have the "tag_is_id" flag set are those that
don't have an alias.  Look harder for the id.

	* src/output.c (is_identifier): Move to...
	* src/symtab.c (is_identifier): here.
	* src/symtab.h, src/symtab.c (symbol_id_get): New.
	* src/output.c (symbol_definitions_output): Use it to define "id"
	and "has_id".
	Remove the definition of "tag_is_id".
	* data/lalr1.cc: Use the "id" and "has_id" whereever "tag" and
	"tag_is_id" were used to produce code.
	We still use "tag" for documentation.
2008-11-13 06:17:09 +01:00
Akim Demaille
086fd1137d Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-11 16:41:28 +01:00
Akim Demaille
8be046d7b8 Inform m4 whether a tag is a valid id.
* src/output.c (is_identifier): New.
	(symbol_definitions_output): Use it to define tag_is_id.
	But maybe this should be done at m4 level?
2008-11-11 15:12:28 +01:00
Paolo Bonzini
905f069774 Replace m4/warning.m4 with warnings module.
* bootstrap.conf: Replace m4/warning.m4 with warnings module.
* configure.ac: Adjust usage.
* lib/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
* src/Makefile.am: Replace $(WARNING_CFLAGS) with $(WARN_CFLAGS).
* tests/atlocal.in: Replace $(WARNING_*FLAGS) with $(WARN_*FLAGS).
2008-11-11 13:37:36 +01:00
Akim Demaille
5d73144067 More information about the symbols.
* src/output.c (type_names_output): Document all the symbols,
	including those that don't have a type-name.
	(symbol_definitions_output): Define "is_token" and
	"has_type_name".
	* data/lalr1.cc (b4_type_action_): Skip symbols that have an empty
	type-name, now that they are defined too in b4_type_names.
2008-11-10 11:58:01 +01:00
Akim Demaille
21db118b64 Regen. 2008-11-10 11:54:38 +01:00
Akim Demaille
b3a28fd4e9 Comment changes. 2008-11-10 11:44:13 +01:00
Akim Demaille
4c3cc7da5d Classify symbols by type-name.
* src/uniqstr.h (UNIQSTR_CMP): New.
	* src/output.c (symbol_type_name_cmp, symbols_by_type_name)
	(type_names_output): New.
	(muscles_output): Use it.
	* data/lalr1.cc (b4_symbol_action_): Remove.
	(b4_symbol_case_, b4_type_action_): New.
	Adjust uses of b4_symbol_action_ to use b4_type_action_.
2008-11-10 11:25:36 +01:00
Akim Demaille
d69c9694a7 Change the handling of the symbols in the skeletons.
Before we were using tables which lines were the symbols and which
columns were things like number, tag, type-name etc.  It is was
difficult to extend: each time a column was added, all the numbers had
to be updated (you asked for colon $2, not for "tag").  Also, it was
hard to filter these tables when only a subset of the symbols (say the
tokens, or the nterms, or the tokens that have and external number
*and* a type-name) was of interest.

Now instead of monolithic tables, we define one macro per cell.  For
instance "b4_symbol(0, tag)" is a macro name which contents is
self-decriptive.  The macro "b4_symbol" provides easier access to
these cells.

	* src/output.c (type_names_output): Remove.
	(symbol_numbers_output, symbol_definitions_output): New.
	(muscles_output): Call them.
	(prepare_symbols): Define b4_symbols_number.
2008-11-10 11:21:50 +01:00
Akim Demaille
5263bea9f7 --trace=muscles
* src/getargs.h, src/getargs.c (trace_muscle): New.
	(trace_types, trace_args): Support it.
	* src/output.c (output_skeleton): Use it.
2008-11-10 11:18:09 +01:00
Akim Demaille
4175f6bba2 muscles_output.
* src/output.c (muscles_output): New, extracted from...
	(output_skeleton): here.
	Adjust.
2008-11-10 11:15:00 +01:00
Akim Demaille
1de69d6a33 Formatting changes. 2008-11-10 11:11:52 +01:00
Akim Demaille
f7398526b6 Regen. 2008-11-10 11:00:40 +01:00
Akim Demaille
d78f0ac9d8 Add %precedence support.
Unfortunately it is not possible to reuse the %prec directive.  This
is because to please POSIX, we do not require to end the rules with a
semicolon.  As a result,

foo: bar %prec baz

is ambiguous: either a rule which precedence is that of baz, or a rule,
and then a declaration of the precedence of the token baz.

	* doc/bison.texinfo: Document %precedence.
	(Precedence Only): New.
	* src/assoc.h, src/assoc.c (precedence_assoc): New.
	* src/conflicts.c (resolve_sr_conflict): Support it.
	* src/scan-gram.l, src/parse-gram.y (%precedence): New token.
	Parse it.
	* tests/calc.at: Use %precedence for NEG.
	* tests/conflicts.at (%precedence does not suffice)
	(%precedence suffices): New tests.
2008-11-10 10:48:15 +01:00
Akim Demaille
432ac57aaa Require the generation of parse-gram.output.
* src/Makefile.am (YACC): Pass --report=all.
2008-11-09 20:10:00 +01:00
Akim Demaille
deef2a0a4d Formatting changes. 2008-11-09 20:06:27 +01:00
Di-an Jan
2935744b3a Remove unused variable.
* src/output.c (type_names_output): Remove unused variable sep.
2008-11-09 12:28:59 +01:00
Joel E. Denny
d9a9b96bb5 Don't add a semicolon to actions for %skeleton or %language.
It breaks Java test cases as reported by Akim Demaille.
* src/scan-code.l: Implement.
2008-11-07 17:21:23 -05:00
Joel E. Denny
5136519230 Clean up %skeleton and %language priority implementation.
* src/getargs.c (skeleton_prio): Use default_prio rather than 2, and
remove static qualifier because others will soon need to see it.
(language_prio): Likewise.
(getargs): Use command_line_prio rather than 0.
* src/getargs.h (command_line_prio, grammar_prio, default_prio): New
enum fields.
(skeleton_prio): Extern it.
(language_prio): Extern it.
* src/parse-gram.y: Use grammar_prio rather than 1.
2008-11-07 17:20:44 -05:00
Akim Demaille
5a893c2b26 Pass command line location to skeleton_arg and language_argmatch.
* src/getargs.h, src/getargs.c (skeleton_arg, language_argmatch):
	The location argument is now mandatory.
	Adjust all dependencies.
	(getargs): Use command_line_location.
2008-11-07 21:38:36 +01:00
Akim Demaille
58697c6d89 -D, --define.
* src/getargs.c (usage): Document -D.
	Fix help string for --locations.
	(command_line_location): New.
	(short_options, long_options, getargs): Support -D, --define.
	(getargs): Move -d support at the right place.
	* doc/bison.texinfo (Bison Options): Update.
	* tests/input.at (%define, --define): New.
2008-11-07 21:38:31 +01:00
Akim Demaille
9fe5a4571e Initialize the muscle table before parsing the command line.
* src/getargs.c (quotearg.h, muscle_tab.h): Include.
	(getargs): Define file_name.
	* src/main.c (main): Initialize muscle_tab before calling
	getargs.
	* src/muscle_tab.c (muscle_init): No longer define file_name, as
	its value is not available yet.
2008-11-07 21:38:27 +01:00
Akim Demaille
56c5eca973 Locations without columns for command line arguments.
* src/location.c (location_print): Don't display negative columns.
	* src/location.h: Document this.
2008-11-07 21:38:23 +01:00
Akim Demaille
9b9e0a7d46 Fix --help.
* src/getargs.c (usage): Fix help string for -W.
2008-11-07 21:38:19 +01:00
Akim Demaille
ccde1f98b0 Regen.
* src/parse-gram.h, src/parse-gram.c: Regen.
2008-11-07 21:28:37 +01:00
Joel E. Denny
58bd33b7fc Fix user actions without a trailing semicolon.
Reported by Sergei Steshenko at
<http://lists.gnu.org/archive/html/bug-bison/2008-11/msg00001.html>.
* THANKS (Sergei Steshenko): Add.
* src/scan-code.l (SC_RULE_ACTION): Fix it.
* tests/regression.at (Fix user actions without a trailing semicolon):
New test case.
2008-11-04 15:58:57 -05:00
Akim Demaille
3c26260608 Formatting changes.
* data/lalr1-fusion.cc, src/parse-gram.y: here.
2008-11-04 21:43:51 +01:00
Akim Demaille
5ab8c47bcf Use variants to support objects as semantic values.
This patch was inspired by work by Michiel De Wilde.  But he used Boost
variants which (i) requires Boost on the user side, (ii) is slow, and
(iii) has useless overhead (the parser knows the type of the semantic value
there is no reason to duplicate this information as Boost.Variants do).

This implementation reserves a buffer large enough to store the largest
objects.  yy::variant implements this buffer.  It was implemented with
Quentin Hocquet.

	* src/output.c (type_names_output): New.
	(output_skeleton): Invoke it.
	* data/c++.m4 (b4_variant_if): New.
	(b4_symbol_value): If needed, provide a definition for variants.
	* data/lalr1.cc (b4_symbol_value, b4_symbol_action_)
	(b4_symbol_variant, _b4_char_sizeof_counter, _b4_char_sizeof_dummy)
	(b4_char_sizeof, yy::variant): New.
	(parser::parse): If variants are requested, define
	parser::union_type, parser::variant, change the definition of
	semantic_type, construct $$ before running the user action instead
	of performing a default $$ = $1.
	* examples/variant.yy: New.
	Based on an example by Michiel De Wilde.
2008-11-03 21:50:48 +01:00
Joel E. Denny
ed4d67dcbe Say %language is experimental.
We're thinking of extending it's effect on output file naming.  See the
thread at
<http://lists.gnu.org/archive/html/bison-patches/2008-10/msg00003.html>.
* NEWS: Say it's experimental.
* doc/bison.texinfo (Decl Summary): Say it's experimental, and so don't
recommend it over %skeleton for now.
(Bison Options): Likewise.
(C++ Bison Interface): Use %skeleton not %language.
(Calc++ Parser): Use %skeleton not %language.
* src/getargs.c (usage): Say it's experimental.
2008-11-02 16:54:45 -05:00
Joel E. Denny
cae5057f47 Always put auxiliary code files in the same dir as other output files.
* src/files.c (compute_file_name_parts): When the user specifies
--output but not --file-prefix, extract the directory prefix from the
file prefix not from the grammar file name.  This affects the location
of files like location.hh generated by the C++ skeleton.  The includes
in the other output files require this fix.
* tests/output.at (AT_CHECK_OUTPUT): Automatically create directories
for expected output files.
(Output files): Add a test for the above.
2008-10-30 15:43:11 -04:00
Joel E. Denny
e26d4e4314 Update copyright year.
* src/files.c: Here.
2008-10-28 22:08:52 -04:00
Di-an Jan
c0ee9e2115 Don't overwrite the input file.
* src/files.c (output_file_name_check): Fatal error if using input file
for output.
* tests/output.at: (AT_CHECK_CONFLICTING_OUTPUT): Add return status
argument.
(Conflicting output files): Add test.
2008-10-28 21:45:43 -04:00
Joel E. Denny
8851116612 Update for recent change to gnulib.
* src/parse-gram.y: Don't include strverscmp.h.  It comes from
string.h now.
2008-08-26 03:33:55 -04:00
Eric Blake
d67c52e852 Remaining m4sugar merge from autoconf.
* data/m4sugar/m4sugar.m4: Copy entire file from autoconf.
* data/m4sugar/foreach.m4: New file, copied from autoconf.
* data/Makefile.am (dist_m4sugar_DATA): Distribute it.
* src/output.c (output_skeleton): Tell m4 how to find it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-08-15 11:46:20 -06:00
Joel E. Denny
5523ac79a0 Update copyright dates for recent changes.
* Makefile.am: Here.
* src/Makefile.am: Here.
* src/reduce.c: Here.
* tests/reduce.at: Here.
2008-07-20 18:33:17 -04:00
Joel E. Denny
8fa369111f Use git-version-gen for version names between releases.
* .cvsignore (.tarball-version, GNUmakefile, *~): Add.
* .gitignore (/.tarball-version, /GNUmakefile, /*~): Add.
* .prev-version: New.
* .version.in: Remove.
* ChangeLog: Remove the $Id$ previously used for capturing the CVS
revision.
* GNUmakefile: Remove, now copied from Gnulib.
* Makefile.am: Add code suggested by comments in
build-aux/git-version-gen.
(EXTRA_DIST): Remove GNUmakefile, handled by Gnulib.  Add maint.mk,
.prev-version, and .version.
* NEWS (2.3b+): Rename to...
(?.?): ... this because we're dropping the "+" version naming scheme,
but, in general, we still can't be sure of our next release name.
* bootstrap: Add a quick hack to remove from .gitignore the
GNUmakefile entry that gnulib adds.  We already have a /GNUmakefile
entry.  This should really be fixed in gnulib instead.
* bootstrap.conf (gnulib_modules): Add gnumakefile.
* configure.ac (AC_INIT): Set version name by invoking
build-aux/git-version-gen.
(AC_CONFIG_FILES): Remove .version, now generated by
build-aux/git-version-gen.
* maint.mk: New, copied from coreutils.
* doc/.cvsignore (bison.1): Add.
* doc/.gitignore (/bison.1): Add.
* doc/bison.1: Remove, generated.
* src/.cvsignore (revision.c): Remove.
* src/.gitignore (/revision.c): Remove.
* src/Makefile.am (bison_SOURCES): Remove revision.c and revision.h.
(BUILT_SOURCES): Remove revision.c.
(revision.c): Remove.
* src/getargs.c (version): Don't print revision after the VERSION.
* src/revision.h: Remove.
2008-07-18 12:55:39 -04:00
Joel E. Denny
bcf07cb707 Fix untranslatable composition of sentences.
Reported by Goran Uddeborg at
<http://lists.gnu.org/archive/html/bug-bison/2008-06/msg00000.html>.
* THANKS (Goran Uddeborg): Add.
* src/reduce.c (reduce_print): Report the number of nonterminals and
rules useless in the grammar in separate sentences.
* tests/reduce.at (Useless Rules): Update output.
(Reduced Automaton): Likewise.
(Underivable Rules): Likewise.
(Empty Language): Likewise.
2008-07-16 02:56:36 -04:00
Joel E. Denny
9aacab9ae9 Fix some .gitignore and .cvsignore problems.
* bootstrap (insert_sorted_if_absent): Replace all uses with...
(insert_vc_ignore): ... this new function, which prepends `/' to all
.gitignore entries before passing them to insert_sorted_if_absent.
* bootstrap.conf (vc_ignore): Set to '.cvsignore .gitignore' so that
.cvsignore files are maintained even though Bison developers run
bootstrap while using Git.
* .cvsignore (*.patch *.log log patches applied): Remove, apparently
unneeded by Bison.
(gnulib): Add.
* .gitignore (/*.patch *.log log patches applied): Remove, broken and
unneeded.  Reported by Eric Blake.
* lib/.gitignore (/*~): Add.
* po/.cvsignore, runtime-po/.cvsignore: Sync with .gitignore.
* examples/calc++/.gitignore (/calc++.exe): Add.  Reported by Eric
Blake.
* src/.gitignore (/bison.exe): Add.  Reported by Eric Blake.
2008-07-16 02:05:14 -04:00
Joel E. Denny
a9fc7990fa Improve forward-compatibility with GNU M4.
Reported by Eric Blake at
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>.
* bootstrap.conf (gnulib_modules): Add unsetenv.
* lib/.gitignore, lib/.cvsignore (/unsetenv.c): Add.
* m4/.gitignore, m4/.cvsignore (/environ.m4): Add.
(/setenv.m4): Add.
* src/output.c (output_skeleton): For the m4 invocation, pass -dV as
the first argument because it may become position-dependent, and unset
POSIXLY_CORRECT so Bison's skeletons have access to GNU M4 extensions.
Add comments explaining these issues in more detail.
2008-07-15 21:00:36 -04:00
Joel E. Denny
0f1d6f10d7 Add .gitignore everywhere based on .cvsignore.
* .gitignore: New.
* build-aux/.gitignore: New.
* data/.gitignore: New.
* doc/.gitignore: New.
* etc/.gitignore: New.
* examples/.gitignore: New.
* examples/calc++/.gitignore: New.
* lib/.gitignore: New.
* m4/.gitignore: New.
* po/.gitignore: New.
* runtime-po/.gitignore: New.
* src/.gitignore: New.
* tests/.gitignore: New.
2008-07-14 06:06:26 -04:00
Joel E. Denny
72c5b9828e * NEWS (2.3b): Update release date since there has been a delay in
getting the announcements and tarballs out.
2008-05-28 00:28:50 +00:00
Joel E. Denny
fa6aa7b3dd * data/yacc.c: Reformat m4 a little for readability.
* src/lalr.c (build_relations): Correct comment.
2008-05-13 05:35:33 +00:00
Joel E. Denny
1cfe6375ce Update to the current gnulib CVS repository, and fix trigraph handling
in Bison.
* bootstrap: Update gnulib CVS repository URL.
(symlink_to_dir): Encapsulate the code that guarantees the destination
directory exists into...
(check_dst_dir): ... this new function, and...
(cp_mark_as_generated): ... reuse it here so that bootstrap doesn't
fail when copying files into lib/uniwidth/.
* src/output.c (prepare_symbols): When writing yytname muscles, where
symbol names will be encoded in C-string literals, tell quotearg to
escape trigraphs.  This used to be the default in gnulib.
* tests/regression.at (Token definitions): Because of the change in
gnulib's quotearg behavior, string_as_id in parse-gram.y no longer
escapes trigraphs in symbol names.  Thus, yytname no longer has
trigraphs unnecessarily doubly escaped.  Update test case output.
Extend test case to be sure Bison's own error messages will no longer
have trigraphs in symbol names unnecessarily escaped once.
2008-04-21 06:54:39 +00:00
Joel E. Denny
8e55b3aac2 * NEWS (2.3a+): Mention that -g now takes an argument.
* doc/bison.texinfo (Bison Options): Reword -W entry a little for
consistency.  Update the -g and -x entries now that they take
arguments.  Use brackets to indicate optional arguments.
* src/getargs.c (usage): Explain the relationship between arguments of
long and short options more completely.  Document --defines and -d
separately since the former takes an argument but, for POSIX Yacc, the
latter does not.
(short_options): Let -W take an optional argument like --warnings.
(getargs): Sort cases.
2008-03-08 20:49:57 +00:00
Akim Demaille
7020f1e9e2 * src/getargs.c (short_options): Split and sort for readability.
-g and -x take optional arguments, just like their long options.
* build-aux/cross-options.pl: Use /x to make the regexp easier to
understand.
Fix the handling of $opt which resulted in all the argument to be
considered as optional.
2008-02-28 16:01:16 +00:00
Joel E. Denny
59da312bc7 * NEWS (2.3a+): Don't say %language is experimental. Mention Java and
say its interface is experimental.
* doc/bison.texinfo (Decl Summary): In the %language entry, mention
Java.
(Bison Options): In the -L and --language entry, mention Java.
(Java Bison Interface): Say the interface is experimental.
* src/getargs.c (usage): Mention -L and --language.

* NEWS (2.3a+): Say the push parsing interface is experimental.
* doc/bison.texinfo (Push Decl): Likewise.
(Decl Summary): Likewise in the "%define api.push_pull" entry.
(Push Parser Function): Likewise.
(Pull Parser Function): Likewise.
(Parser Create Function): Likewise.
(Parser Delete Function): Likewise.
(Table of Symbols): Likewise in the yypstate_delete, yypstate_new,
yypull_parse, and yypush_parse entries.

* NEWS (2.3a+): Mention XML support, and say the schema is
experimental.
* doc/bison.texinfo (Bison Options): Mention -x and --xml.
* src/getargs.c (usage): Say the XML schema is experimental.

* NEWS (2.3a+): Say option instead of flag.
2008-02-23 04:26:14 +00:00
Joel E. Denny
e021811add * src/parse-gram.c, src/parse-gram.h: Regenerate. 2008-02-20 00:03:43 +00:00
Joel E. Denny
ab7f29f8f9 Accept a token number in a %left, %right, or %nonassoc for POSIX
conformance.  Reported by Tim Josling at
<http://lists.gnu.org/archive/html/bug-bison/2008-01/msg00010.html>.
* NEWS (2.3a+): Mention.
* doc/bison.texinfo (Precedence Decl): Describe how literal strings
and code numbers are treated by precedence declarations.
* src/parse-gram.y (precedence_declaration): Use symbols.prec instead
of symbols.1.
(symbols.prec): New, just like symbols.1 but uses symbol.prec instead
of symbol.
(symbol.prec): New, just like symbol but allows INT.
* src/symtab.c (symbol_user_token_number_set): Remove an aver that no
longer holds.
* tests/regression.at (Token number in precedence declaration): New
test case.
2008-02-17 00:18:36 +00:00
Joel E. Denny
408476bca9 In XML output, remove redundant class attribute on symbol element.
* data/xslt/bison.xsl (xsl:key name="bison:symbolByName"): New.
* data/xslt/xml2xhtml.xsl (xsl:template match="symbol"): Use it to
look up a symbol to determine whether it's a nonterminal or terminal.
* src/gram.c (rule_rhs_print_xml): Remove class attribute.
* src/state.c (state_rule_lookahead_tokens_print_xml): Likewise.

Add prec/assoc information to XML output.
* src/gram.c (grammar_rules_print_xml): For each rule that has a
%prec, add a percent_prec attribute.
* src/print-xml.c (print_grammar): For each terminal that has a
precedence or associativity, add a prec or assoc attribute.
(xml_indent): New.
(xml_puts): Use xml_indent.
(xml_printf): Use xml_indent.
* src/print-xml.h (xml_indent): Prototype.

* tests/existing.at (GNU pic Grammar): Fix a rule miscopied from
<http://lists.gnu.org/archive/html/bug-bison/2003-04/msg00026.html>.
2007-12-15 02:08:02 +00:00