diff options
| author | xXx-caillou-xXx | 2017-12-20 18:28:21 +0100 |
|---|---|---|
| committer | jvoisin | 2017-12-20 18:28:21 +0100 |
| commit | f2a87d34f6469af1715608412fc5454e177d0901 (patch) | |
| tree | 0b8abb1b33f00559642429a2c561b658443837f0 /src/sp_var_parser.h | |
| parent | e7f541396715ee2895abcf73044b91ae9b746201 (diff) | |
Refactor a bit the sp_tree implementation
Diffstat (limited to 'src/sp_var_parser.h')
| -rw-r--r-- | src/sp_var_parser.h | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/src/sp_var_parser.h b/src/sp_var_parser.h index eec1d06..eec77c9 100644 --- a/src/sp_var_parser.h +++ b/src/sp_var_parser.h | |||
| @@ -1,18 +1,6 @@ | |||
| 1 | #ifndef SP_VAR_PARSER_H | 1 | #ifndef SP_VAR_PARSER_H |
| 2 | # define SP_VAR_PARSER_H | 2 | #define SP_VAR_PARSER_H |
| 3 | # include "php_snuffleupagus.h" | 3 | #include "php_snuffleupagus.h" |
| 4 | # include "sp_list.h" | ||
| 5 | |||
| 6 | typedef 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 | 4 | ||
| 17 | typedef struct sp_token_s { | 5 | typedef struct sp_token_s { |
| 18 | elem_type type; | 6 | elem_type type; |
| @@ -20,32 +8,22 @@ typedef struct sp_token_s { | |||
| 20 | unsigned int pos; | 8 | unsigned int pos; |
| 21 | } sp_token_t; | 9 | } sp_token_t; |
| 22 | 10 | ||
| 23 | typedef struct parser_s { | ||
| 24 | elem_type type; | ||
| 25 | char *value; | ||
| 26 | struct parser_s *idx; | ||
| 27 | struct parser_s *next; | ||
| 28 | } sp_tree; | ||
| 29 | |||
| 30 | zval *get_value(zend_execute_data *, const sp_tree *, bool); | 11 | zval *get_value(zend_execute_data *, const sp_tree *, bool); |
| 31 | sp_tree *sp_tree_new(); | ||
| 32 | sp_tree *parse_var(const char *); | 12 | sp_tree *parse_var(const char *); |
| 33 | void print_type_list(const char *, sp_tree*, int); | ||
| 34 | void sp_tree_free(sp_tree *); | ||
| 35 | 13 | ||
| 36 | # define OBJECT_TOKEN "->" | 14 | #define OBJECT_TOKEN "->" |
| 37 | # define ARRAY_TOKEN "[" | 15 | #define ARRAY_TOKEN "[" |
| 38 | # define ARRAY_END_TOKEN "]" | 16 | #define ARRAY_END_TOKEN "]" |
| 39 | # define STRING_TOKEN "\"" | 17 | #define STRING_TOKEN "\"" |
| 40 | # define ESC_STRING_TOKEN "\'" | 18 | #define ESC_STRING_TOKEN "\'" |
| 41 | # define CLASS_TOKEN "::" | 19 | #define CLASS_TOKEN "::" |
| 42 | 20 | ||
| 43 | # define VARIABLE_TOKEN '$' | 21 | #define VARIABLE_TOKEN '$' |
| 44 | 22 | ||
| 45 | # define PRIVATE_PROP_FMT "%c%s%c%s" | 23 | #define PRIVATE_PROP_FMT "%c%s%c%s" |
| 46 | # define PROTECTED_PROP_FMT "%c*%c%s" | 24 | #define PROTECTED_PROP_FMT "%c*%c%s" |
| 47 | 25 | ||
| 48 | # define REGEXP_VAR "^\\$[a-z_][a-z0-9_]*$" | 26 | #define REGEXP_VAR "^\\$[a-z_][a-z0-9_]*$" |
| 49 | # define REGEXP_CONST "^[a-z_0-9\\\\]*$" | 27 | #define REGEXP_CONST "^[a-z_0-9\\\\]*$" |
| 50 | 28 | ||
| 51 | #endif | 29 | #endif |
