1
0
forked from GitHub/gf-core

implemented nonExist

This commit is contained in:
krangelov
2021-12-01 14:10:34 +01:00
parent 7e1a2447c2
commit 15c03816ea
4 changed files with 23 additions and 7 deletions

View File

@@ -310,10 +310,20 @@ void PgfLinearizer::free_ref(object x)
PgfLinearizationOutput::PgfLinearizationOutput() : printer(NULL,0,NULL) PgfLinearizationOutput::PgfLinearizationOutput() : printer(NULL,0,NULL)
{ {
bind = true; bind = true;
nonexist = false;
capit = false; capit = false;
allcapit = false; allcapit = false;
} }
PgfText *PgfLinearizationOutput::get_text()
{
if (nonexist) {
free(printer.get_text());
return NULL;
}
return printer.get_text();
}
void PgfLinearizationOutput::symbol_token(PgfText *tok) void PgfLinearizationOutput::symbol_token(PgfText *tok)
{ {
if (!bind) { if (!bind) {
@@ -375,6 +385,7 @@ void PgfLinearizationOutput::end_phrase(PgfText *cat, int fid, PgfText *ann, Pgf
void PgfLinearizationOutput::symbol_ne() void PgfLinearizationOutput::symbol_ne()
{ {
nonexist = true;
} }
void PgfLinearizationOutput::symbol_bind() void PgfLinearizationOutput::symbol_bind()

View File

@@ -4,13 +4,14 @@
class PGF_INTERNAL_DECL PgfLinearizationOutput : public PgfLinearizationOutputIface { class PGF_INTERNAL_DECL PgfLinearizationOutput : public PgfLinearizationOutputIface {
PgfPrinter printer; PgfPrinter printer;
bool bind; bool bind;
bool nonexist;
bool capit; bool capit;
bool allcapit; bool allcapit;
public: public:
PgfLinearizationOutput(); PgfLinearizationOutput();
PgfText *get_text() { return printer.get_text(); }; PgfText *get_text();
virtual void symbol_token(PgfText *tok); virtual void symbol_token(PgfText *tok);
virtual void begin_phrase(PgfText *cat, int fid, PgfText *ann, PgfText *fun); virtual void begin_phrase(PgfText *cat, int fid, PgfText *ann, PgfText *fun);

View File

@@ -71,11 +71,13 @@ again: {
PgfText *PgfPrinter::get_text() PgfText *PgfPrinter::get_text()
{ {
if (res == NULL) { PgfText *tmp = res;
res = (PgfText*) malloc(sizeof(PgfText)); if (tmp == NULL) {
res->size = 0; tmp = (PgfText*) malloc(sizeof(PgfText));
tmp->size = 0;
} }
return res; res = NULL;
return tmp;
} }
void PgfPrinter::flush_lambdas() void PgfPrinter::flush_lambdas()

View File

@@ -584,7 +584,9 @@ linearize c e =
bracket (newStablePtr e) freeStablePtr $ \c_e -> bracket (newStablePtr e) freeStablePtr $ \c_e ->
withForeignPtr marshaller $ \m -> withForeignPtr marshaller $ \m ->
bracket (withPgfExn "linearize" (pgf_linearize (c_db c) c_revision c_e m)) free $ \c_text -> bracket (withPgfExn "linearize" (pgf_linearize (c_db c) c_revision c_e m)) free $ \c_text ->
peekText c_text if c_text == nullPtr
then return ""
else peekText c_text
-- | Generates all possible linearizations of an expression -- | Generates all possible linearizations of an expression
linearizeAll :: Concr -> Expr -> [String] linearizeAll :: Concr -> Expr -> [String]