|
ESP_IOT v2.5
IOT ESP Coding
|
#include "TokenParser.h"
Go to the source code of this file.
Classes | |
| struct | identifierStruct |
Macros | |
| #define | setIndex 3 |
| #define | userIndex 4 |
| #define | passIndex 5 |
| #define | deviceIndex 6 |
| #define | cmdIndex 7 |
| #define | flagIndex 8 |
| #define | smartSwitch 3 |
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... | |
| char * | semanticMarkerToJSON_TokenParser (char *semanticMarker) |
| char * | parseSM_For_UUID_Flownum (char *semanticMarker) |
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... | |
| char | _JSON_String_mainModule [300] |
| storage for the current identifier More... | |
| char | _sm_for_UUID_Flownum [100] |
| global for returning.. More... | |
| #define cmdIndex 7 |
| #define deviceIndex 6 |
| #define flagIndex 8 |
| #define passIndex 5 |
| #define setIndex 3 |
| #define smartSwitch 3 |
| #define userIndex 4 |
| 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 242 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 363 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
NOTE: doesn't support the BLE addresses like: DevQuery: !M5Laybrinth & !84:cc:a8:7a:f6:aa
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 258 of file TokenParser.cpp.

| char * parseSM_For_UUID_Flownum | ( | char * | semanticMarker | ) |
3.29.25 Raiiiinier Beeer movie last night add returning a UUID.FLOWNUM if valid, or nil if nota note "flow" .. not flownum uuid=x&flow=y& .. flownum could be the last .. so end-of-line
syntax: uuid=X&flownum=Y
needed to copy semanticMarker .. as the code below broke the callers' value to "https:" .. SIDE EFFECT
look for tokens
break by '&'
advance quealIndex past the equal
Definition at line 838 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 191 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 424 of file TokenParser.cpp.


| char * semanticMarkerToJSON_TokenParser | ( | char * | semanticMarker | ) |
3.23.25 rainy weekend create a JSON string from the SemanticMarker https://semanticmarker.org/bot/setdevice/scott@konacurrents.com/PASS/M5AtomSocket/socket/on} Create a JSON knowing the "bot" syntax, eg. setdevice/USER/PASS/device/<set>/<flag> and others like set etc. Maybe not 'dev' here. Others cmddevice/USER/PASS return: {'set':<set>,"dev': set- sends the message (command/value) to all device Supports these for now: GET /set/{username}/{password}/{command}/{value} GET /send/{username}/{password}/{request} only support 'device' ones GET /setdevice/{username}/{password}/{devicename}/{command}/{value} GET /senddevice/{username}/{password}/{device}/{request} return "" if not valid
not supported
if set then there will be more .. so add ',' if send then this is the end (no ',')
replace ' with "
Definition at line 721 of file TokenParser.cpp.

| void setup_tokenParser_mainModule | ( | ) |
setup a test ..
setup for the token parser (really just for testing)
Definition at line 659 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 412 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 | ) |
whether the character is a valid identifier character 1.22.24 adding ":" so fits a BLE address DevQuery: !M5Laybrinth & !84:cc:a8:7a:f6:aa
Definition at line 172 of file TokenParser.cpp.

| 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.
| char _JSON_String_mainModule[300] |
storage for the current identifier
Definition at line 704 of file TokenParser.cpp.
| boolean _parsingIdentifier |
whether in an identifier parsing
Definition at line 69 of file TokenParser.cpp.
| char _sm_for_UUID_Flownum[100] |
global for returning..
Definition at line 833 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.