style: minor changes

* examples/c/calc/calc.y, src/lalr.c: Reduce scope.
* src/gram.c: Prefer < to >.
This commit is contained in:
Akim Demaille
2019-02-24 13:54:02 +01:00
parent b81419a9fd
commit 5230e610fc
3 changed files with 5 additions and 8 deletions

View File

@@ -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 ();

View File

@@ -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];
}

View File

@@ -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)