#include <stdlib.h>
#include <string.h>
+void print_node(struct Node* node, bool top) {
+ printf("%s(", node->ident);
+ if(node->nodes != NULL) {
+ int i;
+ for(i = 0; node->nodes[i] != NULL; i++) {
+ if(i > 0) printf(", ");
+ if(node->nodes[i]->ident != NULL) {
+ print_node(node->nodes[i], false);
+ } else {
+ printf("\"%s\"", node->nodes[i]->string);
+ }
+ }
+ }
+ printf(")");
+ if(top) printf("\n");
+}
+
+void parser_process(struct Node* node, bool dolog) {
+ if(node->ident != NULL) {
+ if(dolog) print_node(node, true);
+ }
+}
+
struct dataworks_db_result* dataworks_database_execute_code(struct dataworks_db* db, const char* code, bool dolog) {
struct dataworks_db_result* r = malloc(sizeof(*r));
r->error = false;
if((node = __dw_parser_parse(code, dolog)) == NULL) {
r->error = true;
r->errnum = DW_ERR_PARSER_FAIL;
+ }else{
+ parser_process(node, dolog);
}
return r;
extern void* yy_scan_string(const char* str);
extern void yy_delete_buffer(void* buffer);
-void print_node(struct Node* node, bool top) {
- printf("%s(", node->ident);
- if(node->nodes != NULL) {
- int i;
- for(i = 0; node->nodes[i] != NULL; i++) {
- if(i > 0) printf(", ");
- if(node->nodes[i]->ident != NULL) {
- print_node(node->nodes[i], false);
- } else {
- printf("\"%s\"", node->nodes[i]->string);
- }
- }
- }
- printf(")");
- if(top) printf("\n");
-}
-
-void parser_process(struct Node* node) {
- if(node->ident != NULL) {
- int i;
- print_node(node, true);
- }
-}
-
struct Node* __dw_parser_parse(const char* str, bool top) {
extern YYSTYPE yyval;
#ifdef PARSER_DEBUG
yy_delete_buffer(buf);
return NULL;
}
- parser_process(&yyval.node);
yy_delete_buffer(buf);
return &yyval.node;