-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathqb_parser.h
147 lines (124 loc) · 5.46 KB
/
qb_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Chung Leong <cleong@cal.berkeley.edu> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef QB_PARSER_H_
#define QB_PARSER_H_
typedef struct qb_parser_context qb_parser_context;
typedef struct qb_lexer_context qb_lexer_context;
typedef struct qb_type_declaration qb_type_declaration;
typedef struct qb_function_declaration qb_function_declaration;
typedef struct qb_class_declaration qb_class_declaration;
typedef struct qb_matrix_dimension qb_matrix_dimension;
typedef struct qb_token_position qb_token_position;
enum {
QB_TYPE_DECL_STRING = 0x00010000,
QB_TYPE_DECL_BOOLEAN = 0x00020000,
QB_TYPE_DECL_AUTOVIVIFICIOUS = 0x00040000,
QB_TYPE_DECL_HAS_ALIAS_SCHEMES = 0x00080000,
QB_TYPE_DECL_IMAGE = 0x00100000,
QB_TYPE_DECL_COMPLEX = 0x00200000,
QB_TYPE_DECL_VECTOR = 0x00400000,
QB_TYPE_DECL_MATRIX = 0x00800000,
};
struct qb_type_declaration {
pcre *regexp;
const char *name;
uint32_t name_length;
ulong hash_value;
uint32_t type;
uint32_t flags;
uint32_t *dimensions;
uint32_t dimension_count;
qb_index_alias_scheme **index_alias_schemes;
};
struct qb_class_declaration {
qb_type_declaration **declarations;
uint32_t declaration_count;
zend_class_entry *zend_class;
};
struct qb_function_declaration {
qb_type_declaration **declarations;
uint32_t declaration_count;
uint32_t flags;
const char *import_path;
uint32_t import_path_length;
zend_op_array *zend_op_array;
qb_class_declaration *class_declaration;
};
struct qb_matrix_dimension {
uint32_t row;
uint32_t column;
};
struct qb_token_position {
uint32_t index;
uint32_t length;
};
struct qb_lexer_context {
const char *cursor;
const char *token;
const char *base;
const char *marker;
int condition;
};
struct qb_parser_context {
qb_lexer_context *lexer_context;
qb_lexer_context comment_lexer_context;
qb_lexer_context definition_lexer_context;
int parser_selector;
qb_token_position constant_position;
qb_function_declaration *function_declaration;
qb_class_declaration *class_declaration;
qb_type_declaration *type_declaration;
qb_data_pool *pool;
zend_class_entry *zend_class;
const char *property_name;
uint32_t property_name_length;
ulong property_hash_value;
uint32_t property_flags;
const char *file_path;
uint32_t file_id;
uint32_t line_number_max;
#ifdef ZTS
void ***tsrm_ls;
#endif
};
qb_function_declaration * qb_parse_function_doc_comment(qb_parser_context *cxt, zend_op_array *op_array);
qb_class_declaration * qb_parse_class_doc_comment(qb_parser_context *cxt, zend_class_entry *ce);
void qb_initialize_parser_context(qb_parser_context *cxt, qb_data_pool *pool, zend_class_entry *ce, const char *filename, uint32_t line_number TSRMLS_DC);
void qb_free_parser_context(qb_parser_context *cxt);
int32_t qb_find_engine_tag(const char *doc_comment);
int32_t qb_set_engine_flags(qb_parser_context *cxt, uint32_t flags, qb_token_position p);
int32_t qb_add_import(qb_parser_context *cxt, qb_token_position p);
int32_t qb_add_variable_declaration(qb_parser_context *cxt, uint32_t type, qb_token_position p);
int32_t qb_add_property_declaration(qb_parser_context *cxt, uint32_t type, qb_token_position p);
int32_t qb_end_variable_declaration(qb_parser_context *cxt);
int32_t qb_set_variable_type(qb_parser_context *cxt, qb_primitive_type type, uint32_t flags, qb_token_position p);
int32_t qb_add_dimension(qb_parser_context *cxt, uint32_t count, uint32_t flags, qb_token_position p);
int32_t qb_add_matrix_dimension(qb_parser_context *cxt, qb_matrix_dimension dim, qb_token_position p);
int32_t qb_add_index_alias_scheme(qb_parser_context *cxt, qb_index_alias_scheme *scheme, qb_token_position p);
int32_t qb_attach_variable_name(qb_parser_context *cxt, qb_token_position p);
int32_t qb_attach_variable_name_regexp(qb_parser_context *cxt, qb_token_position p);
int32_t qb_attach_index_alias_scheme_class(qb_parser_context *cxt, qb_index_alias_scheme *scheme, qb_token_position p);
qb_index_alias_scheme *qb_create_index_alias_scheme(qb_parser_context *cxt);
int32_t qb_add_index_alias(qb_parser_context *cxt, qb_index_alias_scheme *scheme, qb_token_position p);
int32_t qb_parse_constant(qb_parser_context *cxt, qb_token_position p);
uint32_t qb_parse_integer(qb_parser_context *cxt, qb_token_position p, uint32_t radix);
qb_matrix_dimension qb_parse_dimension(qb_parser_context *cxt, qb_token_position p);
void qb_doc_comment_yyinit(qb_parser_context *cxt, const char *doc_comment, int parser_selector);
int qb_doc_comment_yyparse(qb_parser_context *cxt);
#endif