mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-20 02:09:32 -06:00
remove the read and write modules from libgu. this simplifies the i/o layer
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include <gu/variant.h>
|
||||
#include <gu/map.h>
|
||||
#include <gu/dump.h>
|
||||
#include <gu/log.h>
|
||||
#include <gu/enum.h>
|
||||
#include <gu/file.h>
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user