MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / pack_symbols

Function pack_symbols

extern/btyacc/reader.c:1698–1791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1696}
1697
1698void pack_symbols()
1699{
1700 register bucket *bp;
1701 register bucket **v;
1702 register int i, j, k, n;
1703
1704 nsyms = 2;
1705 ntokens = 1;
1706 for (bp = first_symbol; bp; bp = bp->next) {
1707 ++nsyms;
1708 if (bp->class == TERM) ++ntokens; }
1709 start_symbol = ntokens;
1710 nvars = nsyms - ntokens;
1711
1712 symbol_name = NEW2(nsyms, char *);
1713 if (symbol_name == 0) no_space();
1714 symbol_value = NEW2(nsyms, Yshort);
1715 if (symbol_value == 0) no_space();
1716 symbol_prec = NEW2(nsyms, Yshort);
1717 if (symbol_prec == 0) no_space();
1718 symbol_assoc = MALLOC(nsyms);
1719 if (symbol_assoc == 0) no_space();
1720
1721 v = NEW2(nsyms, bucket *);
1722 if (v == 0) no_space();
1723
1724 v[0] = 0;
1725 v[start_symbol] = 0;
1726
1727 i = 1;
1728 j = start_symbol + 1;
1729 for (bp = first_symbol; bp; bp = bp->next)
1730 {
1731 if (bp->class == TERM)
1732 v[i++] = bp;
1733 else
1734 v[j++] = bp;
1735 }
1736 assert(i == ntokens && j == nsyms);
1737
1738 for (i = 1; i < ntokens; ++i)
1739 v[i]->index = i;
1740
1741 goal->index = start_symbol + 1;
1742 k = start_symbol + 2;
1743 while (++i < nsyms)
1744 if (v[i] != goal) {
1745 v[i]->index = k;
1746 ++k; }
1747 goal->value = 0;
1748 k = 1;
1749 for (i = start_symbol + 1; i < nsyms; ++i) {
1750 if (v[i] != goal) {
1751 v[i]->value = k;
1752 ++k; } }
1753 k = 0;
1754 for (i = 1; i < ntokens; ++i) {
1755 n = v[i]->value;

Callers 1

readerFunction · 0.85

Calls 2

no_spaceFunction · 0.85
assertClass · 0.85

Tested by

no test coverage detected