mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-09-19 00:36:02 -06:00
for backwards compatibility, now a string literal is a sequence of any characters except space.
This commit is contained in:
@@ -308,14 +308,13 @@ PgfType PgfInternalMarshaller::match_type(PgfUnmarshaller *u, PgfType ty)
|
||||
PgfExprParser::PgfExprParser(PgfText *input, size_t byte_pos, PgfUnmarshaller *unmarshaller)
|
||||
{
|
||||
inp = input;
|
||||
pos = (const char*) &inp->text[byte_pos];
|
||||
ch = ' ';
|
||||
u = unmarshaller;
|
||||
token_pos = NULL;
|
||||
token_value = NULL;
|
||||
bs = NULL;
|
||||
|
||||
token();
|
||||
reset_pos(byte_pos);
|
||||
token();
|
||||
}
|
||||
|
||||
PgfExprParser::~PgfExprParser()
|
||||
@@ -433,6 +432,30 @@ bool PgfExprParser::str_char()
|
||||
return getc();
|
||||
}
|
||||
|
||||
void PgfExprParser::raw_token()
|
||||
{
|
||||
token_tag = PGF_TOKEN_STR;
|
||||
token_pos = pos;
|
||||
token_value = NULL;
|
||||
|
||||
while (pgf_utf8_is_space(ch)) {
|
||||
token_pos = pos;
|
||||
if (!getc()) {
|
||||
token_tag = PGF_TOKEN_EOF;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (!pgf_utf8_is_space(ch)) {
|
||||
putc(ch);
|
||||
if (!getc())
|
||||
break;
|
||||
}
|
||||
|
||||
if (token_value == NULL)
|
||||
token_tag = PGF_TOKEN_EOF;
|
||||
}
|
||||
|
||||
void PgfExprParser::token()
|
||||
{
|
||||
if (token_value != NULL)
|
||||
|
||||
@@ -175,6 +175,7 @@ public:
|
||||
|
||||
bool str_char();
|
||||
void token();
|
||||
void raw_token();
|
||||
bool lookahead(int ch);
|
||||
|
||||
bool parse_bind();
|
||||
@@ -195,7 +196,7 @@ public:
|
||||
bool is_str() { return (token_tag == PGF_TOKEN_STR); }
|
||||
bool is_ident() { return (token_tag == PGF_TOKEN_IDENT); }
|
||||
|
||||
void ident2str() { token_tag = PGF_TOKEN_STR; }
|
||||
void reset_pos(size_t pos) { this->pos = &inp->text[pos]; this->ch = ' '; }
|
||||
|
||||
const PgfText *get_token_value() { return token_value; }
|
||||
const char *get_token_pos() { return token_pos; }
|
||||
|
||||
@@ -1576,9 +1576,12 @@ void PgfParser::suspend(Cont *cont,Item *item,bool do_predict,ref<PgfSymbolCat>
|
||||
bu_literal(cont->state, "Int", &eparser, viterbi_prob);
|
||||
} else if (eparser.is_flt()) {
|
||||
bu_literal(cont->state, "Float", &eparser, viterbi_prob);
|
||||
} else if (eparser.is_ident()) {
|
||||
eparser.ident2str();
|
||||
bu_literal(cont->state, "String", &eparser, viterbi_prob);
|
||||
} else {
|
||||
eparser.reset_pos(cont->state->end.byte_pos);
|
||||
eparser.raw_token();
|
||||
if (eparser.is_str()) {
|
||||
bu_literal(cont->state, "String", &eparser, viterbi_prob);
|
||||
}
|
||||
}
|
||||
bu_predict(concr->phrasetable1, cont->state, viterbi_prob, 1, sentence->size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user