forked from GitHub/gf-core
implemented nonExist
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user