| 1702 | ----------------------------------------------------------------- */ |
| 1703 | |
| 1704 | action* parse_preferences(agent* thisAgent, Symbol* id, |
| 1705 | rhs_value attr, rhs_value value) |
| 1706 | { |
| 1707 | action* a; |
| 1708 | action* prev_a; |
| 1709 | rhs_value referent; |
| 1710 | byte preference_type; |
| 1711 | bool saw_plus_sign; |
| 1712 | |
| 1713 | /* --- Note: this routine is set up so if there's not preference type |
| 1714 | indicator at all, we return a single acceptable preference make --- */ |
| 1715 | |
| 1716 | prev_a = NIL; |
| 1717 | |
| 1718 | saw_plus_sign = (thisAgent->lexeme.type == PLUS_LEXEME); |
| 1719 | preference_type = parse_preference_specifier_without_referent(thisAgent); |
| 1720 | if ((preference_type == ACCEPTABLE_PREFERENCE_TYPE) && (! saw_plus_sign)) |
| 1721 | { |
| 1722 | /* If the routine gave us a + pref without seeing a + sign, then it's |
| 1723 | just giving us the default acceptable preference. Look for optional |
| 1724 | comma. */ |
| 1725 | if (thisAgent->lexeme.type == COMMA_LEXEME) |
| 1726 | { |
| 1727 | get_lexeme(thisAgent); |
| 1728 | } |
| 1729 | } |
| 1730 | |
| 1731 | while (true) |
| 1732 | { |
| 1733 | /* --- read referent --- */ |
| 1734 | if (preference_is_binary(preference_type)) |
| 1735 | { |
| 1736 | referent = parse_rhs_value(thisAgent); |
| 1737 | if (! referent) |
| 1738 | { |
| 1739 | deallocate_action_list(thisAgent, prev_a); |
| 1740 | return NIL; |
| 1741 | } |
| 1742 | if (thisAgent->lexeme.type == COMMA_LEXEME) |
| 1743 | { |
| 1744 | get_lexeme(thisAgent); |
| 1745 | } |
| 1746 | } |
| 1747 | else |
| 1748 | { |
| 1749 | referent = NIL; /* unnecessary, but gcc -Wall warns without it */ |
| 1750 | } |
| 1751 | |
| 1752 | /* --- create the appropriate action --- */ |
| 1753 | allocate_with_pool(thisAgent, &thisAgent->action_pool, &a); |
| 1754 | a->next = prev_a; |
| 1755 | prev_a = a; |
| 1756 | a->type = MAKE_ACTION; |
| 1757 | a->preference_type = preference_type; |
| 1758 | a->id = symbol_to_rhs_value(id); |
| 1759 | symbol_add_ref(thisAgent, id); |
| 1760 | a->attr = copy_rhs_value(thisAgent, attr); |
| 1761 | a->value = copy_rhs_value(thisAgent, value); |
no test coverage detected