From 7c0bad50921365746ea362710015853a4879c0a7 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Thu, 5 Sep 2013 11:20:39 +0000 Subject: remove the read and write modules from libgu. this simplifies the i/o layer --- src/runtime/c/utils/pgf-parse.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/runtime/c/utils/pgf-parse.c') diff --git a/src/runtime/c/utils/pgf-parse.c b/src/runtime/c/utils/pgf-parse.c index c64b07434..a990ee933 100644 --- a/src/runtime/c/utils/pgf-parse.c +++ b/src/runtime/c/utils/pgf-parse.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -75,11 +74,6 @@ int main(int argc, char* argv[]) { // Create an output stream for stdout GuOut* out = gu_file_out(stdout, pool); - // Locale-encoding writers are currently unsupported - // GuWriter* wtr = gu_locale_writer(out, pool); - // Use a writer with hard-coded utf-8 encoding for now. - GuWriter* wtr = gu_new_utf8_writer(out, pool); - // We will keep the latest results in the 'ppool' and // we will iterate over them by using 'result'. GuPool* ppool = NULL; @@ -118,8 +112,8 @@ int main(int argc, char* argv[]) { clock_t start = clock(); - GuReader *rdr = gu_string_reader(gu_str_string(line, ppool), ppool); - PgfLexer *lexer = pgf_new_simple_lexer(rdr, ppool); + GuIn *in = gu_string_in(gu_str_string(line, ppool), ppool); + PgfLexer *lexer = pgf_new_simple_lexer(in, ppool); GuEnum* result = pgf_parse_with_heuristics(concr, cat, lexer, heuristics, ppool, ppool); PgfExprProb* ep = NULL; @@ -129,15 +123,15 @@ int main(int argc, char* argv[]) { clock_t end = clock(); double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; - gu_printf(wtr, err, "%d (%.0f ms): ", ctr, 1000.0 * cpu_time_used); + gu_printf(out, err, "%d (%.0f ms): ", ctr, 1000.0 * cpu_time_used); if (ep != NULL) { - gu_printf(wtr, err, "[%.4f] (", ep->prob); - pgf_print_expr(ep->expr, NULL, 0, wtr, err); - gu_printf(wtr, err, ")\n"); + gu_printf(out, err, "[%.4f] (", ep->prob); + pgf_print_expr(ep->expr, NULL, 0, out, err); + gu_printf(out, err, ")\n"); } else { - gu_printf(wtr, err, "---\n"); + gu_printf(out, err, "---\n"); } - gu_writer_flush(wtr, err); + gu_out_flush(out, err); } fail: -- cgit v1.2.3