summaryrefslogtreecommitdiff
path: root/src/sp_var_parser.h
diff options
context:
space:
mode:
authorxXx-caillou-xXx2017-12-20 18:09:53 +0100
committerjvoisin2017-12-20 18:09:53 +0100
commite7f541396715ee2895abcf73044b91ae9b746201 (patch)
treeba0e9765e7f14f04b92585df1f3fcd1830ab4b00 /src/sp_var_parser.h
parent8d6cc4f2b63c3f0dc31fe6cecd34ac023ea1cccb (diff)
Better parsing of the rules
Thanks to this huge commit from @xXx-caillou-xXx, we can now write amazingly flexible rules.
Diffstat (limited to 'src/sp_var_parser.h')
-rw-r--r--src/sp_var_parser.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/sp_var_parser.h b/src/sp_var_parser.h
new file mode 100644
index 0000000..eec1d06
--- /dev/null
+++ b/src/sp_var_parser.h
@@ -0,0 +1,51 @@
1#ifndef SP_VAR_PARSER_H
2# define SP_VAR_PARSER_H
3# include "php_snuffleupagus.h"
4# include "sp_list.h"
5
6typedef enum {
7 OBJECT = 1,
8 ARRAY,
9 ARRAY_END,
10 STRING_DELIMITER,
11 CLASS,
12 VAR,
13 ESC_STRING_DELIMITER,
14 CONSTANT
15} elem_type;
16
17typedef struct sp_token_s {
18 elem_type type;
19 char *token;
20 unsigned int pos;
21} sp_token_t;
22
23typedef struct parser_s {
24 elem_type type;
25 char *value;
26 struct parser_s *idx;
27 struct parser_s *next;
28} sp_tree;
29
30zval *get_value(zend_execute_data *, const sp_tree *, bool);
31sp_tree *sp_tree_new();
32sp_tree *parse_var(const char *);
33void print_type_list(const char *, sp_tree*, int);
34void sp_tree_free(sp_tree *);
35
36# define OBJECT_TOKEN "->"
37# define ARRAY_TOKEN "["
38# define ARRAY_END_TOKEN "]"
39# define STRING_TOKEN "\""
40# define ESC_STRING_TOKEN "\'"
41# define CLASS_TOKEN "::"
42
43# define VARIABLE_TOKEN '$'
44
45# define PRIVATE_PROP_FMT "%c%s%c%s"
46# define PROTECTED_PROP_FMT "%c*%c%s"
47
48# define REGEXP_VAR "^\\$[a-z_][a-z0-9_]*$"
49# define REGEXP_CONST "^[a-z_0-9\\\\]*$"
50
51#endif