diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2012-12-12 11:25:58 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2012-12-12 11:25:58 +0000 |
| commit | aa13090b66d7ee1ffc68ad242c6419a83cf364d9 (patch) | |
| tree | d36bacbc5f4e0990aae925da31ddeaf2a465a003 /src/runtime/c/utils/pgf-chunk.c | |
| parent | 5e091d2e3dc428daa1d4b0d8df6e7b613adc22a9 (diff) | |
started an official API to the C runtime
Diffstat (limited to 'src/runtime/c/utils/pgf-chunk.c')
| -rw-r--r-- | src/runtime/c/utils/pgf-chunk.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/runtime/c/utils/pgf-chunk.c b/src/runtime/c/utils/pgf-chunk.c index c4d0d0b3f..d5e203368 100644 --- a/src/runtime/c/utils/pgf-chunk.c +++ b/src/runtime/c/utils/pgf-chunk.c @@ -8,7 +8,6 @@ #include <gu/enum.h> #include <gu/file.h> #include <pgf/pgf.h> -#include <pgf/data.h> #include <pgf/parser.h> #include <pgf/lexer.h> #include <pgf/literals.h> @@ -39,38 +38,28 @@ int main(int argc, char* argv[]) { GuString from_lang = gu_str_string(argv[3], pool); - FILE* infile = fopen(filename, "r"); - if (infile == NULL) { - fprintf(stderr, "couldn't open %s\n", filename); - status = EXIT_FAILURE; - goto fail; - } - - // Create an input stream from the input file - GuIn* in = gu_file_in(infile, pool); - // Create an exception frame that catches all errors. GuExn* err = gu_new_exn(NULL, gu_kind(type), pool); // Read the PGF grammar. - PgfPGF* pgf = pgf_read(in, pool, err); + PgfPGF* pgf = pgf_read(filename, pool, err); // If an error occured, it shows in the exception frame if (!gu_ok(err)) { fprintf(stderr, "Reading PGF failed\n"); status = EXIT_FAILURE; - goto fail_read; + goto fail; } - if (!pgf_load_meta_child_probs(pgf, "../../../treebanks/PennTreebank/ParseEngAbs3.probs", pool)) { + pgf_load_meta_child_probs(pgf, "../../../treebanks/PennTreebank/ParseEngAbs3.probs", pool, err); + if (!gu_ok(err)) { fprintf(stderr, "Loading meta child probs failed\n"); status = EXIT_FAILURE; - goto fail_read; + goto fail; } // Look up the source and destination concrete categories - PgfConcr* from_concr = - gu_map_get(pgf->concretes, &from_lang, PgfConcr*); + PgfConcr* from_concr = pgf_get_language(pgf, from_lang); if (!from_concr) { fprintf(stderr, "Unknown language\n"); status = EXIT_FAILURE; @@ -152,8 +141,6 @@ int main(int argc, char* argv[]) { ppool = NULL; } fail_concr: -fail_read: - fclose(infile); fail: gu_pool_free(pool); return status; |
