diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-06-26 07:36:03 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-06-26 07:36:03 +0000 |
| commit | 3c2d1890d0c5de25bbaa7c582c20bcd67bc47d8c (patch) | |
| tree | 9091c47c4693ab1ef14b98fc76726fec8c56c2f5 /src/runtime/c/pgf/pgf.c | |
| parent | d94b6146f2074608fba07421dd6185ac3a296680 (diff) | |
patch for adjustable heuristics from Python
Diffstat (limited to 'src/runtime/c/pgf/pgf.c')
| -rw-r--r-- | src/runtime/c/pgf/pgf.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c index f1b85cae3..95b2132f5 100644 --- a/src/runtime/c/pgf/pgf.c +++ b/src/runtime/c/pgf/pgf.c @@ -211,9 +211,17 @@ GuEnum* pgf_parse(PgfConcr* concr, PgfCId cat, PgfLexer *lexer, GuPool* pool, GuPool* out_pool) { + return pgf_parse_with_heuristics(concr, cat, lexer, -1.0, pool, out_pool); +} + +GuEnum* +pgf_parse_with_heuristics(PgfConcr* concr, PgfCId cat, PgfLexer *lexer, + double heuristics, + GuPool* pool, GuPool* out_pool) +{ // Begin parsing a sentence of the specified category PgfParseState* state = - pgf_parser_init_state(concr, cat, 0, pool, out_pool); + pgf_parser_init_state(concr, cat, 0, heuristics, pool, out_pool); if (state == NULL) { return NULL; } @@ -244,7 +252,7 @@ pgf_get_completions(PgfConcr* concr, PgfCId cat, PgfLexer *lexer, { // Begin parsing a sentence of the specified category PgfParseState* state = - pgf_parser_init_state(concr, cat, 0, pool, pool); + pgf_parser_init_state(concr, cat, 0, -1, pool, pool); if (state == NULL) { return NULL; } @@ -268,31 +276,3 @@ pgf_get_completions(PgfConcr* concr, PgfCId cat, PgfLexer *lexer, // Now begin enumerating the resulting syntax trees return pgf_parser_completions(state, prefix); } - -void -pgf_print_chunks(PgfConcr* concr, PgfCId cat, PgfLexer *lexer, GuPool* pool) -{ - // Begin parsing a sentence of the specified category - PgfParseState* state = - pgf_parser_init_state(concr, cat, 0, pool, pool); - if (state == NULL) { - printf("\n"); - return; - } - - // Tokenization - GuExn* lex_err = gu_new_exn(NULL, gu_kind(type), pool); - PgfToken tok = pgf_lexer_read_token(lexer, lex_err); - while (!gu_exn_is_raised(lex_err)) { - // feed the token to get a new parse state - state = pgf_parser_next_state(state, tok); - if (state == NULL) { - printf("\n"); - return; - } - - tok = pgf_lexer_read_token(lexer, lex_err); - } - - pgf_parse_print_chunks(state); -} |
