+YAZ_PQF_Parser yaz_pqf_create (void)
+{
+ YAZ_PQF_Parser p = xmalloc (sizeof(*p));
+
+ p->error = 0;
+ p->left_sep = "{\"";
+ p->right_sep = "}\"";
+ p->escape_char = '@';
+ p->term_type = Z_Term_general;
+
+ return p;
+}
+
+void yaz_pqf_destroy (YAZ_PQF_Parser p)
+{
+ xfree (p);
+}
+
+Z_RPNQuery *yaz_pqf_parse (YAZ_PQF_Parser p, ODR o, const char *qbuf)
+{
+ if (!p)
+ return 0;
+ p->query_buf = p->query_ptr = qbuf;
+ p->lex_buf = 0;
+ return p_query_rpn_mk (o, p, PROTO_Z3950, qbuf);
+}
+
+Z_AttributesPlusTerm *yaz_pqf_scan (YAZ_PQF_Parser p, ODR o,
+ Odr_oid **attributeSetP,
+ const char *qbuf)
+{
+ if (!p)
+ return 0;
+ p->query_buf = p->query_ptr = qbuf;
+ p->lex_buf = 0;
+ return p_query_scan_mk (p, o, PROTO_Z3950, attributeSetP, qbuf);
+}
+
+int yaz_pqf_error (YAZ_PQF_Parser p, const char **msg, size_t *off)
+{
+ switch (p->error)
+ {
+ case YAZ_PQF_ERROR_NONE:
+ *msg = "no error"; break;
+ case YAZ_PQF_ERROR_EXTRA:
+ *msg = "extra token"; break;
+ case YAZ_PQF_ERROR_MISSING:
+ *msg = "missing token"; break;
+ case YAZ_PQF_ERROR_ATTSET:
+ *msg = "unknown attribute set"; break;
+ case YAZ_PQF_ERROR_TOOMANY:
+ *msg = "too many attributes"; break;
+ case YAZ_PQF_ERROR_BADATTR:
+ *msg = "bad attribute specification"; break;
+ case YAZ_PQF_ERROR_INTERNAL:
+ *msg = "internal error"; break;
+ default:
+ *msg = "unknown error"; break;
+ }
+ *off = p->query_ptr - p->query_buf;
+ return p->error;
+}