[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Implement %define lr.default_rules.

From: Akim Demaille
Subject: Re: [PATCH] Implement %define lr.default_rules.
Date: Tue, 21 Apr 2009 14:14:57 +0200

Le 20 avr. 09 à 07:48, Joel E. Denny a écrit :

Hi Joel,

I haven't pushed yet because I would really like to rename "default rule"
to "default reduction" throughout Bison first:

1. A rule is a production in a grammar, so a default rule sounds to me
like it is a single property of the grammar.  When I read "perform a
reduction by the default rule when there's no other action on the
lookahead", I want to check the grammar to see what it specifies as the
default rule.

I agree.

2. A reduction is a parser action that applies a rule.  Parser states
contain actions, so a default reduction sounds to me like it is a property
of a state, as we expect.  In other words, when I read "perform the
default reduction when there's no other action on the lookahead", I want to look for the reduction in the current parser state, where all the other
relevant actions are stored.

I agree too.

Does my argument make sense to anyone else?  Is this terminology too
standard to change now?  If you agree with the change, should it be
"default reduction" or "default reduce"?  Thanks.

I agree with the change, and I would use "default reduction".

+  /* We need a lookahead either to distinguish different reductions
+ (i.e., there are two or more), or to distinguish a reduction from a
+     shift.  Otherwise, it is straightforward, and the state is
+ `consistent'. However, for states that have any rules, treat only

I don't understand "states that have any rules".

+ the accepting state as consistent (since there is never a lookahead + token that makes sense there, and so no lookahead token should be
+     read) if the user has otherwise disabled default rules.  */
  if (rp->num > 1
-      || (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0)))
+      || (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0))
+      || (rp->num == 1 && rp->rules[0]->number != 0
+          && default_rule_only_for_accept))
    n_lookahead_tokens += rp->num;
    s->consistent = 1;

@@ -244,6 +245,7 @@ print_reductions (FILE *out, state *s)
  rule *default_rule = NULL;
  size_t width = 0;
  int i, j;
+  bool non_default_action = false;

I'm not fond of negated Boolean variables. Especially seems it seems used only negated itself :) But then, I can understand "false" as "not known yet" and "true" as "known".

+AT_BISON_CHECK([[input.y]], [[1]], [[]],
+[[input.y:1.9-24: invalid value for %define variable `lr.default_rules': `bogus'

It should be easy to report the set of valid values too. Sort of unexpected/expected :)

+#                          DECLS, GRAMMAR, INPUT,
+#                          BISON-STDERR, TABLES-OR-LAST-STATE,
+#                          [OTHER-CHECKS],
+#                          [PARSER-EXIT-VALUE],
+#                          [PARSER-STDOUT], [PARSER-STDERR])

Wow, this is a m4sterpiece of 4rt.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]