summaryrefslogtreecommitdiff
path: root/src/runtime/c/utils
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-12-16 10:21:26 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-12-16 10:21:26 +0000
commit9bc5349e622cf00156b46f56a940d035e000115a (patch)
tree8259f44c9857e66dc5901235eac94ad8f3f74cdc /src/runtime/c/utils
parentd98bd34a33cee7bd6a0fba3c7105256512c309ad (diff)
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.
Diffstat (limited to 'src/runtime/c/utils')
-rw-r--r--src/runtime/c/utils/pgf-parse.c7
-rw-r--r--src/runtime/c/utils/pgf-translate.c6
2 files changed, 6 insertions, 7 deletions
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);