Implement %define lr.default_rules.

Its value describes the states that are permitted to contain
default rules: "all", "consistent", or "accepting".
* src/reader.c (reader): Default lr.default_rules to "all".
Check for a valid lr.default_rules value.
* src/lalr.c (state_lookahead_tokens_count): If lr.default_rules
is "accepting", then only mark the accepting state as
consistent.
(initialize_LA): Tell state_lookahead_tokens_count whether
lr.default_rules is "accepting".
* src/tables.c (action_row): If lr.default_rules is not "all",
then disable default rules in inconsistent states.
* src/print.c (print_reductions): Use this opportunity to
perform some assertions about whether lr.default_rules was
obeyed correctly.
* tests/local.at (AT_TEST_TABLES_AND_PARSE): New macro that
helps with checking the parser tables for a grammar.
* tests/input.at (%define lr.default_rules invalid values): New
test group.
* tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): New macro using
AT_TEST_TABLES_AND_PARSE.
(`no %define lr.default_rules'): New test group generated by
AT_TEST_LR_DEFAULT_RULES.
(`%define lr.default_rules "all"'): Likewise.
(`%define lr.default_rules "consistent"'): Likewise.
(`%define lr.default_rules "accepting"'): Likewise.
This commit is contained in:
Joel E. Denny
2009-04-20 00:55:50 -04:00
parent 44c124a389
commit 03c07b0394
8 changed files with 429 additions and 24 deletions

View File

@@ -1,7 +1,7 @@
/* Input parser for Bison
Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003,
2005, 2006, 2007 Free Software Foundation, Inc.
2005, 2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -555,6 +555,17 @@ reader (void)
gram_scanner_initialize ();
gram_parse ();
muscle_percent_define_default ("lr.default_rules", "all");
/* Check front-end %define variable values. */
{
static char const * const values[] = {
"lr.default_rules", "all", "consistent", "accepting", NULL,
NULL
};
muscle_percent_define_check_values (values);
}
if (! complaint_issued)
check_and_convert_grammar ();