diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-10-09 12:08:51 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-10-09 12:08:51 +0000 |
| commit | 8cf03bc5b6895568eb08be1415985a64793bb81c (patch) | |
| tree | 814e95e1b0422362066fef389e8b03741e8478ad /src/runtime/c/utils/pgf-translate.c | |
| parent | 20e4970ec19949da10b86facd3c6a5a4abb03acb (diff) | |
a major redesign in the C runtime. The parser and the linearizer now fully support BIND. The following things are still broken: parseval, word completion, handling 'pre', the robust mode
Diffstat (limited to 'src/runtime/c/utils/pgf-translate.c')
| -rw-r--r-- | src/runtime/c/utils/pgf-translate.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/runtime/c/utils/pgf-translate.c b/src/runtime/c/utils/pgf-translate.c index aa98f1a7a..abd22267c 100644 --- a/src/runtime/c/utils/pgf-translate.c +++ b/src/runtime/c/utils/pgf-translate.c @@ -2,6 +2,7 @@ #include <gu/map.h> #include <gu/enum.h> #include <gu/file.h> +#include <gu/exn.h> #include <pgf/pgf.h> #include <pgf/parser.h> #include <pgf/literals.h> @@ -153,23 +154,19 @@ int main(int argc, char* argv[]) { // sentence, so our memory usage doesn't increase over time. ppool = gu_new_pool(); - GuIn *in = - gu_string_in(line, ppool); - PgfLexer *lexer = - pgf_new_simple_lexer(in, ppool); - clock_t start = clock(); + GuExn* parse_err = gu_new_exn(NULL, gu_kind(type), ppool); result = - pgf_parse(from_concr, cat, lexer, ppool, ppool); - if (result == NULL) { - PgfToken tok = - pgf_lexer_current_token(lexer); - - if (*tok == 0) - gu_puts("Couldn't begin parsing", out, err); - else { + pgf_parse(from_concr, cat, line, parse_err, ppool, ppool); + if (!gu_ok(parse_err)) { + if (gu_exn_caught(parse_err) == gu_type(PgfExn)) { + GuString msg = gu_exn_caught_data(parse_err); + gu_string_write(msg, out, err); + gu_putc('\n', out, err); + } else if (gu_exn_caught(parse_err) == gu_type(PgfParseError)) { gu_puts("Unexpected token: \"", out, err); + GuString tok = gu_exn_caught_data(parse_err); gu_string_write(tok, out, err); gu_puts("\"\n", out, err); } |
