Changeset b39568e8202274e6aed953a924659cef1f971d55
- Timestamp:
- 04/23/08 11:17:03 (9 months ago)
- Parents:
- 3d5c1b18b9912541a77e63bdb908db34f068b328
- Children:
- 7799d1d6f07fd24cc0cf0b784340f994374fc5b1
- git-committer:
- David Balmain <dbalmain@gmail.com> / 2008-04-23T11:17:03Z+1000
- Location:
- c
- Files:
-
- 6 modified
-
include/hash.h (modified) (4 diffs)
-
include/intern.h (modified) (1 diff)
-
include/internal.h (modified) (2 diffs)
-
src/hash.c (modified) (1 diff)
-
src/q_parser.c (modified) (33 diffs)
-
test/test_hash.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
c/include/hash.h
r3d5c1b rb39568 110 110 111 111 /** 112 * Create a new Hash that uses any type of object as it 's key. The112 * Create a new Hash that uses any type of object as its key. The 113 113 * Hash will store all keys and values so if you want to destroy those 114 114 * values when the Hash is destroyed then you should pass free functions. … … 131 131 132 132 /** 133 * Create a new Hash that uses null-terminated strings as it 's keys. The133 * Create a new Hash that uses null-terminated strings as its keys. The 134 134 * Hash will store all keys and values so if you want to destroy those 135 135 * values when the Hash is destroyed then you should pass free functions. … … 148 148 149 149 /** 150 * Create a new Hash that uses integers as it's keys. The 151 * Hash will store all values so if you want to destroy those 152 * values when the Hash is destroyed then you should pass a free function. 153 * NULL will suffice otherwise. 150 * Create a new Hash that uses integers as its keys. The Hash will store all 151 * values so if you want to destroy those values when the Hash is destroyed 152 * then you should pass a free function. NULL will suffice otherwise. 154 153 * 155 154 * @param free_value function to free the value stored in the Hash when … … 159 158 */ 160 159 extern FrtHash *frt_h_new_int(frt_free_ft free_value); 160 161 /** 162 * Create a new Hash that uses pointers as its keys. The Hash will store all 163 * values so if you want to destroy those values when the Hash is destroyed 164 * then you should pass a free function. NULL will suffice otherwise. 165 * 166 * @param free_value function to free the value stored in the Hash when 167 * an entry is deleted, replaced or when the Hash is destroyed. If you 168 * pass NULL in place of this parameter the value will not be destroyed. 169 * @return A newly allocated Hash 170 */ 171 #define frt_h_new_ptr(free_value) frt_h_new_int(free_value) 161 172 162 173 /** -
c/include/intern.h
r553474 rb39568 6 6 extern const char *frt_intern_and_free(char *str); 7 7 8 #define FRT_I frt_intern 9 #define FRT_IF frt_intern_and_free 10 8 11 #endif -
c/include/internal.h
r3d5c1b rb39568 73 73 #define HAS_VARARGS FRT_HAS_VARARGS 74 74 #define HS_MIN_SIZE FRT_HS_MIN_SIZE 75 #define I FRT_I 76 #define IF FRT_IF 75 77 #define INDEX_ERROR FRT_INDEX_ERROR 76 78 #define INDEX_INTERVAL FRT_INDEX_INTERVAL … … 524 526 #define h_new frt_h_new 525 527 #define h_new_int frt_h_new_int 528 #define h_new_ptr frt_h_new_ptr 526 529 #define h_new_str frt_h_new_str 527 530 #define h_rem frt_h_rem -
c/src/hash.c
r3d5c1b rb39568 199 199 } 200 200 201 Hash *h_new_ptr(free_ft free_key, free_ft free_value)202 {203 Hash *self = h_new_str(free_key, free_value);204 205 self->lookup_i = &h_lookup_ptr;206 self->eq_i = NULL;207 self->hash_i = NULL;208 209 return self;210 }211 212 201 Hash *h_new(hash_ft hash, eq_ft eq, free_ft free_key, free_ft free_value) 213 202 { -
c/src/q_parser.c
r4ba05f rb39568 207 207 static void qp_pop_fields(QParser *self); 208 208 209 /** 210 * +FLDS+ calls +func+ for all fields on top of the field stack. +func+ 211 * must return a query. If there is more than one field on top of FieldStack 212 * then +FLDS+ will combing all the queries returned by +func+ into a single 213 * BooleanQuery which it than assigns to +q+. If there is only one field, the 214 * return value of +func+ is assigned to +q+ directly. 215 */ 209 216 #define FLDS(q, func) do {\ 210 217 TRY {\ … … 250 257 251 258 /* Line 216 of yacc.c. */ 252 #line 2 53"src/q_parser.c"259 #line 260 "src/q_parser.c" 253 260 254 261 #ifdef short … … 553 560 static const yytype_uint16 yyrline[] = 554 561 { 555 0, 2 18, 218, 219, 221, 222, 223, 224, 226, 227,556 2 28, 230, 231, 233, 234, 235, 236, 237, 238, 239,557 24 1, 242, 243, 245, 247, 247, 249, 249, 249, 252,558 2 53, 255, 256, 257, 258, 260, 261, 262, 263, 264,559 2 66, 267, 268, 269, 270, 271, 272, 273, 274, 275,560 2 76, 277562 0, 225, 225, 226, 228, 229, 230, 231, 233, 234, 563 235, 237, 238, 240, 241, 242, 243, 244, 245, 246, 564 248, 249, 250, 252, 254, 254, 256, 256, 256, 259, 565 260, 262, 263, 264, 265, 267, 268, 269, 270, 271, 566 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 567 283, 284 561 568 }; 562 569 #endif … … 1217 1224 { 1218 1225 case 27: /* "bool_q" */ 1219 #line 2 13"src/q_parser.y"1226 #line 220 "src/q_parser.y" 1220 1227 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1221 #line 122 2"src/q_parser.c"1228 #line 1229 "src/q_parser.c" 1222 1229 break; 1223 1230 case 28: /* "bool_clss" */ 1224 #line 2 15"src/q_parser.y"1231 #line 222 "src/q_parser.y" 1225 1232 { if ((yyvaluep->bclss) && qp->destruct) bca_destroy((yyvaluep->bclss)); }; 1226 #line 12 27"src/q_parser.c"1233 #line 1234 "src/q_parser.c" 1227 1234 break; 1228 1235 case 29: /* "bool_cls" */ 1229 #line 2 14"src/q_parser.y"1236 #line 221 "src/q_parser.y" 1230 1237 { if ((yyvaluep->bcls) && qp->destruct) bc_deref((yyvaluep->bcls)); }; 1231 #line 123 2"src/q_parser.c"1238 #line 1239 "src/q_parser.c" 1232 1239 break; 1233 1240 case 30: /* "boosted_q" */ 1234 #line 2 13"src/q_parser.y"1241 #line 220 "src/q_parser.y" 1235 1242 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1236 #line 12 37"src/q_parser.c"1243 #line 1244 "src/q_parser.c" 1237 1244 break; 1238 1245 case 31: /* "q" */ 1239 #line 2 13"src/q_parser.y"1246 #line 220 "src/q_parser.y" 1240 1247 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1241 #line 124 2"src/q_parser.c"1248 #line 1249 "src/q_parser.c" 1242 1249 break; 1243 1250 case 32: /* "term_q" */ 1244 #line 2 13"src/q_parser.y"1251 #line 220 "src/q_parser.y" 1245 1252 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1246 #line 12 47"src/q_parser.c"1253 #line 1254 "src/q_parser.c" 1247 1254 break; 1248 1255 case 33: /* "wild_q" */ 1249 #line 2 13"src/q_parser.y"1256 #line 220 "src/q_parser.y" 1250 1257 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1251 #line 125 2"src/q_parser.c"1258 #line 1259 "src/q_parser.c" 1252 1259 break; 1253 1260 case 34: /* "field_q" */ 1254 #line 2 13"src/q_parser.y"1261 #line 220 "src/q_parser.y" 1255 1262 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1256 #line 12 57"src/q_parser.c"1263 #line 1264 "src/q_parser.c" 1257 1264 break; 1258 1265 case 39: /* "phrase_q" */ 1259 #line 2 13"src/q_parser.y"1266 #line 220 "src/q_parser.y" 1260 1267 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1261 #line 126 2"src/q_parser.c"1268 #line 1269 "src/q_parser.c" 1262 1269 break; 1263 1270 case 40: /* "ph_words" */ 1264 #line 2 16"src/q_parser.y"1271 #line 223 "src/q_parser.y" 1265 1272 { if ((yyvaluep->phrase) && qp->destruct) ph_destroy((yyvaluep->phrase)); }; 1266 #line 12 67"src/q_parser.c"1273 #line 1274 "src/q_parser.c" 1267 1274 break; 1268 1275 case 41: /* "range_q" */ 1269 #line 2 13"src/q_parser.y"1276 #line 220 "src/q_parser.y" 1270 1277 { if ((yyvaluep->query) && qp->destruct) q_deref((yyvaluep->query)); }; 1271 #line 127 2"src/q_parser.c"1278 #line 1279 "src/q_parser.c" 1272 1279 break; 1273 1280 … … 1578 1585 { 1579 1586 case 2: 1580 #line 2 18"src/q_parser.y"1587 #line 225 "src/q_parser.y" 1581 1588 { qp->result = (yyval.query) = NULL; } 1582 1589 break; 1583 1590 1584 1591 case 3: 1585 #line 2 19"src/q_parser.y"1592 #line 226 "src/q_parser.y" 1586 1593 { T qp->result = (yyval.query) = get_bool_q((yyvsp[(1) - (1)].bclss)); E } 1587 1594 break; 1588 1595 1589 1596 case 4: 1590 #line 22 1"src/q_parser.y"1597 #line 228 "src/q_parser.y" 1591 1598 { T (yyval.bclss) = first_cls((yyvsp[(1) - (1)].bcls)); E } 1592 1599 break; 1593 1600 1594 1601 case 5: 1595 #line 22 2"src/q_parser.y"1602 #line 229 "src/q_parser.y" 1596 1603 { T (yyval.bclss) = add_and_cls((yyvsp[(1) - (3)].bclss), (yyvsp[(3) - (3)].bcls)); E } 1597 1604 break; 1598 1605 1599 1606 case 6: 1600 #line 2 23"src/q_parser.y"1607 #line 230 "src/q_parser.y" 1601 1608 { T (yyval.bclss) = add_or_cls((yyvsp[(1) - (3)].bclss), (yyvsp[(3) - (3)].bcls)); E } 1602 1609 break; 1603 1610 1604 1611 case 7: 1605 #line 2 24"src/q_parser.y"1612 #line 231 "src/q_parser.y" 1606 1613 { T (yyval.bclss) = add_default_cls(qp, (yyvsp[(1) - (2)].bclss), (yyvsp[(2) - (2)].bcls)); E } 1607 1614 break; 1608 1615 1609 1616 case 8: 1610 #line 2 26"src/q_parser.y"1617 #line 233 "src/q_parser.y" 1611 1618 { T (yyval.bcls) = get_bool_cls((yyvsp[(2) - (2)].query), BC_MUST); E } 1612 1619 break; 1613 1620 1614 1621 case 9: 1615 #line 2 27"src/q_parser.y"1622 #line 234 "src/q_parser.y" 1616 1623 { T (yyval.bcls) = get_bool_cls((yyvsp[(2) - (2)].query), BC_MUST_NOT); E } 1617 1624 break; 1618 1625 1619 1626 case 10: 1620 #line 2 28"src/q_parser.y"1627 #line 235 "src/q_parser.y" 1621 1628 { T (yyval.bcls) = get_bool_cls((yyvsp[(1) - (1)].query), BC_SHOULD); E } 1622 1629 break; 1623 1630 1624 1631 case 12: 1625 #line 23 1"src/q_parser.y"1632 #line 238 "src/q_parser.y" 1626 1633 { T if ((yyvsp[(1) - (3)].query)) sscanf((yyvsp[(3) - (3)].str),"%f",&((yyvsp[(1) - (3)].query)->boost)); (yyval.query)=(yyvsp[(1) - (3)].query); E } 1627 1634 break; 1628 1635 1629 1636 case 14: 1630 #line 2 34"src/q_parser.y"1637 #line 241 "src/q_parser.y" 1631 1638 { T (yyval.query) = bq_new_max(true, qp->max_clauses); E } 1632 1639 break; 1633 1640 1634 1641 case 15: 1635 #line 2 35"src/q_parser.y"1642 #line 242 "src/q_parser.y" 1636 1643 { T (yyval.query) = get_bool_q((yyvsp[(2) - (3)].bclss)); E } 1637 1644 break; 1638 1645 1639 1646 case 20: 1640 #line 24 1"src/q_parser.y"1647 #line 248 "src/q_parser.y" 1641 1648 { FLDS((yyval.query), get_term_q(qp, field, (yyvsp[(1) - (1)].str))); Y} 1642 1649 break; 1643 1650 1644 1651 case 21: 1645 #line 24 2"src/q_parser.y"1652 #line 249 "src/q_parser.y" 1646 1653 { FLDS((yyval.query), get_fuzzy_q(qp, field, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str))); Y} 1647 1654 break; 1648 1655 1649 1656 case 22: 1650 #line 2 43"src/q_parser.y"1657 #line 250 "src/q_parser.y" 1651 1658 { FLDS((yyval.query), get_fuzzy_q(qp, field, (yyvsp[(1) - (2)].str), NULL)); Y} 1652 1659 break; 1653 1660 1654 1661 case 23: 1655 #line 2 45"src/q_parser.y"1662 #line 252 "src/q_parser.y" 1656 1663 { FLDS((yyval.query), get_wild_q(qp, field, (yyvsp[(1) - (1)].str))); Y} 1657 1664 break; 1658 1665 1659 1666 case 24: 1660 #line 2 47"src/q_parser.y"1667 #line 254 "src/q_parser.y" 1661 1668 { qp_pop_fields(qp); } 1662 1669 break; 1663 1670 1664 1671 case 25: 1665 #line 2 48"src/q_parser.y"1672 #line 255 "src/q_parser.y" 1666 1673 { (yyval.query) = (yyvsp[(3) - (4)].query); } 1667 1674 break; 1668 1675 1669 1676 case 26: 1670 #line 2 49"src/q_parser.y"1677 #line 256 "src/q_parser.y" 1671 1678 { qp_push_fields(qp, qp->all_fields, false); } 1672 1679 break; 1673 1680 1674 1681 case 27: 1675 #line 2 49"src/q_parser.y"1682 #line 256 "src/q_parser.y" 1676 1683 { qp_pop_fields(qp); } 1677 1684 break; 1678 1685 1679 1686 case 28: 1680 #line 25 0"src/q_parser.y"1687 #line 257 "src/q_parser.y" 1681 1688 { (yyval.query) = (yyvsp[(4) - (5)].query); } 1682 1689 break; 1683 1690 1684 1691 case 29: 1685 #line 25 2"src/q_parser.y"1692 #line 259 "src/q_parser.y" 1686 1693 { (yyval.hashset) = first_field(qp, (yyvsp[(1) - (1)].str)); } 1687 1694 break; 1688 1695 1689 1696 case 30: 1690 #line 2 53"src/q_parser.y"1697 #line 260 "src/q_parser.y" 1691 1698 { (yyval.hashset) = add_field(qp, (yyvsp[(3) - (3)].str));} 1692 1699 break; 1693 1700 1694 1701 case 31: 1695 #line 2 55"src/q_parser.y"1702 #line 262 "src/q_parser.y" 1696 1703 { (yyval.query) = get_phrase_q(qp, (yyvsp[(2) - (3)].phrase), NULL); } 1697 1704 break; 1698 1705 1699 1706 case 32: 1700 #line 2 56"src/q_parser.y"1707 #line 263 "src/q_parser.y" 1701 1708 { (yyval.query) = get_phrase_q(qp, (yyvsp[(2) - (5)].phrase), (yyvsp[(5) - (5)].str)); } 1702 1709 break; 1703 1710 1704 1711 case 33: 1705 #line 2 57"src/q_parser.y"1712 #line 264 "src/q_parser.y" 1706 1713 { (yyval.query) = NULL; } 1707 1714 break; 1708 1715 1709 1716 case 34: 1710 #line 2 58"src/q_parser.y"1717 #line 265 "src/q_parser.y" 1711 1718 { (yyval.query) = NULL; (void)(yyvsp[(4) - (4)].str);} 1712 1719 break; 1713 1720 1714 1721 case 35: 1715 #line 26 0"src/q_parser.y"1722 #line 267 "src/q_parser.y" 1716 1723 { (yyval.phrase) = ph_first_word((yyvsp[(1) - (1)].str)); } 1717 1724 break; 1718 1725 1719 1726 case 36: 1720 #line 26 1"src/q_parser.y"1727 #line 268 "src/q_parser.y" 1721 1728 { (yyval.phrase) = ph_first_word(NULL); } 1722 1729 break; 1723 1730 1724 1731 case 37: 1725 #line 26 2"src/q_parser.y"1732 #line 269 "src/q_parser.y" 1726 1733 { (yyval.phrase) = ph_add_word((yyvsp[(1) - (2)].phrase), (yyvsp[(2) - (2)].str)); } 1727 1734 break; 1728 1735 1729 1736 case 38: 1730 #line 2 63"src/q_parser.y"1737 #line 270 "src/q_parser.y" 1731 1738 { (yyval.phrase) = ph_add_word((yyvsp[(1) - (3)].phrase), NULL); } 1732 1739 break; 1733 1740 1734 1741 case 39: 1735 #line 2 64"src/q_parser.y"1742 #line 271 "src/q_parser.y" 1736 1743 { (yyval.phrase) = ph_add_multi_word((yyvsp[(1) - (3)].phrase), (yyvsp[(3) - (3)].str)); } 1737 1744 break; 1738 1745 1739 1746 case 40: 1740 #line 2 66"src/q_parser.y"1747 #line 273 "src/q_parser.y" 1741 1748 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].str), true, true)); Y} 1742 1749 break; 1743 1750 1744 1751 case 41: 1745 #line 2 67"src/q_parser.y"1752 #line 274 "src/q_parser.y" 1746 1753 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].str), true, false)); Y} 1747 1754 break; 1748 1755 1749 1756 case 42: 1750 #line 2 68"src/q_parser.y"1757 #line 275 "src/q_parser.y" 1751 1758 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].str), false, true)); Y} 1752 1759 break; 1753 1760 1754 1761 case 43: 1755 #line 2 69"src/q_parser.y"1762 #line 276 "src/q_parser.y" 1756 1763 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].str), false, false)); Y} 1757 1764 break; 1758 1765 1759 1766 case 44: 1760 #line 27 0"src/q_parser.y"1767 #line 277 "src/q_parser.y" 1761 1768 { FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[(2) - (3)].str), false, false)); Y} 1762 1769 break; 1763 1770 1764 1771 case 45: 1765 #line 27 1"src/q_parser.y"1772 #line 278 "src/q_parser.y" 1766 1773 { FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[(2) - (3)].str), false, true)); Y} 1767 1774 break; 1768 1775 1769 1776 case 46: 1770 #line 27 2"src/q_parser.y"1777 #line 279 "src/q_parser.y" 1771 1778 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (3)].str), NULL,true, false)); Y} 1772 1779 break; 1773 1780 1774 1781 case 47: 1775 #line 2 73"src/q_parser.y"1782 #line 280 "src/q_parser.y" 1776 1783 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (3)].str), NULL,false, false)); Y} 1777 1784 break; 1778 1785 1779 1786 case 48: 1780 #line 2 74"src/q_parser.y"1787 #line 281 "src/q_parser.y" 1781 1788 { FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[(2) - (2)].str), false, false)); Y} 1782 1789 break; 1783 1790 1784 1791 case 49: 1785 #line 2 75"src/q_parser.y"1792 #line 282 "src/q_parser.y" 1786 1793 { FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[(3) - (3)].str), false, true)); Y} 1787 1794 break; 1788 1795 1789 1796 case 50: 1790 #line 2 76"src/q_parser.y"1797 #line 283 "src/q_parser.y" 1791 1798 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(3) - (3)].str), NULL,true, false)); Y} 1792 1799 break; 1793 1800 1794 1801 case 51: 1795 #line 2 77"src/q_parser.y"1802 #line 284 "src/q_parser.y" 1796 1803 { FLDS((yyval.query), get_r_q(qp, field, (yyvsp[(2) - (2)].str), NULL,false, false)); Y} 1797 1804 break; … … 1799 1806 1800 1807 /* Line 1267 of yacc.c. */ 1801 #line 180 2"src/q_parser.c"1808 #line 1809 "src/q_parser.c" 1802 1809 default: break; 1803 1810 } … … 2013 2020 2014 2021 2015 #line 2 79"src/q_parser.y"2022 #line 286 "src/q_parser.y" 2016 2023 2017 2024 … … 2019 2026 static const char *not_word = " \t()[]{}!\"~^|<>="; 2020 2027 2028 /** 2029 * +get_word+ gets the next query-word from the query string. A query-word is 2030 * basically a string of non-special or escaped special characters. It is 2031 * Analyzer agnostic. It is up to the get_*_q methods to tokenize the word and 2032 * turn it into a +Query+. See the documentation for each get_*_q method to 2033 * see how it handles tokenization. 2034 * 2035 * Note that +get_word+ is also responsible for returning field names and 2036 * matching the special tokens 'AND', 'NOT', 'REQ' and 'OR'. 2037 */ 2021 2038 static int get_word(YYSTYPE *lvalp, QParser *qp) 2022 2039 { … … 2062 2079 *bufp++ = c; 2063 2080 } 2064 /* we've exceeded the static buffer. switch to the dynamic 2065 one. */ 2081 /* we've exceeded the static buffer. switch to the dynamic one. The 2082 * dynamic buffer is allocated enough space to hold the whole query 2083 * string so it's capacity doesn't need to be checked again once 2084 * allocated. */ 2066 2085 if (!qp->dynbuf && ((bufp - buf) == MAX_WORD_SIZE)) { 2067 2086 qp->dynbuf = ALLOC_AND_ZERO_N(char, strlen(qp->qstr) + 1); … … 2073 2092 get_word_done: 2074 2093 qp->qstrp--; 2075 /* check for keywords. There are only four so we have a bit of a hack which2076 * just checks for all of them. */2094 /* check for keywords. There are only four so we have a bit of a hack 2095 * which just checks for all of them. */ 2077 2096 *bufp = '\0'; 2078 2097 len = (int)(bufp - buf); … … 2094 2113 } 2095 2114 2115 /** 2116 * +yylex+ is the lexing method called by the QueryParser. It breaks the 2117 * query up into special characters; 2118 * 2119 * ( "&:()[]{}!\"~^|<>=*?+-" ) 2120 * 2121 * and tokens; 2122 * 2123 * - QWRD 2124 * - WILD_STR 2125 * - AND['AND', '&&'] 2126 * - OR['OR', '||'] 2127 * - REQ['REQ', '+'] 2128 * - NOT['NOT', '-', '~'] 2129 * 2130 * QWRD tokens are query word tokens which are made up of characters other 2131 * than the special characters. They can also contain special characters when 2132 * escaped with a backslash '\'. WILD_STR is the same as QWRD except that it 2133 * may also contain '?' and '*' characters. 2134 * 2135 * If any of the special chars are seen they will usually be returned straight 2136 * away. The exceptions are the wild chars '*' and '?', and '&' which will be 2137 * treated as a plain old word character unless followed by another '&'. 2138 * 2139 * If no special characters or tokens are found then yylex delegates to 2140 * +get_word+ which will fetch the next query-word. 2141 */ 2096 2142 static int yylex(YYSTYPE *lvalp, QParser *qp) 2097 2143 { … … 2132 2178 } 2133 2179 2180 /** 2181 * yyerror gets called if there is an parse error with the yacc parser. 2182 * It is responsible for clearing any memory that was allocated during the 2183 * parsing process. 2184 */ 2134 2185 static int yyerror(QParser *qp, char const *msg) 2135 2186 { … … 2152 2203 #define BQ(query) ((BooleanQuery *)(query)) 2153 2204 2205 /** 2206 * The QueryParser caches a tokenizer for each field so that it doesn't need 2207 * to allocate a new tokenizer for each term in the query. This would be quite 2208 * expensive as tokenizers use quite a large hunk of memory. 2209 * 2210 * This method returns the query parser for a particular field and sets it up 2211 * with the text to be tokenized. 2212 */ 2154 2213 static TokenStream *get_cached_ts(QParser *qp, char *field, char *text) 2155 2214 { … … 2172 2231 } 2173 2232 2233 /** 2234 * Turns a BooleanClause array into a BooleanQuery. It will optimize the query 2235 * if 0 or 1 clauses are present to NULL or the actual query in the clause 2236 * respectively. 2237 */ 2174 2238 static Query *get_bool_q(BCArray *bca) 2175 2239 { … … 2207 2271 } 2208 2272 2273 /** 2274 * Base method for appending BooleanClauses to a BooleanClause array. This 2275 * method doesn't care about the type of clause (MUST, SHOULD, MUST_NOT). 2276 */ 2209 2277 static void bca_add_clause(BCArray *bca, BooleanClause *clause) 2210 2278 { … … 2217 2285 } 2218 2286 2287 /** 2288 * Add the first clause to a BooleanClause array. This method is also 2289 * responsible for allocating a new BooleanClause array. 2290 */ 2219 2291 static BCArray *first_cls(BooleanClause *clause) 2220 2292 { … … 2228 2300 } 2229 2301 2302 /** 2303 * Add AND clause to the BooleanClause array. The means that it will set the 2304 * clause being added and the previously added clause from SHOULD clauses to 2305 * MUST clauses. (If they are currently MUST_NOT clauses they stay as they 2306 * are.) 2307 */
