summaryrefslogtreecommitdiff
path: root/src/runtime/c
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2015-02-18 16:14:29 +0000
committerkrasimir <krasimir@chalmers.se>2015-02-18 16:14:29 +0000
commite3a87c657bce38dbf4f571c5816e97b7b0f5bfda (patch)
tree30e6022cac8e4b3d9056790ceac672251fcc906b /src/runtime/c
parent24232004f02672320450225c144b0cca2756fc54 (diff)
fix in the parser for callbacks in the middle of a word
Diffstat (limited to 'src/runtime/c')
-rw-r--r--src/runtime/c/pgf/parser.c72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/runtime/c/pgf/parser.c b/src/runtime/c/pgf/parser.c
index bbdcd3cf6..447a3454f 100644
--- a/src/runtime/c/pgf/parser.c
+++ b/src/runtime/c/pgf/parser.c
@@ -1607,7 +1607,7 @@ pgf_parsing_symbol(PgfParsing* ps, PgfItem* item, PgfSymbol sym)
}
else {
PgfItemConts* conts =
- pgf_parsing_get_conts(ps->before,
+ pgf_parsing_get_conts(ps->before,
parg->ccat, slit->r,
ps->pool);
gu_buf_push(conts->items, PgfItem*, item);
@@ -1616,39 +1616,45 @@ pgf_parsing_symbol(PgfParsing* ps, PgfItem* item, PgfSymbol sym)
/* This is the first time when we encounter this
* literal category so we must call the callback */
- PgfLiteralCallback* callback =
- gu_map_get(ps->callbacks,
- parg->ccat->cnccat,
- PgfLiteralCallback*);
-
- if (callback != NULL) {
- size_t start = ps->before->end_offset;
- size_t offset = start;
- PgfExprProb *ep =
- callback->match(callback,
- slit->r,
- ps->sentence, &offset,
- ps->out_pool);
-
- if (ep != NULL) {
- PgfProduction prod;
- PgfProductionExtern* pext =
- gu_new_variant(PGF_PRODUCTION_EXTERN,
- PgfProductionExtern,
- &prod, ps->pool);
- pext->ep = ep;
- pext->lins = NULL;
-
- PgfItem* item =
- pgf_new_item(ps, conts, prod);
- item->curr_sym = pgf_collect_extern_tok(ps,start,offset);
- item->sym_idx = pgf_item_symbols_length(item);
- PgfParseState* state =
- pgf_new_parse_state(ps, offset, BIND_NONE,
- item->inside_prob+item->conts->outside_prob);
- gu_buf_heap_push(state->agenda, pgf_item_prob_order, &item);
+ bool match = false;
+ if (!ps->before->needs_bind) {
+ PgfLiteralCallback* callback =
+ gu_map_get(ps->callbacks,
+ parg->ccat->cnccat,
+ PgfLiteralCallback*);
+
+ if (callback != NULL) {
+ size_t start = ps->before->end_offset;
+ size_t offset = start;
+ PgfExprProb *ep =
+ callback->match(callback,
+ slit->r,
+ ps->sentence, &offset,
+ ps->out_pool);
+
+ if (ep != NULL) {
+ PgfProduction prod;
+ PgfProductionExtern* pext =
+ gu_new_variant(PGF_PRODUCTION_EXTERN,
+ PgfProductionExtern,
+ &prod, ps->pool);
+ pext->ep = ep;
+ pext->lins = NULL;
+
+ PgfItem* item =
+ pgf_new_item(ps, conts, prod);
+ item->curr_sym = pgf_collect_extern_tok(ps,start,offset);
+ item->sym_idx = pgf_item_symbols_length(item);
+ PgfParseState* state =
+ pgf_new_parse_state(ps, offset, BIND_NONE,
+ item->inside_prob+item->conts->outside_prob);
+ gu_buf_heap_push(state->agenda, pgf_item_prob_order, &item);
+ match = true;
+ }
}
- } else {
+ }
+
+ if (!match) {
pgf_item_free(ps, item);
}
} else {