bison-patches
[Top][All Lists]
Advanced

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

style: minor changes


From: Akim Demaille
Subject: style: minor changes
Date: Sun, 24 Feb 2019 19:10:22 +0100

commit 5230e610fc4b5e0599c1bf1edda24faa227213f5
Author: Akim Demaille <address@hidden>
Date:   Sun Feb 24 13:54:02 2019 +0100

    style: minor changes
    
    * examples/c/calc/calc.y, src/lalr.c: Reduce scope.
    * src/gram.c: Prefer < to >.

diff --git a/examples/c/calc/calc.y b/examples/c/calc/calc.y
index f9e19624..f3771f2e 100644
--- a/examples/c/calc/calc.y
+++ b/examples/c/calc/calc.y
@@ -84,9 +84,8 @@ yyerror (char const *s)
 int
 main (int argc, char const* argv[])
 {
-  int i;
   /* Enable parse traces on option -p.  */
-  for (i = 1; i < argc; ++i)
+  for (int i = 1; i < argc; ++i)
     if (!strcmp(argv[i], "-p"))
       yydebug = 1;
   return yyparse ();
diff --git a/src/gram.c b/src/gram.c
index 82e3500b..b580dac4 100644
--- a/src/gram.c
+++ b/src/gram.c
@@ -52,9 +52,8 @@ rule const *
 item_rule (item_number const *item)
 {
   item_number const *sp = item;
-  while (*sp >= 0)
+  while (0 <= *sp)
     ++sp;
-
   rule_number r = item_number_as_rule_number (*sp);
   return &rules[r];
 }
diff --git a/src/lalr.c b/src/lalr.c
index babbc90e..40f1502d 100644
--- a/src/lalr.c
+++ b/src/lalr.c
@@ -40,6 +40,7 @@
 #include "relation.h"
 #include "symtab.h"
 
+/* goto_map[nterm - NTOKENS] -> number of gotos.  */
 goto_number *goto_map = NULL;
 goto_number ngotos = 0;
 state_number *from_state = NULL;
@@ -70,8 +71,7 @@ static goto_list **lookback;
 void
 set_goto_map (void)
 {
-  goto_number *temp_map = xnmalloc (nvars + 1, sizeof *temp_map);
-
+  /* Count the number of gotos (ngotos) per nterm (goto_map). */
   goto_map = xcalloc (nvars + 1, sizeof *goto_map);
   ngotos = 0;
   for (state_number s = 0; s < nstates; ++s)
@@ -80,14 +80,13 @@ set_goto_map (void)
       for (int i = sp->num - 1; 0 <= i && TRANSITION_IS_GOTO (sp, i); --i)
         {
           ngotos++;
-
           /* Abort if (ngotos + 1) would overflow.  */
           aver (ngotos != GOTO_NUMBER_MAXIMUM);
-
           goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
         }
     }
 
+  goto_number *temp_map = xnmalloc (nvars + 1, sizeof *temp_map);
   {
     goto_number k = 0;
     for (symbol_number i = ntokens; i < nsyms; ++i)




reply via email to

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