ESP_IOT v2.5
IOT ESP Coding
|
#include "TokenParser.h"
Go to the source code of this file.
Classes | |
struct | identifierStruct |
Typedefs | |
typedef struct identifierStruct | IdentifierStruct |
Enumerations | |
enum | TokensEnum { notModifier_enum , wildcardAny_enum , booleanOr_enum , booleanAnd_enum , identifier_enum , null_enum } |
retrieves the parsed values More... | |
Functions | |
void | pushToken (TokensEnum token) |
pushes token onto token stack More... | |
TokensEnum | topOfTokenStack () |
get the current top of stack token More... | |
TokensEnum | popTokenStack () |
get the current top of stack token, and move the token stack pointer More... | |
void | pushIdentifier (char *identifier) |
pushes identifier onto identifier stack, while also inserting a token for identifier More... | |
int | numTokens () |
how many tokens More... | |
int | numIdentifiers () |
how many identifiers More... | |
TokensEnum | getToken (int num) |
get the nth token More... | |
char * | getIdentifier (int num) |
the nth identifier More... | |
IdentifierStruct | getIdentifierStruct (int num) |
grab full identifier struct (Pointer?) More... | |
void | addIdentifierChar (char c) |
adds a valie character to an identifier More... | |
void | initIdentifier (char c) |
initi for each new identifier More... | |
void | doneParsingIdentifier () |
finished parsing an identifier More... | |
boolean | validIdentifierChar (char c) |
void | processIdentifier () |
void | initParser () |
initialize the parser More... | |
void | parseQueryLine_mainModule (char *line) |
parses a line of text, returning the number of tokens.. More... | |
boolean | nameMatchesWildcardQuery (char *name, IdentifierStruct idQueryStruct) |
boolean | stringIsQuery_mainModule (char *line) |
whether the stirng is a potential query More... | |
boolean | queryMatchesName_mainModule (char *name) |
void | setup_tokenParser_mainModule () |
setup a test .. More... | |
Variables | |
const int | _identifierMaxLen = 30 |
max length of an identifier.. More... | |
char | _identifier [_identifierMaxLen] |
storage for the current identifier More... | |
int | _identifierIndex |
const int | _identifierStructsMax = 3 |
so now a query is { IdentifierStruct <booleanAnd/Or> } More... | |
int | _identifierStructsIndex = 0 |
index into _identifiers array More... | |
IdentifierStruct | _identifierStructs [_identifierStructsMax] |
array of identifiers .. More... | |
const int | _tokensMax = 10 |
TokensEnum | _tokens [_tokensMax] |
int | _tokensStackPointer |
index into _tokens array More... | |
boolean | _parsingIdentifier |
whether in an identifier parsing More... | |
typedef struct identifierStruct IdentifierStruct |
enum TokensEnum |
retrieves the parsed values
the tokens in the token array
Enumerator | |
---|---|
notModifier_enum | |
wildcardAny_enum | |
booleanOr_enum | |
booleanAnd_enum | |
identifier_enum | |
null_enum |
Definition at line 29 of file TokenParser.cpp.
void addIdentifierChar | ( | char | c | ) |
adds a valie character to an identifier
Definition at line 149 of file TokenParser.cpp.
void doneParsingIdentifier | ( | ) |
finished parsing an identifier
Definition at line 163 of file TokenParser.cpp.
char * getIdentifier | ( | int | num | ) |
the nth identifier
Definition at line 137 of file TokenParser.cpp.
IdentifierStruct getIdentifierStruct | ( | int | num | ) |
grab full identifier struct (Pointer?)
Definition at line 143 of file TokenParser.cpp.
TokensEnum getToken | ( | int | num | ) |
get the nth token
Definition at line 132 of file TokenParser.cpp.
void initIdentifier | ( | char | c | ) |
initi for each new identifier
Definition at line 156 of file TokenParser.cpp.
void initParser | ( | ) |
initialize the parser
Definition at line 238 of file TokenParser.cpp.
boolean nameMatchesWildcardQuery | ( | char * | name, |
IdentifierStruct | idQueryStruct | ||
) |
These are CASE SENSITIVE matches ... matches name with wildcards and the idToMatch name is what is being queried, the idQueryStruct is the QUERY
see if there was a NOT (!)
Definition at line 358 of file TokenParser.cpp.
int numIdentifiers | ( | ) |
how many identifiers
Definition at line 127 of file TokenParser.cpp.
int numTokens | ( | ) |
how many tokens
Definition at line 122 of file TokenParser.cpp.
void parseQueryLine_mainModule | ( | char * | line | ) |
parses a line of text, returning the number of tokens..
parses a line of text, The caller then uses queryMatchesName() to see if their name matches
initialize the variables for parsing this line
if no query params, then make it an identifier and exit
if parsing still then add to identifier
start a new identifier..
init the identifier
else not valid identifier (so a follow..)
done parsing if not a valid identifier character
finishIdNeeded is before pushing another token, unless a not or wildcard
now classify this char if an identifier modifier
! and * belong to the identifier object if a modifier of ident (~ or *) then push the token, and process the identifier
an operator or space if inside an identifier, finish it first
process the token
& and | are expression modifiers
if end of line, and was parsing an identifier .. then finish
Definition at line 254 of file TokenParser.cpp.
TokensEnum popTokenStack | ( | ) |
get the current top of stack token, and move the token stack pointer
else pop
Definition at line 95 of file TokenParser.cpp.
void processIdentifier | ( | ) |
push identifier .. looks at the stack and fills in the identifier object called after seeing a & or | (the follow set of the identifier, after a *)*
the index is already 1 past..
look at stack
replace the stack with our filled out identifier
Definition at line 187 of file TokenParser.cpp.
void pushIdentifier | ( | char * | identifier | ) |
pushes identifier onto identifier stack, while also inserting a token for identifier
now save Identifier
Definition at line 112 of file TokenParser.cpp.
void pushToken | ( | TokensEnum | token | ) |
pushes token onto token stack
Definition at line 72 of file TokenParser.cpp.
boolean queryMatchesName_mainModule | ( | char * | name | ) |
now need to process the token tree to see if name1 and name2 match the query eg. ! name & name2 ... wildcards after name make it slightly complicated SO: look for wildcards before and after, and the id. then decide if that matches before the boolean and notmodifier applied
basically for each identifier in the query, the names (1&2) have to be compared each time..
what the last boolean_enum was..
the result of A <> B
Definition at line 419 of file TokenParser.cpp.
void setup_tokenParser_mainModule | ( | ) |
setup a test ..
setup for the token parser (really just for testing)
Definition at line 654 of file TokenParser.cpp.
boolean stringIsQuery_mainModule | ( | char * | line | ) |
whether the stirng is a potential query
whether the stirng is a potential query. This can be used, but it is also used by the parseQueryLine to optimize out the original dev:name query.
Definition at line 407 of file TokenParser.cpp.
TokensEnum topOfTokenStack | ( | ) |
get the current top of stack token
otherwise grab the top
Definition at line 85 of file TokenParser.cpp.
boolean validIdentifierChar | ( | char | c | ) |
char _identifier[_identifierMaxLen] |
storage for the current identifier
Definition at line 42 of file TokenParser.cpp.
int _identifierIndex |
Definition at line 44 of file TokenParser.cpp.
const int _identifierMaxLen = 30 |
max length of an identifier..
Definition at line 40 of file TokenParser.cpp.
IdentifierStruct _identifierStructs[_identifierStructsMax] |
array of identifiers ..
Definition at line 61 of file TokenParser.cpp.
int _identifierStructsIndex = 0 |
index into _identifiers array
Definition at line 59 of file TokenParser.cpp.
const int _identifierStructsMax = 3 |
so now a query is { IdentifierStruct <booleanAnd/Or> }
the max number of identifiers
Definition at line 57 of file TokenParser.cpp.
boolean _parsingIdentifier |
whether in an identifier parsing
Definition at line 69 of file TokenParser.cpp.
TokensEnum _tokens[_tokensMax] |
Definition at line 64 of file TokenParser.cpp.
const int _tokensMax = 10 |
Definition at line 63 of file TokenParser.cpp.
int _tokensStackPointer |
index into _tokens array
Definition at line 66 of file TokenParser.cpp.