if (trace_flag & trace_resource)
fprintf (stderr, "growing table and check from: %d to %d\n",
if (trace_flag & trace_resource)
fprintf (stderr, "growing table and check from: %d to %d\n",
table = xnrealloc (table, table_size, sizeof *table);
conflict_table = xnrealloc (conflict_table, table_size,
table = xnrealloc (table, table_size, sizeof *table);
conflict_table = xnrealloc (conflict_table, table_size,
check = xnrealloc (check, table_size, sizeof *check);
for (/* Nothing. */; old_size < table_size; ++old_size)
check = xnrealloc (check, table_size, sizeof *check);
for (/* Nothing. */; old_size < table_size; ++old_size)
/*-------------------------------------------------------------------.
| For GLR parsers, for each conflicted token in S, as indicated |
/*-------------------------------------------------------------------.
| For GLR parsers, for each conflicted token in S, as indicated |
-| by non-zero entries in CONFLROW, create a list of possible |
-| reductions that are alternatives to the shift or reduction |
+| by non-zero entries in CONFLROW, create a list of possible |
+| reductions that are alternatives to the shift or reduction |
- conflrow[j] = conflict_list_cnt;
-
- /* Find all reductions for token J, and record all that do not
- match ACTROW[J]. */
- for (i = 0; i < reds->num; i += 1)
- if (bitset_test (reds->lookahead_tokens[i], j)
- && (actrow[j]
- != rule_number_as_item_number (reds->rules[i]->number)))
- {
- aver (0 < conflict_list_free);
- conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
- conflict_list_cnt += 1;
- conflict_list_free -= 1;
- }
-
- /* Leave a 0 at the end. */
- aver (0 < conflict_list_free);
- conflict_list[conflict_list_cnt] = 0;
- conflict_list_cnt += 1;
- conflict_list_free -= 1;
+ conflrow[j] = conflict_list_cnt;
+
+ /* Find all reductions for token J, and record all that do not
+ match ACTROW[J]. */
+ for (i = 0; i < reds->num; i += 1)
+ if (bitset_test (reds->lookahead_tokens[i], j)
+ && (actrow[j]
+ != rule_number_as_item_number (reds->rules[i]->number)))
+ {
+ aver (0 < conflict_list_free);
+ conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
+ conflict_list_cnt += 1;
+ conflict_list_free -= 1;
+ }
+
+ /* Leave a 0 at the end. */
+ aver (0 < conflict_list_free);
+ conflict_list[conflict_list_cnt] = 0;
+ conflict_list_cnt += 1;
+ conflict_list_free -= 1;
| default action (yydefact) for the state. In addition, ACTROW is |
| filled with what to do for each kind of token, index by symbol |
| number, with zero meaning do the default action. The value |
| default action (yydefact) for the state. In addition, ACTROW is |
| filled with what to do for each kind of token, index by symbol |
| number, with zero meaning do the default action. The value |
-| ACTION_NUMBER_MINIMUM, a very negative number, means this |
-| situation is an error. The parser recognizes this value |
-| specially. |
+| ACTION_NUMBER_MINIMUM, a very negative number, means this |
+| situation is an error. The parser recognizes this value |
+| specially. |
| |
| This is where conflicts are resolved. The loop over lookahead |
| rules considered lower-numbered rules last, and the last rule |
| |
| This is where conflicts are resolved. The loop over lookahead |
| rules considered lower-numbered rules last, and the last rule |
- /* and find each token which the rule finds acceptable
- to come next */
- BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
- {
- /* and record this rule as the rule to use if that
- token follows. */
- if (actrow[j] != 0)
- {
- conflicted = true;
- conflrow[j] = 1;
- }
- actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
- }
+ /* and find each token which the rule finds acceptable
+ to come next */
+ BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
+ {
+ /* and record this rule as the rule to use if that
+ token follows. */
+ if (actrow[j] != 0)
+ {
+ conflicted = true;
+ conflrow[j] = 1;
+ }
+ actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
+ }
actrow[sym] = state_number_as_int (shift_state->number);
/* Do not use any default reduction if there is a shift for
actrow[sym] = state_number_as_int (shift_state->number);
/* Do not use any default reduction if there is a shift for
- {
- int max = 0;
- for (i = 0; i < reds->num; i++)
- {
- int count = 0;
- rule *r = reds->rules[i];
- symbol_number j;
-
- for (j = 0; j < ntokens; j++)
- if (actrow[j] == rule_number_as_item_number (r->number))
- count++;
-
- if (count > max)
- {
- max = count;
- default_reduction = r;
- }
- }
-
- /* GLR parsers need space for conflict lists, so we can't
- default conflicted entries. For non-conflicted entries
- or as long as we are not building a GLR parser,
- actions that match the default are replaced with zero,
- which means "use the default". */
-
- if (max > 0)
- {
- int j;
- for (j = 0; j < ntokens; j++)
- if (actrow[j]
+ {
+ int max = 0;
+ for (i = 0; i < reds->num; i++)
+ {
+ int count = 0;
+ rule *r = reds->rules[i];
+ symbol_number j;
+
+ for (j = 0; j < ntokens; j++)
+ if (actrow[j] == rule_number_as_item_number (r->number))
+ count++;
+
+ if (count > max)
+ {
+ max = count;
+ default_reduction = r;
+ }
+ }
+
+ /* GLR parsers need space for conflict lists, so we can't
+ default conflicted entries. For non-conflicted entries
+ or as long as we are not building a GLR parser,
+ actions that match the default are replaced with zero,
+ which means "use the default". */
+
+ if (max > 0)
+ {
+ int j;
+ for (j = 0; j < ntokens; j++)
+ if (actrow[j]
- {
- for (j = 0; j < ntokens; ++j)
- if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
- rules[item_number_as_rule_number (actrow[j])].useful = true;
- if (yydefact[i])
- rules[yydefact[i] - 1].useful = true;
- }
+ {
+ for (j = 0; j < ntokens; ++j)
+ if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
+ rules[item_number_as_rule_number (actrow[j])].useful = true;
+ if (yydefact[i])
+ rules[yydefact[i] - 1].useful = true;
+ }
- if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
- || (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
- match = 0;
+ if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
+ || (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
+ match = 0;
- {
- for (k = 0; k < t; k++)
- {
- loc = j + from[k];
- table[loc] = to[k];
- if (nondeterministic_parser && conflict_to != NULL)
- conflict_table[loc] = conflict_to[k];
- check[loc] = from[k];
- }
-
- while (table[lowzero] != 0)
- lowzero++;
-
- if (loc > high)
- high = loc;
-
- aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
- return j;
- }
+ {
+ for (k = 0; k < t; k++)
+ {
+ loc = j + from[k];
+ table[loc] = to[k];
+ if (nondeterministic_parser && conflict_to != NULL)
+ conflict_table[loc] = conflict_to[k];
+ check[loc] = from[k];
+ }
+
+ while (table[lowzero] != 0)
+ lowzero++;
+
+ if (loc > high)
+ high = loc;
+
+ aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
+ return j;
+ }
- /* A new set of state actions, or a nonterminal. */
- place = pack_vector (i);
+ /* A new set of state actions, or a nonterminal. */
+ place = pack_vector (i);
correlated. In particular the signedness is not taken into
account. But it's not useless. */
verify (sizeof nstates <= sizeof nvectors
correlated. In particular the signedness is not taken into
account. But it's not useless. */
verify (sizeof nstates <= sizeof nvectors