kopia lustrzana https://github.com/martin-ger/esp_mqtt
added 'while do' in scripts
rodzic
f8f57ecaf7
commit
bcdf67d648
|
@ -52,6 +52,7 @@ In general, scripts conform to the following BNF:
|
|||
gpio_pwm <num> <num> |
|
||||
serial_out <expr> |
|
||||
if <expr> then <action> [else <action>] endif |
|
||||
while <expr> do <action> done |
|
||||
print <expr> | println <expr> |
|
||||
system <expr> |
|
||||
<action> <action>
|
||||
|
@ -208,6 +209,11 @@ if <expr> then <action> [else <action>] endif
|
|||
```
|
||||
Classic "if then else" expression. Sequences of actions must be terminated with the (optional) "else" and the "endif". Can be nested.
|
||||
|
||||
```
|
||||
while <expr> do <action> done
|
||||
```
|
||||
Classic "while" loop. Can be nested. Make sure that loops terminate quickly (about a second) to avoid a watchdog timeout reset.
|
||||
|
||||
## Expressions
|
||||
Expressions evaluate to a (string) value. A single constant, a string, or a variable are the basic expressions. Expressions can be combined by operators. If more than one operator is used in an expression, all expressions are stricly evaluated from left to right. CAUTION: arithmetical preceedence does not (yet) apply automatically like in other programming languages. However, the preceedence can be fully controlled by brackets.
|
||||
|
||||
|
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -1,2 +1,2 @@
|
|||
10e10e08f05ad126cf205ec87f50412f8642841f 0x00000.bin
|
||||
4831e82954d459e4efc2fd470c8e7cb4d28e528a 0x10000.bin
|
||||
fc934837e57507b0e318ae84738b9838584efbab 0x00000.bin
|
||||
e35e62cba7daba715dc97b08c77ea93bee07c966 0x10000.bin
|
||||
|
|
36
user/lang.c
36
user/lang.c
|
@ -663,7 +663,7 @@ int ICACHE_FLASH_ATTR parse_action(int next_token, bool doit) {
|
|||
|
||||
while (next_token < max_token && !is_token(next_token, "on")
|
||||
&& !is_token(next_token, "config") && !is_token(next_token, "else")
|
||||
&& !is_token(next_token, "endif")) {
|
||||
&& !is_token(next_token, "endif") && !is_token(next_token, "done")) {
|
||||
bool is_nl = false;
|
||||
|
||||
if (doit) {
|
||||
|
@ -854,6 +854,38 @@ int ICACHE_FLASH_ATTR parse_action(int next_token, bool doit) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
else if (is_token(next_token, "while")) {
|
||||
uint32_t if_val = 0;
|
||||
char *if_char;
|
||||
int if_len;
|
||||
Value_Type if_type;
|
||||
int exp_token;
|
||||
int repeat_token = next_token;
|
||||
|
||||
len_check(3);
|
||||
exp_token = next_token + 1;
|
||||
if ((next_token = parse_expression(next_token + 1, &if_char, &if_len, &if_type, doit)) == -1)
|
||||
return -1;
|
||||
if (syn_chk && !is_token(next_token, "do"))
|
||||
return syntax_error(next_token, "'do' expected");
|
||||
|
||||
if (doit) {
|
||||
if_val = atoi(if_char);
|
||||
if (if_val != 0)
|
||||
lang_log("while %s %s... (done) \r\n", my_token[exp_token++], my_token[exp_token]);
|
||||
}
|
||||
if ((next_token = parse_action(next_token + 1, doit && if_val != 0)) == -1)
|
||||
return -1;
|
||||
if (syn_chk && !is_token(next_token - 1, "done")) {
|
||||
return syntax_error(next_token - 1, "'done' expected");
|
||||
}
|
||||
if (!syn_chk && doit && if_val != 0) {
|
||||
next_token = repeat_token;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (is_token(next_token, "settimer")) {
|
||||
len_check(2);
|
||||
uint32_t timer_no = atoi(my_token[next_token + 1]);
|
||||
|
@ -1108,7 +1140,7 @@ int ICACHE_FLASH_ATTR parse_action(int next_token, bool doit) {
|
|||
|
||||
}
|
||||
|
||||
if (is_token(next_token, "endif"))
|
||||
if (is_token(next_token, "endif") || is_token(next_token, "done"))
|
||||
next_token++;
|
||||
|
||||
return next_token;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _USER_CONFIG_
|
||||
#define _USER_CONFIG_
|
||||
|
||||
#define ESP_UBROKER_VERSION "V2.0.4"
|
||||
#define ESP_UBROKER_VERSION "V2.0.5"
|
||||
|
||||
#define WIFI_SSID "ssid"
|
||||
#define WIFI_PASSWORD "password"
|
||||
|
|
Ładowanie…
Reference in New Issue