3#ifdef WILDCARD_DEVICE_NAME_SUPPORT
78 SerialMin.println(
" *** Over the token max ***");
114 SerialLots.printf(
"\nPushId %s\n", identifier);
172 boolean valid =
false;
175 else if (c >=
'A' && c <=
'Z')
177 else if (c >=
'a' && c <=
'z')
179 else if (c >=
'0' && c <=
'9')
191 SerialLots.printf(
"\nprocessIdentifier[%d]\n", identifierStructsIndex);
197 SerialLots.printf(
"wildcardAny_enum\n");
205 SerialMin.printf(
"*** Syntax error: expected identifier, found: %d\n", top);
209 SerialLots.printf(
"identifier_enum\n");
217 SerialLots.printf(
"wildcardAny_enum\n");
225 SerialLots.printf(
"notModifier_enum\n");
229 SerialLots.printf(
"token = %d\n", top);
257 SerialTemp.printf(
"\nDevQuery: %s\n", line);
264 SerialLots.println(
"*** Not a query, so optimze to just identifier");
290 boolean finishIdNeeded =
false;
295 finishIdNeeded =
true;
300 if (c ==
'!' || c ==
'*')
337 SerialTemp.println(
" *** INVALID CHAR ***");
360 char *queryIdToMatch = idQueryStruct.
identifier;
365 boolean match =
false;
367 SerialLots.printf(
"%s - idQuery(%s), before=%d,after=%d,not=%d\n", name, queryIdToMatch, wildcardBefore, wildcardAfter, wildcardNot);
372 if (wildcardBefore && wildcardAfter)
374 match = (strstr(name, queryIdToMatch)!=NULL);
375 else if (wildcardAfter)
377 match = (strncmp(name, queryIdToMatch, strlen(queryIdToMatch))==0);
378 else if (wildcardBefore)
380 int queryIdLen = strlen(queryIdToMatch);
381 int nameLen = strlen(name);
388 if (nameLen >= queryIdLen)
391 char *startInName = name + nameLen - queryIdLen;
392 match = strcmp(startInName, queryIdToMatch) == 0;
397 match = strcmp(name, queryIdToMatch)==0;
410 boolean isQuery = strpbrk(line, (
char*)
"|*&!") != NULL;
422 boolean match =
true;
430 boolean thisMatch =
false;
451 match = match && thisMatch;
458 match = match || thisMatch;
460 match = match && thisMatch;
464 SerialLots.printf(
"thisMatch = %d, match = %d\n", thisMatch, match);
481 SerialTemp.println(
"TOKEN TREE..");
488 SerialTemp.printf(
"Token [%d]= ", tokensIndex);
493 SerialTemp.println(
"notModifier_enum");
496 SerialTemp.println(
"wildcardAny_enum");
499 SerialTemp.println(
"booleanOr_enum");
502 SerialTemp.println(
"booleanAnd_enum");
508 SerialTemp.printf(
"identifier_enum: %s%s%s%s\n",
521void testMatchResult(
char*query,
boolean expectedBool)
524 SerialTemp.printf(
"query '%s' ", query);
525 if (match != expectedBool)
526 SerialTemp.printf(
"!= expected: ");
528 SerialTemp.printf(
"== matched : ");
529 SerialTemp.printf(
"%s\n", expectedBool?(
char*)
"MATCH":(
char*)
"NO-MATCH");
533boolean _firstTimeParserTest =
true;
536void testParser_mainModule()
542 testMatchResult((
char*)
"M5WRR",
false);
543 testMatchResult((
char*)
"M5Rainier",
true);
547 testMatchResult((
char*)
"M5WRR",
false);
548 testMatchResult((
char*)
"DukeGEN3",
false);
549 testMatchResult((
char*)
"ScoobyDoo",
true);
550 testMatchResult((
char*)
"ScottyGEN3",
true);
553 testMatchResult((
char*)
"M5Scooby",
true);
554 testMatchResult((
char*)
"DukeGEN3",
true);
558 testMatchResult((
char*)
"M5Scooby",
true);
559 testMatchResult((
char*)
"DukeGEN3",
false);
562 testMatchResult((
char*)
"M5Scooby",
false);
563 testMatchResult((
char*)
"DukeGEN3",
true);
566 testMatchResult((
char*)
"M5Scooby",
false);
567 testMatchResult((
char*)
"DukeGEN3",
false);
568 testMatchResult((
char*)
"M5DukeGEN3",
false);
569 testMatchResult((
char*)
"M5DukeGEN3",
true);
572 testMatchResult((
char*)
"M5Scooby",
false);
573 testMatchResult((
char*)
"DukeGEN3",
true);
574 testMatchResult((
char*)
"M5DukeGEN3",
false);
577 testMatchResult((
char*)
"M5WRR",
false);
578 testMatchResult((
char*)
"DukeGEN3",
true);
581 testMatchResult((
char*)
"M5WRR",
false);
582 testMatchResult((
char*)
"M5Scooby",
true);
585 testMatchResult((
char*)
"M5Scooby",
true);
586 testMatchResult((
char*)
"GEN3Scott",
true);
587 testMatchResult((
char*)
"ScoobyDoo",
true);
588 testMatchResult((
char*)
"Duke",
false);
589 testMatchResult((
char*)
"M5Duke",
true);
592 testMatchResult((
char*)
"ScoobyDoo",
true);
593 testMatchResult((
char*)
"Duke",
false);
596 testMatchResult((
char*)
"ScoobyDoo",
true);
597 testMatchResult((
char*)
"M5WRR",
false);
598 testMatchResult((
char*)
"GEN3Scott",
true);
601 testMatchResult((
char*)
"ScoobyDoo",
true);
602 testMatchResult((
char*)
"M5WRR",
false);
603 testMatchResult((
char*)
"GEN3Scott",
true);
607 testMatchResult((
char*)
"Room1_M5Scooby",
true);
608 testMatchResult((
char*)
"Room1_GEN3",
false);
609 testMatchResult((
char*)
"Room2_GEN3",
false);
610 testMatchResult((
char*)
"M5WRR",
false);
614 testMatchResult((
char*)
"Room1_M5Scooby",
true);
615 testMatchResult((
char*)
"Room1_GEN3",
true);
616 testMatchResult((
char*)
"Room2_GEN3",
false);
617 testMatchResult((
char*)
"Room2_M5",
true);
618 testMatchResult((
char*)
"M5WRR",
true);
622 testMatchResult((
char*)
"Room1_M5Scooby",
true);
623 testMatchResult((
char*)
"Room1_GEN3",
true);
624 testMatchResult((
char*)
"Room2_GEN3",
false);
628 testMatchResult((
char*)
"Scooby_Room1",
true);
629 testMatchResult((
char*)
"Scooby_Room1_GEN3",
false);
630 testMatchResult((
char*)
"Room1",
true);
631 testMatchResult((
char*)
"Room2",
false);
635 testMatchResult((
char*)
"Scooby_GEN3",
true);
636 testMatchResult((
char*)
"Scooby_GEN3_Room1",
false);
637 testMatchResult((
char*)
"GEN3",
true);
638 testMatchResult((
char*)
"GEN2",
false);
642 testMatchResult((
char*)
"Scooby_GEN3",
false);
643 testMatchResult((
char*)
"Scooby_GEN3_Room1",
true);
644 testMatchResult((
char*)
"GEN3",
false);
645 testMatchResult((
char*)
"GEN2",
true);
646 testMatchResult((
char*)
"M5Scooby",
true);
647 testMatchResult((
char*)
"DukeGEN3",
false);
648 testMatchResult((
char*)
"M5DukeGEN3",
false);
657 if (_firstTimeParserTest)
659 _firstTimeParserTest =
false;
660 testParser_mainModule();
void initParser()
initialize the parser
TokensEnum topOfTokenStack()
get the current top of stack token
const int _identifierStructsMax
so now a query is { IdentifierStruct <booleanAnd/Or> }
boolean stringIsQuery_mainModule(char *line)
whether the stirng is a potential query
struct identifierStruct IdentifierStruct
const int _identifierMaxLen
max length of an identifier..
TokensEnum _tokens[_tokensMax]
boolean nameMatchesWildcardQuery(char *name, IdentifierStruct idQueryStruct)
void addIdentifierChar(char c)
adds a valie character to an identifier
boolean _parsingIdentifier
whether in an identifier parsing
boolean queryMatchesName_mainModule(char *name)
void initIdentifier(char c)
initi for each new identifier
IdentifierStruct _identifierStructs[_identifierStructsMax]
array of identifiers ..
TokensEnum getToken(int num)
get the nth token
void parseQueryLine_mainModule(char *line)
parses a line of text, returning the number of tokens..
void setup_tokenParser_mainModule()
setup a test ..
void pushToken(TokensEnum token)
pushes token onto token stack
boolean validIdentifierChar(char c)
int numTokens()
how many tokens
void pushIdentifier(char *identifier)
pushes identifier onto identifier stack, while also inserting a token for identifier
char * getIdentifier(int num)
the nth identifier
int _identifierStructsIndex
index into _identifiers array
int numIdentifiers()
how many identifiers
TokensEnum popTokenStack()
get the current top of stack token, and move the token stack pointer
int _tokensStackPointer
index into _tokens array
void doneParsingIdentifier()
finished parsing an identifier
char _identifier[_identifierMaxLen]
storage for the current identifier
TokensEnum
retrieves the parsed values
IdentifierStruct getIdentifierStruct(int num)
grab full identifier struct (Pointer?)
char identifier[_identifierMaxLen]