.PHONY: psi-clean-headers
psi-clean-headers:
-rm -f $(PHP_PSI_HEADERS)
- -rmdir $(PHP_PSI_BUILDDIR)/types
.PHONY: psi-clean-sources
psi-clean-sources:
#include "parser.h"
-void *psi_parser_proc_Alloc(void*(unsigned long));
-void psi_parser_proc_Free(void*, void(*)(void*));
-void psi_parser_proc_(void *, token_t, struct psi_token *, struct psi_parser *);
-void psi_parser_proc_Trace(FILE *, const char*);
+void *psi_parser_proc_init(void);
+void psi_parser_proc_free(void **parser_proc);
+void psi_parser_proc_parse(void *parser_proc, token_t r, struct psi_token *token, struct psi_parser *parser);
+void psi_parser_proc_trace(FILE *out, char *prefix);
struct psi_parser *psi_parser_init(struct psi_parser *P, psi_error_cb error, unsigned flags)
{
P->col = 1;
P->line = 1;
- P->proc = psi_parser_proc_Alloc(malloc);
+ P->proc = psi_parser_proc_init();
if (flags & PSI_DEBUG) {
- psi_parser_proc_Trace(stderr, "PSI> ");
+ psi_parser_proc_trace(stderr, "PSI> ");
}
return P;
void psi_parser_parse(struct psi_parser *P, struct psi_token *T)
{
if (T) {
- psi_parser_proc_(P->proc, T->type, T, P);
+ psi_parser_proc_parse(P->proc, T->type, T, P);
} else {
- psi_parser_proc_(P->proc, 0, NULL, P);
+ psi_parser_proc_parse(P->proc, 0, NULL, P);
}
}
void psi_parser_dtor(struct psi_parser *P)
{
- psi_parser_proc_Free(P->proc, free);
+ psi_parser_proc_free(&P->proc);
switch (P->input.type) {
case PSI_PARSE_FILE:
# define TOKEN_DTOR(token, dtor)
#endif
-DEF(%name, psi_parser_proc_)
DEF(%token_prefix, PSI_T_)
DEF(%token_type, {struct psi_token *})
DEF(%token_destructor, {free($$);})
#include "plist.h"
#include "parser.h"
+
+/* rename lemon symbols, works better than DEF(%name) */
+#define ParseAlloc psi_parser_proc_init_ex
+#define Parse psi_parser_proc_parse
+#define ParseTrace psi_parser_proc_trace
+#define ParseFree psi_parser_proc_free_ex
+
+/* fwd decls */
+void *ParseAlloc(void *(*mallocProc)(size_t));
+void ParseFree(void *p, void (*freeProc)(void*));
+
+/* wrappers */
+void *psi_parser_proc_init(void)
+{
+ return ParseAlloc(malloc);
+}
+
+void psi_parser_proc_free(void **parser_proc)
+{
+ if (*parser_proc) {
+ ParseFree(*parser_proc, free);
+ *parser_proc = NULL;
+ }
+}
+
}
#include "plist.h"
#include "parser.h"
+
+/* rename lemon symbols, works better than DEF(%name) */
+#define ParseAlloc psi_parser_proc_init_ex
+#define Parse psi_parser_proc_parse
+#define ParseTrace psi_parser_proc_trace
+#define ParseFree psi_parser_proc_free_ex
+
+/* fwd decls */
+void *ParseAlloc(void *(*mallocProc)(size_t));
+void ParseFree(void *p, void (*freeProc)(void*));
+
+/* wrappers */
+void *psi_parser_proc_init(void)
+{
+ return ParseAlloc(malloc);
+}
+
+void psi_parser_proc_free(void **parser_proc)
+{
+ if (*parser_proc) {
+ ParseFree(*parser_proc, free);
+ *parser_proc = NULL;
+ }
+}
+
}
-%name psi_parser_proc_
%token_prefix PSI_T_
%token_type {struct psi_token *}
%token_destructor {free($$);}