You are going to love this issue!
I have been battling a challenge with testing a matched variable against a set, and I think I’ve tracked down the problem.
Consider the following concepts:
concept: ~valentines_day (valentine Valentine Valentine_Day Valentines_Day)
concept: ~named_date (~valentines_day)
and this test, which I’ve simplified from my actual code which is spread over several rules, but shows the problem in a single line.
:testpattern (_~named_date _0?~named_date) book valentines day
The _~named_date correctly matches the input and memorizes it.
But the _0?~named_date test unexpectedly fails.
I think I’ve tracked it down to the HandleRelation function. For a ? operation against a memorized variable it calls GetNextSpot() and tests returned value, which is a starting position, against the starting word position of that match variable.
The problem is that GetNextSpot() returns the value of the startPosition parameter, but that, and the endPosition, and passed into the function as the address of variables and as HandleRelation passes those two parameters as the same junk variable then startPosition and endPosition point to the same place and hence contain the same value - the endPosition because that is assigned last.
FunctionResult HandleRelation(char* word1,char* op, char* word2,bool output,unsigned int& id, char* word1val, char* word2val)
. . .
unsigned int junk;
if (GetNextSpot(D, index - 1, junk, junk) == index) result = NOPROBLEM_BIT; // otherwise failed and we would have known
unsigned int GetNextSpot(WORDP D,int start,unsigned int &startPosition;,unsigned int& endPosition, bool reverse)
. . .
else if (at > start)
{
if (at == 0xff) return 0; // end of data going forward
startPosition = at;
endPosition = end;
return startPosition;
}
Therefore where the matched variable is a phrase then the test fails.
For now, I’ve modified the code to have 2 junk variables.