Skip to content

Commit

Permalink
NLP-ENGINE-427 Added pnsetfired function to allow highlighting
Browse files Browse the repository at this point in the history
Signed-off-by: David de Hilster <[email protected]>
  • Loading branch information
ddehilster committed Oct 10, 2024
1 parent 3b4891b commit bfa50d8
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/Api/lite/Arun.h
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,8 @@ class LITE_API Arun
static RFASem *pnvarnames(Nlppp*,RFASem*); // 05/13/02 AM.
static RFASem *pnvartype(Nlppp*,NODE*,_TCHAR*);

static bool pnsetfired(Nlppp*,NODE*,bool);

static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,_TCHAR*); // 07/03/02 AM.
static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,long long); // 07/03/02 AM.
static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,RFASem*); // 07/03/02 AM.
Expand Down
73 changes: 70 additions & 3 deletions lite/fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ switch (fnid) // 12/21/01 AM.
return fnPnroot(args,nlppp,/*UP*/sem); // 10/18/00 AM.
case FNpnrpushval:
return fnPnrpushval(args,nlppp,/*UP*/sem); // 12/12/14 AM.
case FNpnsetfired:
return fnPnsetfired(args,nlppp,sem);
case FNpnsingletdown:
return fnPnsingletdown(args,nlppp,/*UP*/sem); // 10/18/00 AM.
case FNpnup:
Expand Down Expand Up @@ -10953,11 +10955,11 @@ Parse *parse = nlppp->parse_;
RFASem *sem1;
_TCHAR *name1=0;

if (!Arg::sem1(_T("pnvar"),nlppp,(DELTS*&)args,sem1))
if (!Arg::sem1(_T("pnvartype"),nlppp,(DELTS*&)args,sem1))
return false;
if (!Arg::str1(_T("pnvar"), /*UP*/ (DELTS*&)args, name1))
if (!Arg::str1(_T("pnvartype"), /*UP*/ (DELTS*&)args, name1))
return false;
if (!Arg::done((DELTS*)args, _T("pnvar"),parse))
if (!Arg::done((DELTS*)args, _T("pnvartype"),parse))
return false;

if (!sem1)
Expand Down Expand Up @@ -10991,6 +10993,71 @@ return true;
}


/********************************************
* FN: FNPNSETFIRED
* CR: 10/8/2024 Dd.
* SUBJ: Sets the fired flag of a PNODE.
* RET: previous value of fired flag.
********************************************/

bool Fn::fnPnsetfired(
Delt<Iarg> *args,
Nlppp *nlppp,
RFASem* &sem
)
{
sem = 0;
Parse *parse = nlppp->parse_;

RFASem *sem1;
long long num1=0;

if (!Arg::sem1(_T("pnsetflag"),nlppp,(DELTS*&)args,sem1))
return false;
if (!Arg::num1(_T("pnsetflag"), /*UP*/ (DELTS*&)args,num1))
return false;
if (!Arg::done((DELTS*)args, _T("pnsetflag"),parse))
return false;

if (!sem1)
{
_stprintf(Errbuf,_T("[pnsetflag: Warning. Given no pnode.]"));
return parse->errOut(true);
}

if (sem1->getType() != RSNODE)
{
_stprintf(Errbuf,_T("[pnsetflag: Bad semantic arg.]"));
return parse->errOut(false);
}

Node<Pn> *node = sem1->getNode();

if (!node)
{
_stprintf(Errbuf,_T("[pnsetflag: Couldn't fetch node.]"));
return parse->errOut(false);
}

if (num1 < 0LL || num1 > 1LL)
{
_stprintf(Errbuf,_T("[pnsetflag: Warning. Flag value out of range.]"));
return parse->errOut(true);
}

bool firedFlag = (num1 == 1LL);
if (firedFlag) {
Delt<Seqn> *seq = parse->getSeq();
Seqn *seqn = 0;
if (!(seqn = seq->getData()))
return 0;
seqn->setDisplaytree(true);
}
Arun::pnsetfired(nlppp,node,firedFlag);
return true;
}


#ifdef _ODBC

/********************************************
Expand Down
1 change: 1 addition & 0 deletions lite/fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ static bool fnStruniquechars(
static bool fnInteractive(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/06/02 AM.
static bool fnPnvarnames(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/13/02 AM.
static bool fnPnvartype(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/13/02 AM.
static bool fnPnsetfired(Delt<Iarg>*,Nlppp*,RFASem*&);

static bool fnDbopen(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/23/02 AM.
static bool fnDbclose(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/23/02 AM.
Expand Down
17 changes: 17 additions & 0 deletions lite/fnrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13412,6 +13412,23 @@ return sem;
}


bool Arun::pnsetfired(
Nlppp *nlppp,
NODE *pnode,
bool fired
)
{
RFASem *sem = 0;
if (!nlppp || !pnode || !fired)
return 0;

Node<Pn> *node = (Node<Pn> *)pnode;
Pn *pn = node->getData();
pn->setFired(fired);
return fired;
}


#ifdef _ODBC

/********************************************
Expand Down
1 change: 1 addition & 0 deletions lite/func_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ enum funcDef
FNpnreplaceval,
FNpnroot,
FNpnrpushval, // 12/12/14 AM.
FNpnsetfired,
FNpnsingletdown,
FNpnup,
FNpnvar,
Expand Down
1 change: 1 addition & 0 deletions lite/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ _T("pnrename"),
_T("pnreplaceval"),
_T("pnroot"),
_T("pnrpushval"), // 12/12/14 AM.
_T("pnsetfired"),
_T("pnsingletdown"),
_T("pnup"),
_T("pnvar"),
Expand Down
1 change: 1 addition & 0 deletions lite/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ std::_t_ostream *sout; // For restoring output stream. // 12/01/98 AM.
clock_t s_time;
_TCHAR *pretname;
Seqn *pass = seq->getData();
this->seq_ = seq;
Algo *algo = pass->getAlgo();
_TCHAR *sfile = pass->getRulesfilename();
_TCHAR *salgo = pass->getAlgoname();
Expand Down
2 changes: 2 additions & 0 deletions lite/pat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ if (!rulelist)
gerrStr << _T("[Pat pass given no rules.]") << std::ends;
return errOut(&gerrStr,false);
}
if (seqn->displaytree_)
prettyPass(root,tree,parse);
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions lite/seqn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ else
rules_ = rules;
name_ = name; // 11/24/98 AM.
rulesfile_ = 0; // 11/25/98 AM.
displaytree_ = false;
active_ = true; // 01/08/99 AM.
comment_[0] = '\0'; // 01/08/99 AM.
passnum_ = 0; // 09/23/99 AM.
Expand Down Expand Up @@ -102,6 +103,7 @@ if (comment && *comment) // 02/12/99 AM.
algo = 0;
rules_ = 0;
rulesfile_ = 0;
displaytree_ = false;
passnum_ = 0; // 09/23/99 AM.
recid_ = 0;

Expand Down Expand Up @@ -156,6 +158,7 @@ Dlist<Irule> *Seqn::getRules() {return rules_; }
_TCHAR *Seqn::getName() {return name_; }
Ifile *Seqn::getRulesfile() {return rulesfile_; }
bool Seqn::getActive() {return active_; }
bool Seqn::getDisplaytree() {return displaytree_; }
_TCHAR *Seqn::getComment() {return comment_; }
_TCHAR *Seqn::getAlgoname() {return algo_name_; }
int Seqn::getPassnum() {return passnum_; } // 09/23/99 AM.
Expand Down Expand Up @@ -186,6 +189,7 @@ void Seqn::setRules(Dlist<Irule> *x) {rules_ = x;}
void Seqn::setName(_TCHAR *x) {name_ = x;}
void Seqn::setRulesfile(Ifile *x) {rulesfile_ = x;}
void Seqn::setActive(bool x) {active_ = x;}
void Seqn::setDisplaytree(bool x) {displaytree_ = x;}
void Seqn::setPassnum(int x) {passnum_ = x;} // 09/23/99 AM.
void Seqn::setRecid(int x) {recid_ = x;}
void Seqn::setComment(_TCHAR *x)
Expand Down
4 changes: 4 additions & 0 deletions lite/seqn.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Seqn
Ifile *getRulesfile();
Dlist<Iarg> *getSelects(); // 11/30/98 AM.
bool getActive(); // 01/08/99 AM.
bool getDisplaytree();
_TCHAR *getAlgoname(); // 01/08/99 AM.
_TCHAR *getComment(); // 01/08/99 AM.
int getPassnum(); // 09/23/99 AM.
Expand All @@ -83,6 +84,7 @@ class Seqn
void setRulesfile(Ifile *);
void setSelects(Dlist<Iarg> *);
void setActive(bool); // 01/08/99 AM.
void setDisplaytree(bool);
void setAlgoname(_TCHAR *); // 01/08/99 AM.
void setComment(_TCHAR *); // 01/08/99 AM.
void setPassnum(int); // 09/23/99 AM.
Expand Down Expand Up @@ -142,6 +144,8 @@ class Seqn

Ifile *rulesfile_; // Internal representation of rules file.// 11/25/98 AM.

bool displaytree_; // Force tree to be displayed

// New data to enable user-editing of the analyzer sequence.// 01/08/99 AM.
bool active_; // If this pass will be executed. // 01/08/99 AM.
_TCHAR comment_[MAXSTR]; // User comment for pass. // 01/08/99 AM.
Expand Down
2 changes: 1 addition & 1 deletion nlp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ All rights reserved.
#include "lite/nlp_engine.h"
#include "version.h"

#define NLP_ENGINE_VERSION "2.13.0"
#define NLP_ENGINE_VERSION "2.14.1"

bool cmdReadArgs(int,_TCHAR*argv[],_TCHAR*&,_TCHAR*&,_TCHAR*&,_TCHAR*&,bool&,bool&,bool&);
void cmdHelpargs(_TCHAR*);
Expand Down
2 changes: 1 addition & 1 deletion vcpkg
Submodule vcpkg updated 3220 files

0 comments on commit bfa50d8

Please sign in to comment.