From f2a87d34f6469af1715608412fc5454e177d0901 Mon Sep 17 00:00:00 2001 From: xXx-caillou-xXx Date: Wed, 20 Dec 2017 18:28:21 +0100 Subject: Refactor a bit the sp_tree implementation --- src/sp_var_parser.h | 48 +++++++++++++----------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) (limited to 'src/sp_var_parser.h') 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 @@ #ifndef SP_VAR_PARSER_H -# define SP_VAR_PARSER_H -# include "php_snuffleupagus.h" -# include "sp_list.h" - -typedef enum { - OBJECT = 1, - ARRAY, - ARRAY_END, - STRING_DELIMITER, - CLASS, - VAR, - ESC_STRING_DELIMITER, - CONSTANT -} elem_type; +#define SP_VAR_PARSER_H +#include "php_snuffleupagus.h" typedef struct sp_token_s { elem_type type; @@ -20,32 +8,22 @@ typedef struct sp_token_s { unsigned int pos; } sp_token_t; -typedef struct parser_s { - elem_type type; - char *value; - struct parser_s *idx; - struct parser_s *next; -} sp_tree; - zval *get_value(zend_execute_data *, const sp_tree *, bool); -sp_tree *sp_tree_new(); sp_tree *parse_var(const char *); -void print_type_list(const char *, sp_tree*, int); -void sp_tree_free(sp_tree *); -# define OBJECT_TOKEN "->" -# define ARRAY_TOKEN "[" -# define ARRAY_END_TOKEN "]" -# define STRING_TOKEN "\"" -# define ESC_STRING_TOKEN "\'" -# define CLASS_TOKEN "::" +#define OBJECT_TOKEN "->" +#define ARRAY_TOKEN "[" +#define ARRAY_END_TOKEN "]" +#define STRING_TOKEN "\"" +#define ESC_STRING_TOKEN "\'" +#define CLASS_TOKEN "::" -# define VARIABLE_TOKEN '$' +#define VARIABLE_TOKEN '$' -# define PRIVATE_PROP_FMT "%c%s%c%s" -# define PROTECTED_PROP_FMT "%c*%c%s" +#define PRIVATE_PROP_FMT "%c%s%c%s" +#define PROTECTED_PROP_FMT "%c*%c%s" -# define REGEXP_VAR "^\\$[a-z_][a-z0-9_]*$" -# define REGEXP_CONST "^[a-z_0-9\\\\]*$" +#define REGEXP_VAR "^\\$[a-z_][a-z0-9_]*$" +#define REGEXP_CONST "^[a-z_0-9\\\\]*$" #endif -- cgit v1.3