const char sig[3] = {0x7f, 'D', 'W'};
-const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables", "Database not selected"};
+const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables", "Database not selected", "Parser fail"};
#ifdef M_I86
#define BUFSIZE 128
#include "dataworks.h"
#include <stdbool.h>
+#include <stdio.h>
const char* dataworks_version = "0.0.0";
const char* dataworks_compile_date = __DATE__;
int yywrap() { return 1; }
-int yyerror(const char* err) { return 0; }
+int yyerror(const char* err) { fprintf(stderr, "Parser error: %s\n", err); return 0; }
bool dataworks_get_if_supported(void) {
#ifdef SUPPORTED
r->error = false;
r->value = NULL;
- __dw_parser_parse(code, dolog);
+ int err;
+ if((err = __dw_parser_parse(code, dolog)) != DW_ERR_SUCCESS){
+ r->error = true;
+ r->errnum = err;
+ }
return r;
}
int __dw_parser_parse(const char* str, bool top) {
void* buf = yy_scan_string(str);
- yyparse();
+ if(yyparse() != 0){
+ yy_delete_buffer(buf);
+ return DW_ERR_PARSER_FAIL;
+ }
yy_delete_buffer(buf);
+
+ return DW_ERR_SUCCESS;
}