From 9bc5349e622cf00156b46f56a940d035e000115a Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 16 Dec 2014 10:21:26 +0000 Subject: change in the API for literals The API in the C runtime as well as in the Haskell, Python and Java binding is changed. Now instead of adding the literal callbacks to the concrete syntax you need to supply them every time when you need to parse. The main reason is: - referentially transparent API for Haskell - when we start using memory mapped files we will not be allowed to change anything in the grammar data structures. At that point the old API would be impossible to use. --- src/runtime/c/utils/pgf-parse.c | 7 ++----- src/runtime/c/utils/pgf-translate.c | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/runtime/c/utils') diff --git a/src/runtime/c/utils/pgf-parse.c b/src/runtime/c/utils/pgf-parse.c index eb417d5e7..088fe409d 100644 --- a/src/runtime/c/utils/pgf-parse.c +++ b/src/runtime/c/utils/pgf-parse.c @@ -58,10 +58,6 @@ int main(int argc, char* argv[]) { goto fail; } - /* // Register a callback for the literal category Symbol */ - /* pgf_parser_add_literal(from_concr, "Symb", */ - /* &pgf_nerc_literal_callback); */ - clock_t end = clock(); double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; @@ -109,7 +105,8 @@ int main(int argc, char* argv[]) { clock_t start = clock(); GuExn* parse_err = gu_new_exn(ppool); - GuEnum* result = pgf_parse_with_heuristics(concr, cat, line, heuristics, parse_err, ppool, ppool); + PgfCallbacksMap* callbacks = pgf_new_callbacks_map(concr, ppool); + GuEnum* result = pgf_parse_with_heuristics(concr, cat, line, heuristics, callbacks, parse_err, ppool, ppool); PgfExprProb* ep = NULL; if (gu_ok(parse_err)) diff --git a/src/runtime/c/utils/pgf-translate.c b/src/runtime/c/utils/pgf-translate.c index 0f3b297aa..065853215 100644 --- a/src/runtime/c/utils/pgf-translate.c +++ b/src/runtime/c/utils/pgf-translate.c @@ -87,8 +87,10 @@ int main(int argc, char* argv[]) { } // Register a callback for the literal category Symbol - pgf_concr_add_literal(from_concr, "Symb", - &pgf_nerc_literal_callback, err); + PgfCallbacksMap* callbacks = + pgf_new_callbacks_map(from_concr, pool); + pgf_callbacks_map_add_literal(from_concr, callbacks, + "PN", &pgf_nerc_literal_callback); // Create an output stream for stdout GuOut* out = gu_file_out(stdout, pool); -- cgit v1.2.3