void* __parse_string(const char* str, GError** err, parser parser_cb, parser_alloc parser_alloc_cb, parser_free parser_free_cb, lexer lexer_cb) { parser_context* ctx = g_new0(parser_context, 1); ctx->stream = stream_new_from_string(str); if (ctx->stream == NULL) { g_free(ctx); g_set_error(err, 0, 1, "Stream can't be created!"); return NULL; } __parse(ctx, parser_cb, parser_alloc_cb, parser_free_cb, lexer_cb); if (ctx->error) { g_set_error(err, 0, 1, "%s", ctx->error); return NULL; } void* data = ctx->data; g_free(ctx); return data; }
String __getName(Const Char * arg) { if(!__inCache(arg)) __parse(arg); return String(name__,param__-name__-1); }
String __getParam(Const Char * arg) { if(!__inCache(arg)) __parse(arg); return String(param__,paramEnd__-param__); }
/** * Board constructor * * Create custom board from JSON array * */ Board::Board(const std::string json) { int width, height = 0; int **board = __parse(json, width, height); if ( board ) { _board = board; _width = width; _height = height; _size = width * height; __init(); } else { _board = NULL; } }
size_t __parse_ws(struct state* s) { return __parse(s,__isblank); }