| 1791 | } |
| 1792 | |
| 1793 | void pack_grammar() |
| 1794 | { |
| 1795 | register int i, j; |
| 1796 | int assoc, prec; |
| 1797 | |
| 1798 | ritem = NEW2(nitems, Yshort); |
| 1799 | if (ritem == 0) no_space(); |
| 1800 | rlhs = NEW2(nrules, Yshort); |
| 1801 | if (rlhs == 0) no_space(); |
| 1802 | rrhs = NEW2(nrules+1, Yshort); |
| 1803 | if (rrhs == 0) no_space(); |
| 1804 | rprec = RENEW(rprec, nrules, Yshort); |
| 1805 | if (rprec == 0) no_space(); |
| 1806 | rassoc = RENEW(rassoc, nrules, char); |
| 1807 | if (rassoc == 0) no_space(); |
| 1808 | |
| 1809 | ritem[0] = -1; |
| 1810 | ritem[1] = goal->index; |
| 1811 | ritem[2] = 0; |
| 1812 | ritem[3] = -2; |
| 1813 | rlhs[0] = 0; |
| 1814 | rlhs[1] = 0; |
| 1815 | rlhs[2] = start_symbol; |
| 1816 | rrhs[0] = 0; |
| 1817 | rrhs[1] = 0; |
| 1818 | rrhs[2] = 1; |
| 1819 | |
| 1820 | j = 4; |
| 1821 | for (i = 3; i < nrules; ++i) { |
| 1822 | if (plhs[i]->args > 0) { |
| 1823 | if (plhs[i]->argnames) { |
| 1824 | FREE(plhs[i]->argnames); |
| 1825 | plhs[i]->argnames = 0; |
| 1826 | } |
| 1827 | if (plhs[i]->argtags) { |
| 1828 | FREE(plhs[i]->argtags); |
| 1829 | plhs[i]->argtags = 0; |
| 1830 | } |
| 1831 | } |
| 1832 | rlhs[i] = plhs[i]->index; |
| 1833 | rrhs[i] = j; |
| 1834 | assoc = TOKEN; |
| 1835 | prec = 0; |
| 1836 | while (pitem[j]) { |
| 1837 | ritem[j] = pitem[j]->index; |
| 1838 | if (pitem[j]->class == TERM) { |
| 1839 | prec = pitem[j]->prec; |
| 1840 | assoc = pitem[j]->assoc; } |
| 1841 | ++j; } |
| 1842 | ritem[j] = -i; |
| 1843 | ++j; |
| 1844 | if (rprec[i] == UNDEFINED) { |
| 1845 | rprec[i] = prec; |
| 1846 | rassoc[i] = assoc; } } |
| 1847 | rrhs[i] = j; |
| 1848 | FREE(plhs); |
| 1849 | FREE(pitem); |
| 1850 | clean_arg_cache(); |
no test coverage detected