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