-
Notifications
You must be signed in to change notification settings - Fork 1
/
command_parser.h
75 lines (53 loc) · 1.81 KB
/
command_parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
/* This is the parser for processing logic expressions
used in scene definitions
Example:
Patio Door Sensor.0.SensorBinary.Get(1.level) == True
Room Lights.0.Basic.Set(On)
Motion Detector.0.Basic.Set(On)
Motion Detector.0.Basic.Get() == On & Time.0.Basic.Get() > 20:00"
Timer.0.Basic.Set(10, ConditionalLightsOff)
Syntax:
Get Path:
[Device name].[Instance].[CommandClass].Get(data)
Operators:
==,&&,||,>, <, (, )
Set Path:
[Device name].[Instance].[CommandClass].Set(arguments)
Reserved words:
True, False, On, Off
Each device knows its command classes and provides callbacks for Set and Get with relevant argument requirements
Operator precedence is same as in C
*/
#include "command_class.h"
#include "resolver.h"
#include "stack.h"
#include "operator.h"
#include "variant.h"
#include "variant_types.h"
#define MAX_COMMAND_ARGUMENTS 3
#define MAX_METHOD_LEN 32
/*typedef enum OperandType_e
{
DEVICE,
RESERVED_WORD
} OperandType;*/
typedef struct function_operator_data_st
{
device_record_t* device_record;
//ZWBYTE instance_id;
command_class_t* command_class;
char command_method[MAX_METHOD_LEN];
} function_operator_data_t;
typedef struct service_method_operator_data_t
{
} service_method_operator_data_t;
typedef struct dynamic_symbol_t
{
char* symbol;
variant_t* value;
} dynamic_symbol_t;
variant_stack_t* command_parser_compile_expression(const char* expression, bool* isOk);
variant_t* command_parser_execute_expression(variant_stack_t* compiled_expression);
void command_parser_print_stack(variant_stack_t* compiled_expression);
void command_parser_register_symbol(const char* symbol, variant_t* value);