ESP_IOT v2.5
IOT ESP Coding
TokenParser.h
Go to the documentation of this file.
1
2#ifndef TokenParser_h
3#define TokenParser_h
4
5#include "../../Defines.h"
6
7/*
8 <identifier> ::= {characters A-Z,a-z,0-9,_}
9 <notModifier> ::= '!'
10 <modifier> ::= <notModifier>
11 <wildcardAny> ::= '*'
12 <wildcard> ::= <wildcardAny>
13 <booleanAnd> ::= '&'
14 <booleanOr> ::= '|'
15 <booleanOps> ::= <booleanAnd> | <booleanOr> | <null>
16 <queryElement> ::= { [<modifier>] [<wildcard>] <identifier> [<wildcard>] }
17 <queryPart> ::= { <queryElement> <booleanOps> }
18
19 <identifierFollow> ::= {anything not <identifier> }
20 eg. ! M5* -> <notModifier> <identifier> <wildcard>
21 !*M5* & ! *GEN3* -> <wildcard=*> <identifier=M5> <wildcard=*> <booleanOps=&> <wildcard=*> <identifier=GEN3>
22 means: any non M5* and not *GEN3*
23
24
25 Currently presidence will be AND over OR (or just left to right)
26
27 Usage:
28 parseQueryLine_mainModule((char*)"M5* | DukeGEN3");
29 boolean queryMatchesName_mainModule("M5Duke");
30 */
31
32
33//!parses a line of text, The caller then uses queryMatchesName() to see if their name matches
34void parseQueryLine_mainModule(char *line);
35
36//!now need to process the token tree to see if name1 and name2 match the query
37//!eg. ! *name* & name2 ...
38//!wildcards after name make it slightly complicated
39//! SO: look for wildcards before and after, and the id. then decide if that matches
40//! before the boolean and notmodifier applied
41boolean queryMatchesName_mainModule(char*name);
42
43//! whether the stirng is a potential query. This can be used, but it is also used by the parseQueryLine
44//! to optimize out the original dev:name query.
45boolean stringIsQuery_mainModule(char *line);
46
47//! setup for the token parser (really just for testing)
49
50//! 3.23.25 rainy weekend
51//! create a JSON string from the SemanticMarker
52//! https://semanticmarker.org/bot/setdevice/scott@konacurrents.com/PASS/M5AtomSocket/socket/on}
53//! Create a JSON knowing the "bot" syntax, eg. setdevice/USER/PASS/device/<set>/<flag>
54//! and others like set etc.
55//! Maybe not 'dev' here. Others cmddevice/USER/PASS
56//! return: {'set':<set>,"dev':
57//! Supports these for now:
58//!GET /set/{username}/{password}/{command}/{value}
59//!GET /send/{username}/{password}/{request}
60//! only support 'device' ones
61//!GET /setdevice/{username}/{password}/{devicename}/{command}/{value}
62//!GET /senddevice/{username}/{password}/{device}/{request}
63//!return "" if not valid
64char *semanticMarkerToJSON_TokenParser(char* semanticMarker);
65
66//! 3.29.25 Raiiiinier Beeer movie last night
67//! add returning a UUID.FLOWNUM if valid, or nil if nota
68char *parseSM_For_UUID_Flownum(char* semanticMarker);
69
70//! 2.11.26 Rainier out in spring like day.
71//! refactor, moving parsing from Chain to here..
72
73
74//! 2.10.26 NICE day out ..
75//! struct for returning a parsed SM address
76//! syntax: uuid.flow(set,val,dev)
77typedef struct smStruct
78{
79 char *smAddress;
80 char *setString;
81 char *valString;
82 char *devString;
84
85//! 2.10.26 Sunny Clear, Mountain,
86//! parse the address
87//! syntax: uuid.flow(set,val,dev)
88//! NOTE: THis creates storage for the 3 components
89SMStruct parseSMAddress(char *str);
90
91//! 2.11.26 Lincoln's birthday, Puppies going home to Auburn, Nice Day out..
92//! return the uuid.flownum (if any)
93//! search for 'uuid=<uuid>&" and "flow=<flow> [& or }"
94//! return NULL if not matching
95//! NOTE: no storage is created but the buffer returned is REUSED
96char *parseDOCFOLLOW(char *str);
97
98#endif// TokenParser_h
99
char * parseDOCFOLLOW(char *str)
boolean stringIsQuery_mainModule(char *line)
whether the stirng is a potential query
struct smStruct SMStruct
boolean queryMatchesName_mainModule(char *name)
void parseQueryLine_mainModule(char *line)
parses a line of text, The caller then uses queryMatchesName() to see if their name matches
void setup_tokenParser_mainModule()
setup for the token parser (really just for testing)
char * semanticMarkerToJSON_TokenParser(char *semanticMarker)
char * parseSM_For_UUID_Flownum(char *semanticMarker)
before 1355313 now 1355169
SMStruct parseSMAddress(char *str)
2.11.26 moved here from ChainButtonClassType
char * devString
Definition: TokenParser.h:82
char * valString
Definition: TokenParser.h:81
char * smAddress
Definition: TokenParser.h:79
char * setString
Definition: TokenParser.h:80