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.
This commit is contained in:
kr.angelov
2014-12-16 10:21:26 +00:00
parent d98bd34a33
commit 9bc5349e62
20 changed files with 425 additions and 440 deletions

View File

@@ -25,6 +25,10 @@ PgfPGF*
pgf_read(const char* fpath,
GuPool* pool, GuExn* err);
PgfPGF*
pgf_read_in(GuIn* in,
GuPool* pool, GuPool* tmp_pool, GuExn* err);
void
pgf_concrete_load(PgfConcr* concr, GuIn* in, GuExn* err);
@@ -114,9 +118,12 @@ GuEnum*
pgf_lookup_word_prefix(PgfConcr *concr, GuString prefix,
GuPool* pool, GuExn* err);
typedef GuMap PgfCallbacksMap;
PgfExprEnum*
pgf_parse_with_heuristics(PgfConcr* concr, PgfCId cat,
GuString sentence, double heuristics,
PgfCallbacksMap* callbacks,
GuExn* err,
GuPool* pool, GuPool* out_pool);
@@ -130,9 +137,6 @@ GuEnum*
pgf_complete(PgfConcr* concr, PgfCId cat, GuString string,
GuString prefix, GuExn* err, GuPool* pool);
GuPool*
pgf_concr_get_pool(PgfConcr* concr);
typedef struct PgfLiteralCallback PgfLiteralCallback;
struct PgfLiteralCallback {
@@ -146,10 +150,12 @@ struct PgfLiteralCallback {
GuPool *out_pool);
};
PgfCallbacksMap*
pgf_new_callbacks_map(PgfConcr* concr, GuPool *pool);
void
pgf_concr_add_literal(PgfConcr *concr, PgfCId cat,
PgfLiteralCallback* callback,
GuExn* err);
pgf_callbacks_map_add_literal(PgfConcr* concr, PgfCallbacksMap* callbacks,
PgfCId cat, PgfLiteralCallback* callback);
void
pgf_print(PgfPGF* pgf, GuOut* out, GuExn* err);